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