Created
August 6, 2013 02:15
-
-
Save cz/6161445 to your computer and use it in GitHub Desktop.
Fish config. Most of it stolen from @stevelosh.
This file contains hidden or 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
# Useful aliases {{{ | |
function serve_this | |
python -m SimpleHTTPServer | |
end | |
function c | |
clear | |
end | |
function paththis | |
set PATH (pwd) $PATH | |
end | |
function g | |
git $argv | |
end | |
function gco | |
git checkout $argv | |
end | |
function gl | |
git pull $argv | |
end | |
function v | |
vim $argv | |
end | |
function V | |
vim . | |
end | |
function vu | |
vagrant up | |
end | |
function vd | |
vagrant suspend | |
end | |
function vs | |
vagrant ssh | |
end | |
function vh | |
vagrant halt | |
end | |
function py | |
python $argv | |
end | |
function gmd | |
gco dev; git fetch origin; git merge --ff-only origin/dev --message "Merge branch 'staging' into dev"; git merge --no-ff staging; gco staging | |
end | |
function psg -d "Grep for a running process, returning its PID and full string" | |
ps auxww | grep --color=always $argv | grep -v grep | collapse | cuts -f 2,11- | |
end | |
function hey_virtualbox_shut_down_or_i_will_fucking_cut_you | |
VBoxManage controlvm $argv poweroff | |
end | |
function dp | |
dtach -n /tmp/dp-(random) dreampie (which python) | |
end | |
# }}} | |
# Environment variables {{{ | |
function prepend_to_path -d "Prepend the given dir to PATH if it exists and is not already in it" | |
if test -d $argv[1] | |
if not contains $argv[1] $PATH | |
set -gx PATH "$argv[1]" $PATH | |
end | |
end | |
end | |
prepend_to_path "/usr/local/php5/bin" | |
prepend_to_path "/usr/lib/lightdm/lightdm" | |
prepend_to_path "/usr/sbin" | |
prepend_to_path "/bin" | |
prepend_to_path "/usr/bin" | |
prepend_to_path "/usr/local/bin" | |
prepend_to_path "/usr/local/share/python" | |
prepend_to_path "/usr/local/sbin" | |
prepend_to_path "/usr/games" | |
prepend_to_path "$HOME/.bin" | |
prepend_to_path "/opt/local/bin" | |
prepend_to_path "/opt/vagrant/bin" | |
prepend_to_path "/usr/local/heroku/bin" | |
prepend_to_path "/var/lib/gems/1.9.1" | |
set BROWSER open | |
set -g -x fish_greeting '' | |
set -g -x COMMAND_MODE unix2003 | |
set -g -x RUBYOPT rubygems | |
set -g -x NODE_PATH "/usr/local/lib/node_modules" | |
# }}} | |
# Python variables {{{ | |
set -g -x PIP_DOWNLOAD_CACHE "$HOME/.pip/cache" | |
set -g -x WORKON_HOME "$HOME/.virtualenvs" | |
set -gx WORKON_HOME "$HOME/.virtualenvs" | |
. ~/.config/fish/virtualenv.fish | |
# }}} | |
# Prompt {{{ | |
set normal (set_color normal) | |
set magenta (set_color magenta) | |
set yellow (set_color yellow) | |
set green (set_color green) | |
set gray (set_color -o black) | |
function __fish_git_in_working_tree | |
[ "true" = (git rev-parse --is-inside-work-tree ^ /dev/null; or echo false) ] | |
end | |
function __fish_git_dirty | |
not git diff --no-ext-diff --quiet --exit-code ^ /dev/null | |
or not git diff-index --cached --quiet HEAD ^ /dev/null | |
or count (git ls-files --others --exclude-standard) > /dev/null | |
end | |
function __fish_git_current_head | |
git symbolic-ref HEAD ^ /dev/null | |
or git describe --contains --all HEAD | |
end | |
function __fish_git_current_branch | |
__fish_git_current_head | sed -e "s#^refs/heads/##" | |
end | |
function __fish_git_current_commit | |
git log -1 --format="%h" | |
end | |
function git_prompt | |
if __fish_git_in_working_tree | |
if __fish_git_dirty | |
set_color magenta | |
else | |
set_color yellow | |
end | |
printf " ± %s @%s" (__fish_git_current_branch) (__fish_git_current_commit) | |
if __fish_git_dirty | |
printf "!" | |
end | |
set_color normal | |
end | |
set_color normal | |
end | |
function virtualenv_prompt | |
if [ -n "$VIRTUAL_ENV" ] | |
set_color green | |
printf ' | %s |' (basename "$VIRTUAL_ENV") | |
set_color normal | |
end | |
end | |
function prompt_pwd --description 'CWD, shortened to fit the prompt' | |
echo $PWD | sed -e "s|^$HOME|~|" | |
end | |
function fish_prompt | |
echo | |
set_color $fish_color_cwd | |
printf '%s' (prompt_pwd) | |
set_color normal | |
git_prompt | |
virtualenv_prompt | |
echo | |
set_color white -o | |
printf '↪ ' | |
set_color normal | |
end | |
# }}} | |
# Directories {{{ | |
alias .. 'cd ..' | |
alias ... 'cd ../..' | |
alias .... 'cd ../../..' | |
alias ..... 'cd ../../../..' | |
alias md 'mkdir -p' | |
alias l1 'tree --dirsfirst -ChFL 1' | |
alias l2 'tree --dirsfirst -ChFL 2' | |
alias l3 'tree --dirsfirst -ChFL 3' | |
alias l4 'tree --dirsfirst -ChFL 4' | |
alias l5 'tree --dirsfirst -ChFL 5' | |
alias l6 'tree --dirsfirst -ChFL 6' | |
alias ll1 'tree --dirsfirst -ChFupDaL 1' | |
alias ll2 'tree --dirsfirst -ChFupDaL 2' | |
alias ll3 'tree --dirsfirst -ChFupDaL 3' | |
alias ll4 'tree --dirsfirst -ChFupDaL 4' | |
alias ll5 'tree --dirsfirst -ChFupDaL 5' | |
alias ll6 'tree --dirsfirst -ChFupDaL 6' | |
alias l 'l1' | |
alias ll 'll1' | |
# }}} | |
# Misc {{{ | |
# }}} | |
# Local Settings {{{ | |
if test -s $HOME/.config/fish/local.fish | |
source $HOME/.config/fish/local.fish | |
end | |
# }}} | |
true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment