Skip to content

Instantly share code, notes, and snippets.

@mrchrisadams
Forked from burke/0-readme.md
Created October 27, 2013 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrchrisadams/7181254 to your computer and use it in GitHub Desktop.
Save mrchrisadams/7181254 to your computer and use it in GitHub Desktop.

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.

#!/usr/bin/env ruby
Dir.chdir("/opt/boxen") do
File.open(File.expand_path("~/.config/fish/boxen.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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment