Sha256: 34d46dbfd569cd387c6c45bae485d42527162afe230b3dc9a20a2944a981e433
Contents?: true
Size: 1.09 KB
Versions: 33
Compression:
Stored size: 1.09 KB
Contents
#!/usr/bin/env ruby require 'tins/go' include Tins::GO require 'tins/xt/secure_write' require 'tempfile' path_separator = RUBY_PLATFORM =~ /mswin32/ ? ';' : ':' path = (ENV['PATH'] || '').split(path_separator) path.map! { |part| File.expand_path(part) } $opts = go('e') case cmd = ARGV.shift when 'prefix', 'postfix' part = ARGV.shift or fail 'need a path part to prefix' part = File.expand_path(part) path.delete part if cmd == 'prefix' path.unshift part else path.push part end when 'list' if path_argument = ARGV.first path = path_argument.split(path_separator) path.map! { |part| File.expand_path(part) } end puts path exit when 'edit' if path_argument = ARGV.first path = path_argument.split(path_separator) path.map! { |part| File.expand_path(part) } end path_file = File.join(Dir.tmpdir, "path_temp.#$$") File.secure_write path_file, path * "\n" system "edit -w #{path_file.inspect}" path = File.read(path_file).split(/\n/) path.map! { |part| File.expand_path(part) } end path.uniq! puts "#{'export ' if $opts[?e]}PATH=#{path * path_separator}"
Version data entries
33 entries across 33 versions & 1 rubygems