Skip to content

Instantly share code, notes, and snippets.

@ragingwind
Last active April 3, 2017 03:18
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 ragingwind/1e2edf7717fe7c49062fd42eea3490bf to your computer and use it in GitHub Desktop.
Save ragingwind/1e2edf7717fe7c49062fd42eea3490bf to your computer and use it in GitHub Desktop.
fish shell
function chpwd --on-variable PWD --description 'handler of changing $PWD'
if not status --is-command-substitution ; and status --is-interactive
set cur_cwd (echo $PWD | sed -e "s|^$HOME|~|" -e 's|^/private||')
# set_color -o black
# printf (printf "%*s" (tput cols)) | sed -e "s/ /\─/g";
echo ""
printf "%s⇢ %sEntering %s%s%s …\n" (set_color $fish_color_cwd) (set_color normal) (set_color $fish_color_cwd) $cur_cwd (set_color normal)
ls
end
end
set default_user "ragingwind"
set default_machine ""
# source ~/.config/fish/path.fish
# source ~/.config/fish/aliases.fish
source ~/.config/fish/chpwd.fish
# source ~/.config/fish/functions.fish
# source ~/.config/fish/chromium.fish
source ~/.config/fish/shell-extra.fish
source ~/.config/fish/git-extra.fish
# for things not checked into git..
if test -e "$HOME/.extra.fish";
source ~/.extra.fish
end
# THEME PURE #
set fish_function_path /Users/paulirish/.config/fish/functions/pure $fish_function_path
export GOPATH=$HOME/.go/
# Completions
function make_completion --argument-names alias command
echo "
function __alias_completion_$alias
set -l cmd (commandline -o)
set -e cmd[1]
complete -C\"$command \$cmd\"
end
" | .
complete -c $alias -a "(__alias_completion_$alias)"
end
make_completion g 'git'
# Readline colors
set -g fish_color_autosuggestion 555 yellow
set -g fish_color_command 5f87d7
set -g fish_color_comment 808080
set -g fish_color_cwd 87af5f
set -g fish_color_cwd_root 5f0000
set -g fish_color_error 870000 --bold
set -g fish_color_escape af5f5f
set -g fish_color_history_current 87afd7
set -g fish_color_host 5f87af
set -g fish_color_match d7d7d7 --background=303030
set -g fish_color_normal normal
set -g fish_color_operator d7d7d7
set -g fish_color_param 5f87af
set -g fish_color_quote d7af5f
set -g fish_color_redirection normal
set -g fish_color_search_match --background=purple
set -g fish_color_status 5f0000
set -g fish_color_user 5f875f
set -g fish_color_valid_path --underline
set -g fish_color_dimmed 555
set -g fish_color_separator 999
# Git prompt status
set -g __fish_git_prompt_showdirtystate 'yes'
set -g __fish_git_prompt_showupstream auto
set -g pure_git_untracked_dirty false
# Status Chars
#set __fish_git_prompt_char_dirtystate '*'
set __fish_git_prompt_char_upstream_equal ''
set __fish_git_prompt_char_upstream_ahead '↑'
set __fish_git_prompt_char_upstream_behind '↓'
set __fish_git_prompt_color_branch yellow
set __fish_git_prompt_color_dirtystate 'red'
set __fish_git_prompt_color_upstream_ahead ffb90f
set __fish_git_prompt_color_upstream_behind blue
# Local prompt customization
set -e fish_greeting
set -g fish_pager_color_completion normal
set -g fish_pager_color_description 555 yellow
set -g fish_pager_color_prefix cyan
set -g fish_pager_color_progress cyan
# highlighting inside manpages and elsewhere
set -gx LESS_TERMCAP_mb \e'[01;31m' # begin blinking
set -gx LESS_TERMCAP_md \e'[01;38;5;74m' # begin bold
set -gx LESS_TERMCAP_me \e'[0m' # end mode
set -gx LESS_TERMCAP_se \e'[0m' # end standout-mode
set -gx LESS_TERMCAP_so \e'[38;5;246m' # begin standout-mode - info box
set -gx LESS_TERMCAP_ue \e'[0m' # end underline
set -gx LESS_TERMCAP_us \e'[04;38;5;146m' # begin underline
# this currently messes with newlines in my prompt. lets debug it later.
# test -e {$HOME}/.iterm2_shell_integration.fish ; and source {$HOME}/.iterm2_shell_integration.fish
# env
set -gx PATH /usr/local/sbin $PATH
# set -gx PATH /Users/ragingwind/.nvm/v0.10.29/bin/node $PATH
# export DOCKER_HOST=tcp://192.168.59.103:2376
# export DOCKER_CERT_PATH=/Users/ragingwind/.boot2docker/certs/boot2docker-vm
# export DOCKER_TLS_VERIFY=1
export ANDROID_HOME=/Users/ragingwind/Android
set -gx PATH /Users/ragingwind/Android/platform-tools/ $PATH
set -gx PATH /Users/ragingwind/Android/tools/ $PATH
# export GOPATH=/Users/ragingwind/Go/gopath
# set -gx PATH $GOPATH/bin $PATH
# set -gx PATH /usr/local/go_appengine $PATH
# set -gx PATH /usr/local/google-cloud-sdk/bin $PATH
# set -gx PATH /Users/Go/go_appengine $PATH
# source '/usr/local/google-cloud-sdk/path.bash.inc'
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/
# shortcut
# alias dc-connect='ssh core@128.199.129.152'
# alias va='vagrant'
function _pwd_with_tilde
echo $PWD | sed 's|^'$HOME'\(.*\)$|~\1|'
end
function _in_git_directory
git rev-parse --git-dir > /dev/null 2>&1
end
function _git_branch_name_or_revision
set -l branch (git symbolic-ref HEAD ^ /dev/null | sed -e 's|^refs/heads/||')
set -l revision (git rev-parse HEAD ^ /dev/null | cut -b 1-7)
if test (count $branch) -gt 0
echo $branch
else
echo $revision
end
end
function _git_upstream_configured
git rev-parse --abbrev-ref @"{u}" > /dev/null 2>&1
end
function _git_behind_upstream
test (git rev-list --right-only --count HEAD...@"{u}" ^ /dev/null) -gt 0
end
function _git_ahead_of_upstream
test (git rev-list --left-only --count HEAD...@"{u}" ^ /dev/null) -gt 0
end
function _git_upstream_status
set -l arrows
if _git_upstream_configured
if _git_behind_upstream
set arrows "$arrows⇣"
end
if _git_ahead_of_upstream
set arrows "$arrows⇡"
end
end
echo $arrows
end
function _print_in_color
set -l string $argv[1]
set -l color $argv[2]
set_color $color
printf $string
set_color normal
end
function _prompt_color_for_status
if test $argv[1] -eq 0
echo magenta
else
echo red
end
end
function fish_prompt
set -l last_status $status
_print_in_color "\n"(_pwd_with_tilde) blue
if _in_git_directory
_print_in_color " "(_git_branch_name_or_revision) yellow
_print_in_color " "(_git_upstream_status) red
end
_print_in_color "\n❯ " (_prompt_color_for_status $last_status)
end
edc/bass
fisherman/getopts
fisherman/git_util
fisherman/host_info
fisherman/humanize_duration
fisherman/last_job_id
fisherman/nvm
fisherman/pwd_info
fisherman/pwd_is_home
fisherman/sol
fisherman/z
source ~/.config/fish/functions/getopts.fish
function gite --description "gite <command> <arguments>"
set cmd $argv[1]
set --erase argv[1]
eval "git-"$cmd $argv
end
function git-init
git init
touch readme.md
git add readme.md
git commit -m "first commit"
git remote add origin $argv
git push -u origin master
end
function git-touch-commit
echo "touch"
end
function mkcd
mkdir -p $argv
cd $argv
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment