···11-function e -d "Run $EDITOR with given file" --wraps $EDITOR
22- set -x VIMRUNTIME /usr/share/vim/vim74/
33- eval "$EDITOR '$argv'"
44-end
-3
fish/functions/g.fish
···11-function g --description 'Less typing more work!' --wraps git
22- git $argv
33-end
-7
fish/functions/git.fish
···11-function git --description 'Git wrapper that run hub fi avaliable'
22- if which hub ^/dev/null >/dev/null
33- hub $argv
44- else
55- command git $argv
66- end
77-end
-3
fish/functions/grep.fish
···11-function grep --description 'Search for a regexp in file(s)'
22- command grep --color=auto $argv
33-end
···11-function mcd --description="Create a directory and set CWD"
22- command mkdir $argv
33- if test $status = 0
44- switch $argv[(count $argv)]
55- case '-*'
66- case '*'
77- cd $argv[(count $argv)]
88- return
99- end
1010- end
1111-end
-3
fish/functions/most-used.fish
···11-function most-used --description 'Print most used commands'
22- history | awk '{print $1}' | sort | uniq -c | sort -rn | head $argv
33-end
···11-function ssh_agent
22- if [ -z "$SSH_ENV" ]
33- echo 'You must set $SSH_ENV variable to use ssh-agent in login shell'
44- echo 'Otherwise you can run `exec ssh-agent fish` to use it'
55- return 1
66- end
77-88- # Load old ssh-agent instance
99- [ -f "$SSH_ENV" ]; and source "$SSH_ENV"
1010-1111- # Check if agent is running
1212- ssh-add -l > /dev/null ^&1
1313- if [ ! $status -eq 0 ]
1414- echo "Setting up ssh-agent"
1515-1616- # Run ssh-agent
1717- ssh-agent -c | sed 's/^echo/#echo/' > "$SSH_ENV"
1818- source "$SSH_ENV"
1919-2020- # Add SSH identities
2121- ssh-add
2222- end
2323-end
···11-function work
22- set project (basename (git rev-parse --show-toplevel))
33- time -f '%E' -- tmux new -s $project ; or time -f '%E' -- tmux attach -t $project
44-end
-129
fish/themes/agnoster.fish
···11-set SEGMENT_SEPARATOR ''
22-set SEGMENT_BG
33-set RSTATUS
44-55-set SEGMENT_LSEPARATOR ''
66-77-function prompt_segment --desc 'Create prompt segment'
88- set -l bg $argv[1]
99- set -l fg $argv[2]
1010- [ (count $argv) -gt 2 ]; and set -l content $argv[3..-1]
1111-1212- set_color -b $bg
1313-1414- if begin; [ -n "$SEGMENT_BG" ]; and [ "$SEGMENT_BG" != "$bg" ]; end
1515- color_echo $SEGMENT_BG $SEGMENT_SEPARATOR
1616- end
1717-1818- if [ -n "$content" ]
1919- set SEGMENT_BG $bg
2020- set_color -b $bg $fg
2121- echo -n " $content"
2222- end
2323-end
2424-2525-function color_echo
2626- set_color $argv[1]
2727- echo -n $argv[2]
2828-end
2929-3030-function prompt_context
3131- set -l user (whoami)
3232- set -l host (hostname)
3333-3434- if begin; [ "$user" != "$DEFAULT_USER" ]; or [ -n "$SSH_CLIENT" ]; end
3535- prompt_segment black normal "$user@$host "
3636- end
3737-end
3838-3939-function parse_git_dirty
4040- set -l submodule_syntax
4141- set submodule_syntax "--ignore-submodules=dirty"
4242- set git_dirty (command git status -s $submodule_syntax 2> /dev/null)
4343- if [ -n "$git_dirty" ]
4444- echo -n "±"
4545- else
4646- echo -n ""
4747- end
4848-end
4949-5050-# Status:
5151-# - was there an error
5252-# - am I root
5353-# - are there background jobs?
5454-function prompt_status
5555- set -l icons
5656- if [ "$RSTATUS" -ne 0 ]
5757- set icons $icons (set_color red -b black; echo -n "✘ ")
5858- end
5959- if [ (id -u $USER) -eq 0 ]
6060- set icons $icons (set_color red -b black; echo -n "⚡ ")
6161- end
6262- if [ (jobs -l | wc -l) -ne 0 ]
6363- set icons $icons (set_color red -b black; echo -n "⚙ ")
6464- end
6565-6666- prompt_segment black normal "$icons"
6767-end
6868-6969-function prompt_git -d "Display the actual git state"
7070- set -l ref
7171- set -l dirty
7272- if command git rev-parse --is-inside-work-tree >/dev/null ^&1
7373- set dirty (parse_git_dirty)
7474- set ref (command git symbolic-ref HEAD ^/dev/null)
7575- if [ $status -gt 0 ]
7676- set -l branch (command git show-ref --head -s --abbrev |head -n1 ^/dev/null)
7777- set ref "➦ $branch "
7878- end
7979- set branch_symbol \uE0A0
8080- set -l branch (echo $ref | sed "s-refs/heads/-$branch_symbol -")
8181- if [ "$dirty" != "" ]
8282- prompt_segment yellow black "$branch$dirty "
8383- else
8484- prompt_segment green black "$branch$dirty "
8585- end
8686- end
8787-end
8888-8989-# Dir: current working directory
9090-function prompt_dir
9191- set -l dir (prompt_pwd)
9292- prompt_segment blue black "$dir "
9393-end
9494-9595-function prompt_finish
9696- prompt_segment normal normal
9797- echo -n ' '
9898- set SEGMENT_BG
9999-end
100100-101101-function fish_prompt
102102- set RSTATUS $status
103103- prompt_status
104104- prompt_context
105105- prompt_dir
106106- prompt_git
107107- prompt_finish
108108-end
109109-110110-function fish_right_prompt
111111- if [ -n "$fish_bind_mode" ]
112112- switch "$fish_bind_mode"
113113- case default
114114- set color white
115115- case insert
116116- set color yellow
117117- case visual
118118- set color magenta
119119- case '*'
120120- set color black
121121- end
122122-123123- set_color normal
124124- color_echo "$color" "$SEGMENT_LSEPARATOR"
125125- set_color -b $color
126126- color_echo black " $fish_bind_mode "
127127- set_color normal
128128- end
129129-end