Skip to content

Instantly share code, notes, and snippets.

@cjs
Forked from burke/0-readme.md
Last active August 29, 2015 14:19

Revisions

  1. @burke burke revised this gist Mar 18, 2013. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions 0-readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    Boxen uses a bunch of shellscripts to insert itself into your environment on shell load.

    These assume a POSIX shell, which fish is not.

    Run this script to generate a fish-compatible config file in `~/.config/fish/boxen.fish`, which you can source at the end of your `~/.config/fish/config.fish`.
  2. @burke burke revised this gist Mar 1, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion boxen-to-fish.rb
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    Dir.chdir("/opt/boxen") do

    File.open("env.fish", "w") do |f|
    File.open(File.expand_path("~/.config/fish/boxen.fish"), "w") do |f|

    ["env.sh", *Dir.glob("env.d/*.sh")].each do |file|

  3. @burke burke created this gist Mar 1, 2013.
    42 changes: 42 additions & 0 deletions boxen-to-fish.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    #!/usr/bin/env ruby

    Dir.chdir("/opt/boxen") do

    File.open("env.fish", "w") do |f|

    ["env.sh", *Dir.glob("env.d/*.sh")].each do |file|

    File.readlines(file).each do |line|
    case line
    when /^#!/
    f.puts "#!/usr/bin/env fish"
    when /^\s*(?:export )?(.*?)=(.*)/
    name, content = $1, $2
    content.gsub!(/:\$/, ' $') # yay fuzzy heuristics
    content.gsub!(/`(.*)`/) {
    contents = $1
    contents.sub!(/^([^\s]+?)=([^\s]+)/, 'env \1=\2')
    "(#{contents})"
    }
    content.gsub!(/\$\{(.*)\}/, '(\1)')
    f.print "set -x #{name} #{content}\n"
    when /^\s*set [\-\+][eu]/
    f.print "# #{line.chomp}\n"
    when /^\s*#.*/
    f.print line
    when /^\s*$/
    f.print line
    else
    f.print "###### PARSE ERR: #{line.chomp}\n"
    end
    end

    end

    f.puts "set -x PATH /opt/boxen/rbenv/shims /opt/boxen/rbenv/bin $PATH"
    f.puts "rbenv rehash 2>/dev/null"

    f.puts "function git ; hub $argv ; end"

    end
    end