Last active
February 8, 2016 15:14
-
-
Save idan/5619691 to your computer and use it in GitHub Desktop.
My fish config. I was using oh-my-fish but it seems to introduce a bunch of bugginess.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if not set -q AUTOENVFISH_FILE | |
set -g AUTOENVFISH_FILE ".env.fish" | |
end | |
# Automatic env loading | |
function _autoenvfish --on-variable PWD | |
if status --is-command-substitution # doesn't work with 'or', inexplicably | |
return | |
end | |
# find an autoenv file, checking up the directory tree until we find | |
# such a file (or nothing) | |
set -l envfishdir $PWD | |
while test ! "$envfishdir" = "" -a ! -f "$envfishdir/$AUTOENVFISH_FILE" | |
# this strips the last path component from the path. | |
set envfishdir (echo "$envfishdir" | sed 's|/[^/]*$||') | |
end | |
# if we've found such a file, source it | |
set -l envfishpath "$envfishdir/$AUTOENVFISH_FILE" | |
if [ -f $envfishpath ] | |
echo "Loading $envfishpath" | |
. $envfishpath | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Disable the greeting | |
set fish_greeting | |
# set PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin | |
# set PATH $HOME/.rvm/bin $PATH # Add RVM to PATH for scripting | |
set -x PATH (brew --prefix ruby)/bin $PATH | |
set -x PATH /Applications/Postgres.app/Contents/MacOS/bin $PATH # postgres.app | |
set -x PATH /usr/local/bin $PATH | |
set -x JAVA_HOME (/usr/libexec/java_home) | |
set -x EC2_PRIVATE_KEY "~/Dropbox/ec2/pk-ZOACHXXRNMOW4VHIQLYM6EWJKVAI6SRY.pem" | |
set -x EC2_CERT "~/Dropbox/ec2/cert-ZOACHXXRNMOW4VHIQLYM6EWJKVAI6SRY.pem" | |
set -x EC2_HOME "/usr/local/Library/LinkedKegs/ec2-api-tools/jars" | |
alias ls "ls -FG" | |
alias git "hub" | |
# Load virtualfish | |
. ~/.config/fish/virtual.fish | |
function _venvactivate --on-event virtualenv_did_activate | |
echo "The virtualenv \""(basename $VIRTUAL_ENV)"\" was activated" | |
end | |
function _venvdeactivate --on-event virtualenv_did_deactivate | |
echo "The virtualenv \""(basename $VIRTUAL_ENV)"\" was deactivated" | |
end | |
# load autoenv.fish | |
. ~/.config/fish/autoenv.fish | |
# Set prompt | |
. ~/.config/fish/fish_prompt.fish | |
. ~/.config/fish/fish_right_prompt.fish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Display the following bits on the left: | |
# * Virtualenv name (if applicable, see https://github.com/adambrenecki/virtualfish) | |
# * Current directory name | |
# * Git branch and dirty state (if inside a git repo) | |
function _git_branch_name | |
echo (git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||') | |
end | |
function _is_git_dirty | |
echo (git status -s --ignore-submodules=dirty ^/dev/null) | |
end | |
function fish_prompt | |
set -l cyan (set_color -o cyan) | |
set -l yellow (set_color -o yellow) | |
set -l red (set_color -o red) | |
set -l blue (set_color -o blue) | |
set -l green (set_color -o green) | |
set -l normal (set_color normal) | |
set -l cwd $cyan(basename (prompt_pwd)) | |
# output the prompt, left to right | |
# Add a newline before prompts | |
echo -e "" | |
# Display [venvname] if in a virtualenv | |
if set -q VIRTUAL_ENV | |
echo -n -s (set_color -b cyan black) '[' (basename "$VIRTUAL_ENV") ']' $normal ' ' | |
end | |
# Display the current directory name | |
echo -n -s $cwd $normal | |
# Show git branch and dirty state | |
if [ (_git_branch_name) ] | |
set -l git_branch '(' (_git_branch_name) ')' | |
if [ (_is_git_dirty) ] | |
set git_info $red $git_branch " ★ " | |
else | |
set git_info $green $git_branch | |
end | |
echo -n -s ' · ' $git_info $normal | |
end | |
# Terminate with a nice prompt char | |
echo -n -s ' ⟩ ' $normal | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Display the compressed current working path on the right | |
# If the previous command returned any kind of error code, display that too | |
function fish_right_prompt | |
set -l last_status $status | |
set -l cyan (set_color -o cyan) | |
set -l red (set_color -o red) | |
set -l normal (set_color normal) | |
echo -n -s $cyan (prompt_pwd) | |
if test $last_status -ne 0 | |
set_color red | |
printf ' %d' $last_status | |
set_color normal | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment