Sha256: 93a94f31efee9b86fb644b1415d015b8517c60b71efb5e6016a568162ede8fa1

Contents?: true

Size: 940 Bytes

Versions: 10

Compression:

Stored size: 940 Bytes

Contents

#!/usr/bin/env ruby

require 'spruz/go'
include Spruz::GO
require 'spruz/xt/write'
require 'tempfile'

path_separator = RUBY_PLATFORM =~ /mswin32/ ? ';' : ':'
path = (ENV['PATH'] || '').split(path_separator)
path.map! { |part| File.expand_path(part) }

$opt = 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 '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.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 $opt['e']}PATH=#{path * path_separator}"

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
utils-0.0.16 bin/path
utils-0.0.15 bin/path
utils-0.0.14 bin/path
utils-0.0.13 bin/path
utils-0.0.12 bin/path
utils-0.0.10 bin/path
utils-0.0.8 bin/path
utils-0.0.7 bin/path
utils-0.0.6 bin/path
utils-0.0.5 bin/path