Mercurial > dotfiles
annotate fish/config.fish @ 427:9a046e8fe5dd
Better way to figure out the OS in Fish.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 29 Mar 2018 12:56:11 -0700 |
parents | 350f7a55ff33 |
children | 4f6af3e668eb |
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 | |
90 if hg root >/dev/null 2>/dev/null | |
91 printf '☿' ; return | |
92 end | |
93 echo 'â—‹' | |
371 | 94 end |
95 end | |
96 | |
97 function hg_prompt | |
407
c6da0c9f40ae
Replace subrepos with an install script. Finally.
Ludovic Chabant <ludovic@chabant.com>
parents:
405
diff
changeset
|
98 if set -q __local_has_hg |
c6da0c9f40ae
Replace subrepos with an install script. Finally.
Ludovic Chabant <ludovic@chabant.com>
parents:
405
diff
changeset
|
99 and set -q __local_has_fast_hg_bookmark |
404 | 100 set_color magenta |
101 printf '%s' (fast-hg-bookmark 2>/dev/null) | |
102 set_color normal | |
103 end | |
371 | 104 end |
105 | |
106 function git_prompt | |
404 | 107 if set -q __local_has_git |
108 if git root >/dev/null 2>&1 | |
109 set_color normal | |
110 printf ' on ' | |
111 set_color magenta | |
112 printf '%s' (git currentbranch ^/dev/null) | |
113 set_color green | |
114 git_prompt_status | |
115 set_color normal | |
116 end | |
371 | 117 end |
118 end | |
119 | |
120 function fish_prompt | |
121 set last_status $status | |
122 | |
123 echo | |
124 | |
125 # 'username@hostname: ' | |
126 set_color magenta | |
127 printf '%s' (whoami) | |
128 set_color normal | |
129 printf '@' | |
130 set_color yellow | |
131 printf '%s' (hostname|cut -d . -f 1) | |
132 set_color normal | |
133 printf ': ' | |
134 | |
135 set_color $fish_color_cwd | |
136 printf '%s' (prompt_pwd) | |
137 set_color normal | |
138 | |
139 printf ' ' | |
140 prompt_char | |
141 printf ' ' | |
142 | |
143 hg_prompt | |
144 | |
145 echo | |
146 | |
147 virtualenv_prompt | |
148 | |
149 if test $last_status -eq 0 | |
150 set_color white -o | |
151 printf '> ' | |
152 else | |
153 set_color red -o | |
154 printf '[%d] > ' $last_status | |
155 end | |
156 | |
157 set_color normal | |
158 end | |
159 | |
160 # }}} | |
161 | |
425
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
162 # FZF {{{ |
371 | 163 |
425
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
164 if type -q fzf |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
165 function _gen_fzf_default_opts |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
166 set -l base03 "234" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
167 set -l base02 "235" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
168 set -l base01 "240" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
169 set -l base00 "241" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
170 set -l base0 "244" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
171 set -l base1 "245" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
172 set -l base2 "254" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
173 set -l base3 "230" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
174 set -l yellow "136" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
175 set -l orange "166" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
176 set -l red "160" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
177 set -l magenta "125" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
178 set -l violet "61" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
179 set -l blue "33" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
180 set -l cyan "37" |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
181 set -l green "64" |
371 | 182 |
425
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
183 # Solarized Dark color scheme for fzf |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
184 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
|
185 # Solarized Light 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+:$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
|
187 end |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
188 |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
189 _gen_fzf_default_opts |
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 if type -q ag |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
192 # Use Ag for searching. |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
193 set -x FZF_DEFAULT_COMMAND 'ag --nocolor -g ""' |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
194 end |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
195 |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
196 # Use the default command for searching in Fisherman's FZF plugin. |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
197 set -x FZF_FIND_FILE_COMMAND $FZF_DEFAULT_COMMAND |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
198 set -U FZF_LEGACY_KEYBINDINGS 0 |
350f7a55ff33
Improve fish configuration.
Ludovic Chabant <ludovic@chabant.com>
parents:
422
diff
changeset
|
199 end |
371 | 200 |
201 # }}} | |
202 | |
203 # Local Settings {{{ | |
204 | |
205 if test -s $HOME/.config/fish/local.fish | |
206 . $HOME/.config/fish/local.fish | |
207 end | |
407
c6da0c9f40ae
Replace subrepos with an install script. Finally.
Ludovic Chabant <ludovic@chabant.com>
parents:
405
diff
changeset
|
208 #eval (/usr/local/bin/python -m virtualfish) |
371 | 209 |
210 # }}} | |
211 |