Mercurial > dotfiles
annotate fish/config.fish @ 425:350f7a55ff33
Improve fish configuration.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 28 Mar 2018 20:07:21 -0700 |
parents | 61f343a2aaff |
children | 9a046e8fe5dd |
rev | line source |
---|---|
371 | 1 |
2 # Environment variables {{{ | |
3 | |
425
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
4 set -x fish_greeting 'Hello.' |
371 | 5 |
6 # My own stuff. | |
404 | 7 if test -d $HOME/.local/bin |
425
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
8 set -x PATH $HOME/.local/bin $PATH |
404 | 9 end |
10 if test -d $HOME/bin | |
425
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
11 set -x PATH $HOME/bin $PATH |
404 | 12 end |
425
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
13 set -x OS MacOSX |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
14 set -x EDITOR vim |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
15 #set -x TERM screen-256color-bce |
371 | 16 |
17 # Python. | |
425
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
18 set -x VIRTUAL_ENV_DISABLE_PROMPT 1 |
371 | 19 |
425
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
20 # Detect Git/Hg availability. |
404 | 21 if type -q git |
425
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
22 set -x __local_has_git |
404 | 23 end |
24 if type -q hg | |
425
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
25 set -x __local_has_hg |
404 | 26 end |
425
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
27 |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
28 # Detect my own stuff. |
407
c6da0c9f40ae
Replace subrepos with an install script. Finally.
Ludovic Chabant <ludovic@chabant.com>
parents:
405
diff
changeset
|
29 if test -e $HOME/.local/bin/fast-hg-bookmark |
425
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
30 set -x __local_has_fast_hg_bookmark |
407
c6da0c9f40ae
Replace subrepos with an install script. Finally.
Ludovic Chabant <ludovic@chabant.com>
parents:
405
diff
changeset
|
31 end |
404 | 32 |
371 | 33 # }}} |
34 | |
35 # Aliases {{{ | |
36 | |
404 | 37 # Run Tmux in UTF8 and 256 colours always. |
371 | 38 alias tm 'tmux -u2' |
39 | |
425
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
40 # Switch directories. |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
41 alias .. 'cd ..' |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
42 alias ... 'cd ../..' |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
43 alias .... 'cd ../../..' |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
44 alias ..... 'cd ../../../..' |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
45 |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
46 alias md 'mkdir -p' |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
47 |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
48 # }}} |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
49 |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
50 # Key Bindings {{{ |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
51 |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
52 |
371 | 53 # }}} |
54 | |
55 # Prompt {{{ | |
56 | |
57 set normal (set_color normal) | |
58 set magenta (set_color magenta) | |
59 set yellow (set_color yellow) | |
60 set green (set_color green) | |
61 set gray (set_color -o black) | |
62 | |
63 function virtualenv_prompt | |
64 if set -q VIRTUAL_ENV | |
65 set_color -b blue white | |
66 printf '(venv:%s)' (basename "$VIRTUAL_ENV") | |
67 set_color normal | |
68 printf ' ' | |
69 end | |
70 end | |
71 | |
72 function prompt_char | |
404 | 73 if set -q __local_has_git |
74 if git branch >/dev/null 2>/dev/null | |
75 printf '±' ; return | |
76 end | |
77 if hg root >/dev/null 2>/dev/null | |
78 printf '☿' ; return | |
79 end | |
80 echo '○' | |
371 | 81 end |
82 end | |
83 | |
84 function hg_prompt | |
407
c6da0c9f40ae
Replace subrepos with an install script. Finally.
Ludovic Chabant <ludovic@chabant.com>
parents:
405
diff
changeset
|
85 if set -q __local_has_hg |
c6da0c9f40ae
Replace subrepos with an install script. Finally.
Ludovic Chabant <ludovic@chabant.com>
parents:
405
diff
changeset
|
86 and set -q __local_has_fast_hg_bookmark |
404 | 87 set_color magenta |
88 printf '%s' (fast-hg-bookmark 2>/dev/null) | |
89 set_color normal | |
90 end | |
371 | 91 end |
92 | |
93 function git_prompt | |
404 | 94 if set -q __local_has_git |
95 if git root >/dev/null 2>&1 | |
96 set_color normal | |
97 printf ' on ' | |
98 set_color magenta | |
99 printf '%s' (git currentbranch ^/dev/null) | |
100 set_color green | |
101 git_prompt_status | |
102 set_color normal | |
103 end | |
371 | 104 end |
105 end | |
106 | |
107 function fish_prompt | |
108 set last_status $status | |
109 | |
110 echo | |
111 | |
112 # 'username@hostname: ' | |
113 set_color magenta | |
114 printf '%s' (whoami) | |
115 set_color normal | |
116 printf '@' | |
117 set_color yellow | |
118 printf '%s' (hostname|cut -d . -f 1) | |
119 set_color normal | |
120 printf ': ' | |
121 | |
122 set_color $fish_color_cwd | |
123 printf '%s' (prompt_pwd) | |
124 set_color normal | |
125 | |
126 printf ' ' | |
127 prompt_char | |
128 printf ' ' | |
129 | |
130 hg_prompt | |
131 | |
132 echo | |
133 | |
134 virtualenv_prompt | |
135 | |
136 if test $last_status -eq 0 | |
137 set_color white -o | |
138 printf '> ' | |
139 else | |
140 set_color red -o | |
141 printf '[%d] > ' $last_status | |
142 end | |
143 | |
144 set_color normal | |
145 end | |
146 | |
147 # }}} | |
148 | |
425
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
149 # FZF {{{ |
371 | 150 |
425
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
151 if type -q fzf |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
152 function _gen_fzf_default_opts |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
153 set -l base03 "234" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
154 set -l base02 "235" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
155 set -l base01 "240" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
156 set -l base00 "241" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
157 set -l base0 "244" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
158 set -l base1 "245" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
159 set -l base2 "254" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
160 set -l base3 "230" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
161 set -l yellow "136" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
162 set -l orange "166" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
163 set -l red "160" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
164 set -l magenta "125" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
165 set -l violet "61" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
166 set -l blue "33" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
167 set -l cyan "37" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
168 set -l green "64" |
371 | 169 |
425
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
170 # Solarized Dark color scheme for fzf |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
171 set -x FZF_DEFAULT_OPTS "--color fg:-1,bg:-1,hl:$blue,fg+:$base2,bg+:$base02,hl+:$blue --color info:$yellow,prompt:$yellow,pointer:$base3,marker:$base3,spinner:$yellow" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
172 # Solarized Light color scheme for fzf |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
173 #set -x FZF_DEFAULT_OPTS "--color fg:-1,bg:-1,hl:$blue,fg+:$base02,bg+:$base2,hl+:$blue --color info:$yellow,prompt:$yellow,pointer:$base03,marker:$base03,spinner:$yellow" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
174 end |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
175 |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
176 _gen_fzf_default_opts |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
177 |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
178 if type -q ag |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
179 # Use Ag for searching. |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
180 set -x FZF_DEFAULT_COMMAND 'ag --nocolor -g ""' |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
181 end |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
182 |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
183 # Use the default command for searching in Fisherman's FZF plugin. |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
184 set -x FZF_FIND_FILE_COMMAND $FZF_DEFAULT_COMMAND |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
185 set -U FZF_LEGACY_KEYBINDINGS 0 |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
186 end |
371 | 187 |
188 # }}} | |
189 | |
190 # Local Settings {{{ | |
191 | |
192 if test -s $HOME/.config/fish/local.fish | |
193 . $HOME/.config/fish/local.fish | |
194 end | |
407
c6da0c9f40ae
Replace subrepos with an install script. Finally.
Ludovic Chabant <ludovic@chabant.com>
parents:
405
diff
changeset
|
195 #eval (/usr/local/bin/python -m virtualfish) |
371 | 196 |
197 # }}} | |
198 |