├── Contributing.md
├── License.md
├── ReadMe.md
├── functions
├── _confirmation.fish
├── _ifnotset.fish
├── _logo.fish
└── _prepend_path.fish
├── modules
├── virtualfish
│ ├── environment.fish
│ ├── virtual.fish
│ └── virtualprojects.fish
├── virtualhooks
│ ├── ReadMe.md
│ └── virtualhooks.fish
└── z
│ └── z.fish
├── plugins
├── docker
│ ├── dps.fish
│ ├── dpsa.fish
│ ├── dra.fish
│ ├── dre.fish
│ ├── dria.fish
│ ├── drui.fish
│ └── dsa.fish
├── extract
│ ├── ReadMe.md
│ ├── compress.fish
│ └── extract.fish
├── grc
│ ├── _colorize.fish
│ ├── configure.fish
│ ├── df.fish
│ ├── diff.fish
│ ├── dig.fish
│ ├── gcc.fish
│ ├── make.fish
│ ├── netstat.fish
│ ├── ping.fish
│ └── ps.fish
├── hg
│ └── hgc.fish
├── pip
│ ├── completions
│ │ └── pip.fish
│ └── gpip.fish
├── python
│ ├── _python.fish
│ ├── pyclean.fish
│ └── pyhttp.fish
├── sdl
│ └── sdl.fish
└── up
│ ├── ReadMe.md
│ └── up.fish
└── themes
├── budspencer
├── README.md
├── fish_greeting.fish
├── fish_prompt.fish
└── fish_right_prompt.fish
├── entropy
├── ReadMe.md
├── fish_prompt.fish
└── fish_title.fish
└── urdh
├── ReadMe.md
├── fish_greeting.fish
├── fish_prompt.fish
├── fish_right_prompt.fish
└── fish_title.fish
/Contributing.md:
--------------------------------------------------------------------------------
1 | # Contributing to Tackle
2 |
3 | Contributions to Tackle and [Tacklebox][] are welcomed and encouraged. When
4 | considering submitting a pull request, please adhere to the following guidelines.
5 |
6 | ## Code standards
7 |
8 | Consistency throughout the project makes it easier for everyone. When making changes, please…
9 |
10 | * use 4-space indents (no tabs)
11 | * use `-d` to include descriptions for all function declarations
12 | * include a `ReadMe.md` *if* purpose/usage can't be explained in a single sentence
13 |
14 | ## Git and GitHub
15 |
16 | * Create a new git feature branch specific to your change (as opposed to making
17 | your commits in the master branch).
18 | * **Don't put multiple unrelated fixes/features in the same branch / pull request.**
19 | For example, if while working on a new feature you find and fix a bug on which
20 | your new feature does not directly depend, **make a new distinct branch and
21 | pull request** for the bugfix.
22 | * Check for unnecessary whitespace via `git diff --check` before committing.
23 | * First line of your commit message should start with present-tense verb, be 50
24 | characters or less, and include the relevant issue number(s) if applicable.
25 | *Example:* `Add .xz support to extract plugin. Refs #982.` If the commit
26 | *completely fixes* an existing bug report, please use ``Fixes #982`` or ``Fix
27 | #982`` syntax (so the relevant issue is automatically closed upon PR merge).
28 | * After the first line of the commit message, add a blank line and then a more
29 | detailed explanation.
30 | * Squash your commits to eliminate merge commits and ensure a clean and
31 | readable commit history.
32 |
33 | [Tacklebox]: https://github.com/justinmayer/tacklebox
34 |
--------------------------------------------------------------------------------
/License.md:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) Justin Mayer and contributors
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/ReadMe.md:
--------------------------------------------------------------------------------
1 | # Tackle
2 |
3 | Tackle is a repository of [Fish shell][] functions, modules, plugins, and themes designed to be used with the [Tacklebox][] framework.
4 |
5 | Visit the [Tacklebox][] project for information on installation, usage, and other useful documentation.
6 |
7 | ### Modules
8 |
9 | - **virtualfish** — [Virtualfish][] facilitates [Virtualenv][] management and matches projects to virtual environments
10 | - **virtualhooks** — sources `$VIRTUAL_ENV/virtualhooks.fish` upon virtual environment activation (requires Virtualfish)
11 | - **z** - jump to often-used directories, weighted by “frecency”
12 |
13 | ### Plugins
14 |
15 | - **docker** — provides useful commands to manage [Docker][] containers and images
16 | - **extract** — extracts a variety of archive file formats; `compress` function also included
17 | - **grc** — colorizes terminal output of ping, make, and other commands (must first install [grc][] via Homebrew/apt)
18 | - **hg** — facilitates interactions with [Mercurial][] repositories
19 | - **pip** – [Pip][] command completions and handy wrapper functions
20 | - **python** — functions to run simple HTTP server and clean `.pyc` files
21 | - **sdl** — sudo the last command in history
22 | - **up** — update Fish completions, Homebrew, Python packages, and Vim plugins (via Vundle)
23 |
24 | ### Themes
25 |
26 | - [entropy][] — shows Virtualenv, Git, and Mercurial status; indicates if connected to another host via SSH
27 | - [budspencer][]
28 | - [urdh][]
29 |
30 | ### Functions
31 |
32 | These are helper functions, mainly to be used inside of configuration and other functions:
33 |
34 | - **_confirmation** — confirmation prompt for use in interactive scripts
35 | - **_logo** — prints a colorful Fish shell logo as ASCII art
36 | - **_prepend_path** — prepend the given path, if it exists, to the specified path list
37 |
38 |
39 | ## Contributing
40 |
41 | Contributions to both Tackle and [Tacklebox][] are welcome. If you would like to contribute to the project, please review the [Contributing Guidelines][] thoroughly.
42 |
43 | [contributing guidelines]: https://github.com/justinmayer/tackle/blob/master/Contributing.md
44 | [docker]: http://www.docker.com/
45 | [fish shell]: http://fishshell.com/
46 | [grc]: http://korpus.juls.savba.sk/~garabik/software/grc.html
47 | [Mercurial]: http://mercurial.selenic.com/
48 | [pip]: http://pip.readthedocs.org/
49 | [Tacklebox]: https://github.com/justinmayer/tacklebox
50 | [virtualenv]: http://virtualenv.readthedocs.org/
51 | [Virtualfish]: https://github.com/adambrenecki/virtualfish
52 | [entropy]: https://github.com/justinmayer/tackle/tree/master/themes/entropy
53 | [budspencer]: https://github.com/justinmayer/tackle/tree/master/themes/budspencer
54 | [urdh]: https://github.com/justinmayer/tackle/tree/master/themes/urdh
55 |
56 |
--------------------------------------------------------------------------------
/functions/_confirmation.fish:
--------------------------------------------------------------------------------
1 | function _confirm_prompt
2 | echo 'Are you sure you want to continue? [y/N] '
3 | end
4 |
5 | function _confirmation
6 | while true
7 | read -l -p _confirm_prompt confirm
8 |
9 | switch $confirm
10 | case Y y
11 | return 0
12 | case '' N n
13 | return 1
14 | end
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/functions/_ifnotset.fish:
--------------------------------------------------------------------------------
1 | function _ifnotset -d "To save a few cycles, only set variables if not already set"
2 | if not set -q $argv[1]
3 | set -g $argv[1] $argv[2]
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/functions/_logo.fish:
--------------------------------------------------------------------------------
1 | function _logo
2 | echo ' '(set_color F00)'___
3 | ___======____='(set_color FF7F00)'-'(set_color FF0)'-'(set_color FF7F00)'-='(set_color F00)')
4 | /T \_'(set_color FF0)'--='(set_color FF7F00)'=='(set_color F00)')
5 | [ \ '(set_color FF7F00)'('(set_color FF0)'0'(set_color FF7F00)') '(set_color F00)'\~ \_'(set_color FF0)'-='(set_color FF7F00)'='(set_color F00)')
6 | \ / )J'(set_color FF7F00)'~~ \\'(set_color FF0)'-='(set_color F00)')
7 | \\\\___/ )JJ'(set_color FF7F00)'~'(set_color FF0)'~~ '(set_color F00)'\)
8 | \_____/JJJ'(set_color FF7F00)'~~'(set_color FF0)'~~ '(set_color F00)'\\
9 | '(set_color FF7F00)'/ '(set_color FF0)'\ '(set_color FF0)', \\'(set_color F00)'J'(set_color FF7F00)'~~~'(set_color FF0)'~~ '(set_color FF7F00)'\\
10 | (-'(set_color FF0)'\)'(set_color F00)'\='(set_color FF7F00)'|'(set_color FF0)'\\\\\\'(set_color FF7F00)'~~'(set_color FF0)'~~ '(set_color FF7F00)'L_'(set_color FF0)'_
11 | '(set_color FF7F00)'('(set_color F00)'\\'(set_color FF7F00)'\\) ('(set_color FF0)'\\'(set_color FF7F00)'\\\)'(set_color F00)'_ '(set_color FF0)'\=='(set_color FF7F00)'__
12 | '(set_color F00)'\V '(set_color FF7F00)'\\\\'(set_color F00)'\) =='(set_color FF7F00)'=_____ '(set_color FF0)'\\\\\\\\'(set_color FF7F00)'\\\\
13 | '(set_color F00)'\V) \_) '(set_color FF7F00)'\\\\'(set_color FF0)'\\\\JJ\\'(set_color FF7F00)'J\)
14 | '(set_color F00)'/'(set_color FF7F00)'J'(set_color FF0)'\\'(set_color FF7F00)'J'(set_color F00)'T\\'(set_color FF7F00)'JJJ'(set_color F00)'J)
15 | (J'(set_color FF7F00)'JJ'(set_color F00)'| \UUU)
16 | (UU)'(set_color normal)
17 | end
18 |
--------------------------------------------------------------------------------
/functions/_prepend_path.fish:
--------------------------------------------------------------------------------
1 | function _prepend_path -d "Prepend the given path, if it exists, to the specified
2 | path list. If no list specified, defaults to $PATH" --no-scope-shadowing
3 | set -l path "$argv[1]"
4 | set -l list PATH
5 | if set -q argv[2]
6 | set list $argv[2]
7 | end
8 |
9 | if test -d $path
10 | # If the path is already in the list, remove it first.
11 | # Prepending puts it in front, where it belongs.
12 | if set -l idx (contains -i -- $path $$list)
13 | set -e -- {$list}[$idx]
14 | end
15 | set -- $list $path $$list
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/modules/virtualfish/environment.fish:
--------------------------------------------------------------------------------
1 | # Set up the configurable filename
2 | if not set -q VIRTUALFISH_ENVIRONMENT_FILE
3 | set -g VIRTUALFISH_ENVIRONMENT_FILE .env
4 | end
5 |
6 | function __vfsupport_set_env_file_path --description "Set VIRTUALFISH_ENVIRONMENT_FILE_PATH to appropriate value"
7 | set -l vf_path $VIRTUAL_ENV/$VIRTUALFISH_ENVIRONMENT_FILE
8 | # Check if Projects plugin is used
9 | if not set -q PROJECT_HOME
10 | # Always look in the virtualenv dir when not using Projects plugin
11 | echo $vf_path
12 | else
13 | set -l project_path $PROJECT_HOME/(basename $VIRTUAL_ENV)/$VIRTUALFISH_ENVIRONMENT_FILE
14 | if not test -r $project_path
15 | and test -r $vf_path
16 | # Only use virtualenv dir when there is already a file there
17 | echo $vf_path
18 | else
19 | # Prefer to use the project dir
20 | echo $project_path
21 | end
22 | end
23 | end
24 |
25 | function __vfext_environment_activate --on-event virtualenv_did_activate
26 | set -l env_file_path (__vfsupport_set_env_file_path)
27 |
28 | if test -r $env_file_path
29 | while read -l line
30 | # Skip empty lines and comments
31 | if not string length -q $line
32 | or test (string sub -s 1 -l 1 $line) = "#"
33 | continue
34 | end
35 |
36 | set key (echo $line | cut -d = -f 1)
37 | set value (echo $line | cut -d = -f 2-)
38 |
39 | # Preserve existing env var with shared name
40 | if set -q $key
41 | set -gx __VF_ENVIRONMENT_OLD_VALUE_$key $$key
42 | end
43 |
44 | # Eval to allow for expanding variables, e.g. PATH=$PATH foo
45 | set -gx $key (eval echo $value)
46 | end < $env_file_path
47 | end
48 | end
49 |
50 | function __vfext_environment_deactivate --on-event virtualenv_will_deactivate
51 | set -l env_file_path (__vfsupport_set_env_file_path)
52 |
53 | if test -r $env_file_path
54 | while read -l line
55 | # Skip empty lines and comments
56 | if not string length -q $line
57 | or test (string sub -s 1 -l 1 $line) = "#"
58 | continue
59 | end
60 |
61 | set key (echo $line | cut -d = -f 1)
62 | set old_key __VF_ENVIRONMENT_OLD_VALUE_$key
63 |
64 | # Check if old value was preserved
65 | if set -q $old_key
66 | set -gx $key $$old_key
67 | set -e $old_key
68 | else
69 | set -e $key
70 | end
71 | end < $env_file_path
72 | end
73 | end
74 |
75 | function __vf_environment --description "Edit the environment variables for the active virtual environment"
76 | # Requires active virtualenv
77 | if not set -q VIRTUAL_ENV
78 | echo "Must have a virtual env active to run command"
79 | return 1
80 | end
81 |
82 | # Check if $VISUAL or $EDITOR is set, otherwise use vi (Git default)
83 | if set -q VISUAL
84 | set editor $VISUAL
85 | else if set -q EDITOR
86 | set editor $EDITOR
87 | else
88 | set editor vi
89 | end
90 |
91 | set -l env_file_path (__vfsupport_set_env_file_path)
92 | # Deactivate before applying new env vars to avoid stomping stashed values
93 | __vfext_environment_deactivate
94 | eval $editor $env_file_path
95 | __vfext_environment_activate
96 | end
97 |
--------------------------------------------------------------------------------
/modules/virtualfish/virtual.fish:
--------------------------------------------------------------------------------
1 | # VirtualFish
2 | # A Virtualenv wrapper for the Fish Shell based on Doug Hellman's virtualenvwrapper
3 |
4 | if not set -q VIRTUALFISH_HOME
5 | set -g VIRTUALFISH_HOME $HOME/.virtualenvs
6 | end
7 |
8 | if set -q VIRTUALFISH_COMPAT_ALIASES
9 | function workon
10 | if not set -q argv[1]
11 | vf ls
12 | else
13 | vf activate $argv[1]
14 | end
15 | end
16 | function deactivate
17 | vf deactivate
18 | end
19 | function mktmpenv
20 | vf tmp $argv
21 | end
22 | function mkvirtualenv
23 | # Check if the first argument is an option to virtualenv
24 | # if it is then the the last argument must be the DEST_DIR.
25 | set -l idx 1
26 | switch $argv[1]
27 | case '-*'
28 | set idx -1
29 | end
30 |
31 | # Extract the DEST_DIR and remove it from $argv
32 | set -l env_name $argv[$idx]
33 | set -e argv[$idx]
34 |
35 | vf new $argv $env_name
36 | end
37 | function rmvirtualenv
38 | vf rm $argv
39 | end
40 | function add2virtualenv
41 | __vf_addpath $argv
42 | end
43 | function cdvirtualenv
44 | vf cd $argv
45 | end
46 | function cdsitepackages
47 | vf cdpackages $argv
48 | end
49 | end
50 |
51 | function vf --description "VirtualFish: fish plugin to manage virtualenvs"
52 | # copy all but the first argument to $scargs
53 | set -l sc $argv[1]
54 | set -l funcname "__vf_$sc"
55 | set -l scargs
56 |
57 | if begin; [ (count $argv) -eq 0 ]; or [ $sc = "--help" ]; or [ $sc = "-h" ]; end
58 | # If called without arguments, print usage
59 | vf help
60 | return
61 | end
62 |
63 | if test (count $argv) -gt 1
64 | set scargs $argv[2..-1]
65 | end
66 |
67 | if functions -q $funcname
68 | eval $funcname $scargs
69 | else
70 | echo "The subcommand $sc is not defined"
71 | end
72 | end
73 |
74 | function __vf_activate --description "Activate a virtualenv"
75 | # check arguments
76 | if [ (count $argv) -lt 1 ]
77 | echo "You need to specify a virtualenv."
78 | return 1
79 | end
80 | if not [ -d $VIRTUALFISH_HOME/$argv[1] ]
81 | echo "The virtualenv $argv[1] does not exist."
82 | echo "You can create it with mkvirtualenv."
83 | return 2
84 | end
85 |
86 | #Check if a different env is being used
87 | if set -q VIRTUAL_ENV
88 | vf deactivate
89 | end
90 |
91 | # Set VIRTUAL_ENV before the others so that the will_activate event knows
92 | # which virtualenv is about to be activated
93 | set -gx VIRTUAL_ENV $VIRTUALFISH_HOME/$argv[1]
94 |
95 | emit virtualenv_will_activate
96 | emit virtualenv_will_activate:$argv[1]
97 |
98 | set -g _VF_EXTRA_PATH $VIRTUAL_ENV/bin
99 | set -gx PATH $_VF_EXTRA_PATH $PATH
100 |
101 | # hide PYTHONHOME
102 | if set -q PYTHONHOME
103 | set -g _VF_OLD_PYTHONHOME $PYTHONHOME
104 | set -e PYTHONHOME
105 | end
106 |
107 | emit virtualenv_did_activate
108 | emit virtualenv_did_activate:(basename $VIRTUAL_ENV)
109 | end
110 |
111 | function __vf_deactivate --description "Deactivate the currently-activated virtualenv"
112 | # check for active virtualenv
113 | if not set -q VIRTUAL_ENV
114 | echo "There is no active virtualenv to deactivate."
115 | return 1
116 | end
117 |
118 | emit virtualenv_will_deactivate
119 | emit virtualenv_will_deactivate:(basename $VIRTUAL_ENV)
120 |
121 | # find elements to remove from PATH
122 | set to_remove
123 | for i in (seq (count $PATH))
124 | if contains $PATH[$i] $_VF_EXTRA_PATH
125 | set to_remove $to_remove $i
126 | end
127 | end
128 |
129 | # remove them
130 | for i in $to_remove
131 | set -e PATH[$i]
132 | end
133 |
134 | # restore PYTHONHOME
135 | if set -q _VF_OLD_PYTHONHOME
136 | set -gx PYTHONHOME $_VF_OLD_PYTHONHOME
137 | set -e _VF_OLD_PYTHONHOME
138 | end
139 |
140 | emit virtualenv_did_deactivate
141 | emit virtualenv_did_deactivate:(basename $VIRTUAL_ENV)
142 |
143 | set -e VIRTUAL_ENV
144 | end
145 |
146 | function __vf_new --description "Create a new virtualenv"
147 | emit virtualenv_will_create
148 | set envname $argv[-1]
149 | set -e argv[-1]
150 | virtualenv $argv $VIRTUALFISH_HOME/$envname
151 | set vestatus $status
152 | if begin; [ $vestatus -eq 0 ]; and [ -d $VIRTUALFISH_HOME/$envname ]; end
153 | vf activate $envname
154 | emit virtualenv_did_create
155 | emit virtualenv_did_create:(basename $VIRTUAL_ENV)
156 | else
157 | echo "Error: The virtualenv wasn't created properly."
158 | echo "virtualenv returned status $vestatus."
159 | return 1
160 | end
161 | end
162 |
163 | function __vf_rm --description "Delete a virtualenv"
164 | if not [ (count $argv) -eq 1 ]
165 | echo "You need to specify exactly one virtualenv."
166 | return 1
167 | end
168 | if begin; set -q VIRTUAL_ENV; and [ $argv[1] = (basename $VIRTUAL_ENV) ]; end
169 | echo "You can't delete a virtualenv you're currently using."
170 | return 1
171 | end
172 | echo "Removing $VIRTUALFISH_HOME/$argv[1]"
173 | rm -rf $VIRTUALFISH_HOME/$argv[1]
174 | end
175 |
176 | function __vf_ls --description "List all of the available virtualenvs"
177 | pushd $VIRTUALFISH_HOME
178 | for i in */bin/python
179 | echo $i
180 | end | sed "s|/bin/python||"
181 | popd
182 | end
183 |
184 | function __vf_cd --description "Change directory to currently-activated virtualenv"
185 | if set -q VIRTUAL_ENV
186 | cd $VIRTUAL_ENV
187 | else
188 | echo "Cannot locate an active virtualenv."
189 | end
190 | end
191 |
192 | function __vf_cdpackages --description "Change to the site-packages directory of the active virtualenv"
193 | vf cd
194 | cd lib/python*/site-packages
195 | end
196 |
197 | function __vf_tmp --description "Create a temporary virtualenv that will be removed when deactivated"
198 | set -l env_name (printf "%s%.4x" "tempenv-" (random) (random) (random))
199 | set -g VF_TEMPORARY_ENV
200 |
201 | # Use will_deactivate here so that $VIRTUAL_ENV is available.
202 | function __vf_tmp_remove --on-event virtualenv_will_deactivate:$env_name
203 | echo "Removing $VIRTUAL_ENV"
204 | rm -rf $VIRTUAL_ENV
205 | set -e VF_TEMPORARY_ENV
206 | end
207 |
208 | # Ensure that the virtualenv gets deleted even if we close the shell w/o
209 | # explicitly deactivating.
210 | function __vfsupport_remove_temp_env_on_exit --on-process %self
211 | if set -q VF_TEMPORARY_ENV
212 | vf deactivate # the deactivate handler will take care of removing it
213 | end
214 | end
215 |
216 | vf new $argv $env_name
217 | end
218 |
219 | function __vf_addpath --description "Adds a path to sys.path in this virtualenv"
220 | if set -q VIRTUAL_ENV
221 | set -l site_packages (eval "$VIRTUAL_ENV/bin/python -c 'import distutils; print(distutils.sysconfig.get_python_lib())'")
222 | set -l path_file $site_packages/_virtualenv_path_extensions.pth
223 |
224 | set -l remove 0
225 | if test $argv[1] = "-d"
226 | set remove 1
227 | set -e argv[1]
228 | end
229 |
230 | if not test -f $path_file
231 | echo "import sys; sys.__plen = len(sys.path)" > $path_file
232 | echo "import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)" >> $path_file
233 | end
234 |
235 | for pydir in $argv
236 | set -l absolute_path (eval "$VIRTUAL_ENV/bin/python -c 'import os,sys; sys.stdout.write(os.path.abspath(\"$pydir\")+\"\n\")'")
237 | if not test $pydir = $absolute_path
238 | echo "Warning: Converting \"$pydir\" to \"$absolute_path\"" 1>&2
239 | end
240 |
241 | if test $remove -eq 1
242 | sed -i.tmp "\:^$absolute_path\$: d" "$path_file"
243 | else
244 | sed -i.tmp '1 a\
245 | '"$absolute_path"'
246 | ' "$path_file"
247 | end
248 | rm -f "$path_file.tmp"
249 | end
250 | return 0
251 | else
252 | echo "No virtualenv is active."
253 | end
254 | end
255 |
256 | function __vf_all --description "Run a command in all virtualenvs sequentially"
257 | if test (count $argv) -lt 1
258 | echo "You need to supply a command."
259 | return 1
260 | end
261 |
262 | if set -q VIRTUAL_ENV
263 | set -l old_env (basename $VIRTUAL_ENV)
264 | end
265 |
266 | for env in (vf ls)
267 | vf activate $env
268 | eval $argv
269 | end
270 |
271 | if set -q old_env
272 | vf activate $old_env
273 | else
274 | vf deactivate
275 | end
276 | end
277 |
278 | # 'vf connect' command
279 | # Used by the project management and auto-activation plugins
280 |
281 | if not set -q VIRTUALFISH_ACTIVATION_FILE
282 | set -g VIRTUALFISH_ACTIVATION_FILE .venv
283 | end
284 |
285 |
286 | function __vf_connect --description "Connect this virtualenv to the current directory"
287 | if set -q VIRTUAL_ENV
288 | basename $VIRTUAL_ENV > $VIRTUALFISH_ACTIVATION_FILE
289 | else
290 | echo "No virtualenv is active."
291 | end
292 | end
293 |
294 | function __vf_help --description "Print VirtualFish usage information"
295 | echo "Usage: vf []"
296 | echo
297 | echo "Available commands:"
298 | echo
299 | for sc in (functions -a | sed -n '/__vf_/{s///g;p;}')
300 | set -l helptext (functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|")
301 | printf " %-15s %s\n" $sc (set_color 555)$helptext(set_color normal)
302 | end
303 | echo
304 | echo "For full documentation, see: http://virtualfish.readthedocs.org/en/latest/"
305 | end
306 |
307 | ################
308 | # Autocomplete
309 | # Based on https://github.com/zmalltalker/fish-nuggets/blob/master/completions/git.fish
310 | begin
311 | function __vfcompletion_needs_command
312 | set cmd (commandline -opc)
313 | if test (count $cmd) -eq 1 -a $cmd[1] = 'vf'
314 | return 0
315 | end
316 | return 1
317 | end
318 |
319 | function __vfcompletion_using_command
320 | set cmd (commandline -opc)
321 | if test (count $cmd) -gt 1
322 | if test $argv[1] = $cmd[2]
323 | return 0
324 | end
325 | end
326 | return 1
327 | end
328 |
329 | # add completion for subcommands
330 | for sc in (functions -a | sed -n '/__vf_/{s///g;p;}')
331 | set -l helptext (functions "__vf_$sc" | head -n 1 | sed -E "s|.*'(.*)'.*|\1|")
332 | complete -x -c vf -n '__vfcompletion_needs_command' -a $sc -d $helptext
333 | end
334 |
335 | complete -x -c vf -n '__vfcompletion_using_command activate' -a "(vf ls)"
336 | complete -x -c vf -n '__vfcompletion_using_command rm' -a "(vf ls)"
337 | if set -q VIRTUALFISH_COMPAT_ALIASES
338 | complete -x -c workon -a "(vf ls)"
339 | complete -x -c rmvirtualenv -a "(vf ls)"
340 | end
341 | end
342 |
343 |
--------------------------------------------------------------------------------
/modules/virtualfish/virtualprojects.fish:
--------------------------------------------------------------------------------
1 | if not set -q PROJECT_HOME
2 | set -g PROJECT_HOME $HOME/projects
3 | end
4 |
5 | if not set -q VIRTUALFISH_ACTIVATION_FILE
6 | set -g VIRTUALFISH_ACTIVATION_FILE .venv
7 | end
8 |
9 | function __vf_workon --description "Work on a project"
10 | if [ (count $argv) -lt 1 ]
11 | echo "You must specify a project or virtual environment."
12 | return 1
13 | end
14 | # Matches a virtualenv name and possibly a project name
15 | if [ -d $VIRTUALFISH_HOME/$argv[1] ]
16 | vf activate $argv[1]
17 | if [ -d $PROJECT_HOME/$argv[1] ]
18 | cd $PROJECT_HOME/$argv[1]
19 | end
20 | # Matches a project name but not a virtualenv name
21 | else if [ -d $PROJECT_HOME/$argv[1] ]
22 | set -l project_name $argv[1]
23 | set -l venv_file "$PROJECT_HOME/$project_name/$VIRTUALFISH_ACTIVATION_FILE"
24 | if [ -f $venv_file ]
25 | vf activate (cat $venv_file)
26 | else
27 | echo "No virtual environment found."
28 | end
29 | cd $PROJECT_HOME/$argv[1]
30 | else
31 | echo "No project or virtual environment named $argv[1] exists."
32 | return 2
33 | end
34 | end
35 |
36 | function __vf_project --description "Create a new project and virtualenv with the name provided"
37 | set -l project_name $argv[-1]
38 | set -l project_path "$PROJECT_HOME/$project_name"
39 | if [ -d $project_path ]
40 | echo "A project with that name already exists at: $project_path"
41 | return 2
42 | else
43 | vf new $argv
44 | mkdir -p $project_path
45 | cd $project_path
46 | end
47 | end
48 |
49 | function __vf_lsprojects --description "List projects"
50 | if [ -d $PROJECT_HOME ]
51 | pushd $PROJECT_HOME
52 | for i in *
53 | if [ -d $i ]
54 | echo $i
55 | end
56 | end
57 | popd
58 | else
59 | echo "PROJECT_HOME environment variable is set to non-existent directory: $PROJECT_HOME"
60 | return 2
61 | end
62 | end
63 |
64 | if set -q VIRTUALFISH_COMPAT_ALIASES
65 | function mkproject
66 | vf project $argv
67 | end
68 | function workon
69 | if not set -q argv[1]
70 | set_color blue; echo "Projects:"; set_color normal
71 | vf lsprojects
72 | set_color blue; echo -e "\nVirtual environments:"; set_color normal
73 | vf ls
74 | else
75 | vf workon $argv[1]
76 | end
77 | end
78 |
79 | complete -x -c workon -a "(ls $PROJECT_HOME)"
80 | end
81 |
82 | complete -x -c vf -n '__vfcompletion_using_command workon' -a "(ls $PROJECT_HOME)"
83 |
--------------------------------------------------------------------------------
/modules/virtualhooks/ReadMe.md:
--------------------------------------------------------------------------------
1 | # Virtualhooks
2 |
3 | ### Problem
4 |
5 | Remembering to set (and later unset) environment variables is hard. Even when you remember, manually setting and unsetting environment variables is a chore.
6 |
7 | ### Solution
8 |
9 | Virtualhooks will set your desired environment variables upon [virtualenv][] activation, as well as unset those variables upon deactivation.
10 |
11 | This can be particularly useful for database passwords, API keys, and other secrets you might prefer to keep out of your source code repository.
12 |
13 | ## Usage
14 |
15 | Enable this module and create a `virtualhooks.fish` file inside each virtual environment that you want to use with Virtualhooks. While the intended goal is to set environment variables, any [fish][] code contained inside `$VIRTUAL_ENV/virtualhooks.fish` will be sourced upon `virtualenv` activation.
16 |
17 | Following is an example `virtualhooks.fish` file that defines a few environment variables that will be set/unset upon `virtualenv` activation/deactivation.
18 |
19 | set -gx HTTP_HOST "justinmayer.com"
20 | set -gx PG_PASSWORD "foo"
21 | set -gx DEPLOYMENT_API_KEY "test-ka8pv3ygn5ozp7qkf"
22 |
23 | function __virtualteardown --on-event virtualenv_will_deactivate
24 | set -e HTTP_HOST
25 | set -e DB_PASSWORD
26 | set -e DEPLOYMENT_API_KEY
27 | end
28 |
29 |
30 | [fish]: http://fishshell.com/
31 | [virtualenv]: http://virtualenv.readthedocs.org/
32 |
--------------------------------------------------------------------------------
/modules/virtualhooks/virtualhooks.fish:
--------------------------------------------------------------------------------
1 | # Virtualhooks: https://github.com/justinmayer/tackle/tree/master/modules/virtualhooks
2 | function virtualhooks --on-event virtualenv_did_activate
3 | if test -f "$VIRTUAL_ENV/virtualhooks.fish"
4 | echo "Sourcing $VIRTUAL_ENV/virtualhooks.fish"
5 | source "$VIRTUAL_ENV/virtualhooks.fish"
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/modules/z/z.fish:
--------------------------------------------------------------------------------
1 | # This maintains a jump-list of the directories you actually use.
2 | #
3 | # First, cd around for a while to build up the database of directories.
4 | #
5 | # USAGE:
6 | # * z foo # goes to most frecent dir matching foo
7 | # * z foo bar # goes to most frecent dir matching foo and bar
8 | # * z -r foo # goes to highest ranked dir matching foo
9 | # * z -t foo # goes to most recently accessed dir matching foo
10 | # * z -l foo # list all dirs matching foo (by frecency)
11 | #
12 | # Originally from: https://github.com/sjl/z-fish
13 |
14 | function addzhist --on-variable PWD
15 | z --add "$PWD"
16 | end
17 |
18 | function z -d "Jump to a recent directory"
19 | set -l datafile "$HOME/.z"
20 |
21 | # add entries
22 | if [ "$argv[1]" = "--add" ]
23 | set -e argv[1]
24 |
25 | # $HOME isn't worth matching
26 | [ "$argv" = "$HOME" ]; and return
27 |
28 | set -l tempfile (mktemp $datafile.XXXXXX)
29 | test -f $tempfile; or return
30 |
31 | # maintain the file
32 | awk -v path="$argv" -v now=(date +%s) -F"|" '
33 | BEGIN {
34 | rank[path] = 1
35 | time[path] = now
36 | }
37 | $2 >= 1 {
38 | if( $1 == path ) {
39 | rank[$1] = $2 + 1
40 | time[$1] = now
41 | } else {
42 | rank[$1] = $2
43 | time[$1] = $3
44 | }
45 | count += $2
46 | }
47 | END {
48 | if( count > 1000 ) {
49 | for( i in rank ) print i "|" 0.9*rank[i] "|" time[i] # aging
50 | } else for( i in rank ) print i "|" rank[i] "|" time[i]
51 | }
52 | ' $datafile ^/dev/null > $tempfile
53 |
54 | mv -f $tempfile $datafile
55 |
56 | # tab completion
57 | else
58 | if [ "$argv[1]" = "--complete" ]
59 | awk -v q="$argv[2]" -F"|" '
60 | BEGIN {
61 | if( q == tolower(q) ) nocase = 1
62 | split(q,fnd," ")
63 | }
64 | {
65 | if( system("test -d \"" $1 "\"") ) next
66 | if( nocase ) {
67 | for( i in fnd ) tolower($1) !~ tolower(fnd[i]) && $1 = ""
68 | if( $1 ) print $1
69 | } else {
70 | for( i in fnd ) $1 !~ fnd[i] && $1 = ""
71 | if( $1 ) print $1
72 | }
73 | }
74 | ' "$datafile" 2>/dev/null
75 |
76 | else
77 | # list/go
78 | set -l last ''
79 | set -l list 0
80 | set -l typ ''
81 | set -l fnd ''
82 |
83 | while [ (count $argv) -gt 0 ]
84 | switch "$argv[1]"
85 | case -- '-h'
86 | echo "z [-h][-l][-r][-t] args" >&2
87 | return
88 | case -- '-l'
89 | set list 1
90 | case -- '-r'
91 | set typ "rank"
92 | case -- '-t'
93 | set typ "recent"
94 | case -- '--'
95 | while [ "$argv[1]" ]
96 | set -e argv[1]
97 | set fnd "$fnd $argv[1]"
98 | end
99 | case '*'
100 | set fnd "$fnd $argv[1]"
101 | end
102 | set last $1
103 | set -e argv[1]
104 | end
105 |
106 | [ "$fnd" ]; or set list 1
107 |
108 | # if we hit enter on a completion just go there
109 | [ -d "$last" ]; and cd "$last"; and return
110 |
111 | # no file yet
112 | [ -f "$datafile" ]; or return
113 |
114 | set -l tempfile (mktemp $datafile.XXXXXX)
115 | test -f $tempfile; or return
116 | set -l target (awk -v t=(date +%s) -v list="$list" -v typ="$typ" -v q="$fnd" -v tmpfl="$tempfile" -F"|" '
117 | function frecent(rank, time) {
118 | dx = t-time
119 | if( dx < 3600 ) return rank*4
120 | if( dx < 86400 ) return rank*2
121 | if( dx < 604800 ) return rank/2
122 | return rank/4
123 | }
124 | function output(files, toopen, override) {
125 | if( list ) {
126 | if( typ == "recent" ) {
127 | cmd = "sort -nr >&2"
128 | } else cmd = "sort -n >&2"
129 | for( i in files ) if( files[i] ) printf "%-10s %s\n", files[i], i | cmd
130 | if( override ) printf "%-10s %s\n", "common:", override > "/dev/stderr"
131 | } else {
132 | if( override ) toopen = override
133 | print toopen
134 | }
135 | }
136 | function common(matches, fnd, nc) {
137 | for( i in matches ) {
138 | if( matches[i] && (!short || length(i) < length(short)) ) short = i
139 | }
140 | if( short == "/" ) return
141 | for( i in matches ) if( matches[i] && i !~ short ) x = 1
142 | if( x ) return
143 | if( nc ) {
144 | for( i in fnd ) if( tolower(short) !~ tolower(fnd[i]) ) x = 1
145 | } else for( i in fnd ) if( short !~ fnd[i] ) x = 1
146 | if( !x ) return short
147 | }
148 | BEGIN { split(q, a, " ") }
149 | {
150 | if( system("test -d \"" $1 "\"") ) next
151 | print $0 >> tmpfl
152 | if( typ == "rank" ) {
153 | f = $2
154 | } else if( typ == "recent" ) {
155 | f = t-$3
156 | } else f = frecent($2, $3)
157 | wcase[$1] = nocase[$1] = f
158 | for( i in a ) {
159 | if( $1 !~ a[i] ) delete wcase[$1]
160 | if( tolower($1) !~ tolower(a[i]) ) delete nocase[$1]
161 | }
162 | if( wcase[$1] > oldf ) {
163 | cx = $1
164 | oldf = wcase[$1]
165 | } else if( nocase[$1] > noldf ) {
166 | ncx = $1
167 | noldf = nocase[$1]
168 | }
169 | }
170 | END {
171 | if( cx ) {
172 | output(wcase, cx, common(wcase, a, 0))
173 | } else if( ncx ) output(nocase, ncx, common(nocase, a, 1))
174 | }
175 | ' "$datafile")
176 |
177 | if [ $status -gt 0 ]
178 | rm -f "$tempfile"
179 | else
180 | mv -f "$tempfile" "$datafile"
181 | [ "$target" ]; and cd "$target"
182 | end
183 | end
184 | end
185 | end
186 |
--------------------------------------------------------------------------------
/plugins/docker/dps.fish:
--------------------------------------------------------------------------------
1 | function dps -d "Abbreviated list of running Docker containers"
2 | if which docker > /dev/null
3 | docker ps $argv | awk '
4 | NR==1{
5 | FIRSTLINEWIDTH=length($0)
6 | IDPOS=index($0,"CONTAINER ID");
7 | IMAGEPOS=index($0,"IMAGE");
8 | COMMANDPOS=index($0,"COMMAND");
9 | CREATEDPOS=index($0,"CREATED");
10 | STATUSPOS=index($0,"STATUS");
11 | PORTSPOS=index($0,"PORTS");
12 | NAMESPOS=index($0,"NAMES");
13 | UPDATECOL();
14 | }
15 | function UPDATECOL () {
16 | ID=substr($0,IDPOS,IMAGEPOS-IDPOS-1);
17 | IMAGE=substr($0,IMAGEPOS,COMMANDPOS-IMAGEPOS-1);
18 | COMMAND=substr($0,COMMANDPOS,CREATEDPOS-COMMANDPOS-1);
19 | CREATED=substr($0,CREATEDPOS,STATUSPOS-CREATEDPOS-1);
20 | STATUS=substr($0,STATUSPOS,PORTSPOS-STATUSPOS-1);
21 | PORTS=substr($0,PORTSPOS,NAMESPOS-PORTSPOS-1);
22 | NAMES=substr($0, NAMESPOS);
23 | }
24 | function PRINT () {
25 | print NAMES IMAGE STATUS CREATED COMMAND;
26 | }
27 | NR==2{
28 | NAMES=sprintf("%s%*s",NAMES,length($0)-FIRSTLINEWIDTH,"");
29 | PRINT();
30 | }
31 | NR>1{
32 | UPDATECOL();
33 | PRINT();
34 | }';
35 | else
36 | echo "Docker could not be found. Is it installed?"
37 | end
38 | end
39 |
--------------------------------------------------------------------------------
/plugins/docker/dpsa.fish:
--------------------------------------------------------------------------------
1 | function dpsa -d "Abbreviated list of all Docker containers"
2 | dps -a
3 | end
4 |
5 |
--------------------------------------------------------------------------------
/plugins/docker/dra.fish:
--------------------------------------------------------------------------------
1 | function dra -d "Remove all Docker containers"
2 | if _confirmation
3 | if which docker
4 | docker rm (docker ps -a -q)
5 | else
6 | echo "Docker could not be found. Is it installed?"
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/plugins/docker/dre.fish:
--------------------------------------------------------------------------------
1 | function dre -d "Remove all exited Docker containers"
2 | if _confirmation
3 | if which docker
4 | docker rm (docker ps -a | grep Exited | awk '{print $1}')
5 | else
6 | echo "Docker could not be found. Is it installed?"
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/plugins/docker/dria.fish:
--------------------------------------------------------------------------------
1 | function dria -d "Remove all Docker images"
2 | if _confirmation
3 | if which docker
4 | docker rmi (docker images -a -q)
5 | else
6 | echo "Docker could not be found. Is it installed?"
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/plugins/docker/drui.fish:
--------------------------------------------------------------------------------
1 | function drui -d "Remove all untagged Docker images"
2 | if _confirmation
3 | if which docker
4 | docker rmi (docker images -q --filter "dangling=true")
5 | else
6 | echo "Docker could not be found. Is it installed?"
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/plugins/docker/dsa.fish:
--------------------------------------------------------------------------------
1 | function dsa -d "Stop all Docker containers"
2 | if _confirmation
3 | if which docker
4 | docker stop (docker ps -q)
5 | else
6 | echo "Docker could not be found. Is it installed?"
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/plugins/extract/ReadMe.md:
--------------------------------------------------------------------------------
1 | # Extract and Compress
2 |
3 | ### Problem
4 |
5 | It's hard to remember which commands to use to extract the various compressed archive formats.
6 |
7 | ### Solution
8 |
9 | Use the `extract` command to extract `.xz`, `.bz2`, `.gz`, `.zip`, `.tar(.XXX)`, `.rar`, and `.pax` archives. For example:
10 |
11 | extract your-file.xz
12 |
13 | ### Bonus: Compress
14 |
15 | Similarly, the syntax for compressing files and directories is neither consistent nor particularly memorable.
16 |
17 | **Provided you have `xz` installed**, you can compress a single file or directory (as `*.xz` or `*.txz`, respectively) via the following simple command:
18 |
19 | compress your-file-or-directory
20 |
21 | The archive will be created in-place unless a destination is specified, as shown via this example:
22 |
23 | compress your-directory ~/your-new-archive.txz
24 |
25 | **Mac OS X users:** You should install GNU Tar via `brew install gnu-tar`, since the bundled version of `tar` is ancient and doesn’t support `xz`.
26 |
27 | ### Extra Bonus: Parallel Compression and Extraction
28 |
29 | If you have [pixz][] installed, both compression and extraction of `xz` archives will be processed in parallel on multi-core systems. This usually results in a dramatic increase in compression/extraction speed.
30 |
31 | To install `pixz` on Mac OS X via Homebrew:
32 |
33 | brew install pixz gnu-tar
34 |
35 | To install `pixz` on Debian/Ubuntu`:
36 |
37 | sudo aptitude install pixz
38 |
39 |
40 | [pixz]: https://github.com/vasi/pixz
41 |
--------------------------------------------------------------------------------
/plugins/extract/compress.fish:
--------------------------------------------------------------------------------
1 | function compress -d "Compress a file or directory via xz, with optional destination"
2 | # Target is a file
3 | if test -f $argv[1]
4 | set file $argv[1]
5 | # If no destination is provided, compress in-place
6 | if test (count $argv) = 1
7 | set destination $file.xz
8 | else
9 | set destination $argv[2]
10 | end
11 | echo -s "Compressing file: " (set_color --bold blue) $file (set_color normal)
12 | command -s pixz >/dev/null
13 | and pixz $file $destination
14 | or xz $file $destination
15 | end
16 |
17 | # Target is a directory
18 | if test -d $argv[1]
19 | set directory $argv[1]
20 | # If no destination is provided, compress in-place
21 | if test (count $argv) = 1
22 | set destination $directory.txz
23 | else
24 | set destination $argv[2]
25 | end
26 | echo -s "Compressing directory: " (set_color --bold blue) $directory (set_color normal)
27 | set os (uname)
28 | switch $os
29 | case Darwin
30 | command -s gtar pixz >/dev/null
31 | and gtar -Ipixz -cf $destination $directory
32 | or tar -Jcf $destination $directory
33 | case '*'
34 | command -s pixz >/dev/null
35 | and tar -Ipixz -cf $destination $directory
36 | or tar -Jcf $destination $directory
37 | end
38 | end
39 | end
40 |
--------------------------------------------------------------------------------
/plugins/extract/extract.fish:
--------------------------------------------------------------------------------
1 | # Inspiration from: https://github.com/dideler/dotfiles/blob/master/.config/fish/functions/extract.fish
2 | function extract -d "Expand or extract bundled & compressed files"
3 | for file in $argv
4 | if test -f $file
5 | echo -s "Extracting: " (set_color --bold blue) $file (set_color normal)
6 | switch $file
7 | case *.tar
8 | tar -xf $file
9 | case *.tar.xz *.txz
10 | # Use pixz for parallel extraction, if available
11 | set os (uname)
12 | if [ $os = "Darwin" ]
13 | command -s pixz gtar >/dev/null
14 | and gtar -Ipixz -xf $file
15 | or tar -Jxf $file
16 | else
17 | command -s pixz >/dev/null
18 | and tar -Ipixz -xf $file
19 | or tar -Jxf $file
20 | end
21 | case *.tar.bz2 *.tbz *.tbz2
22 | tar -jxf $file
23 | case *.tar.gz *.tgz
24 | tar -zxf $file
25 | case *.xz
26 | command -s pixz >/dev/null
27 | and pixz -d $file
28 | or unxz $file
29 | case *.bz2
30 | bunzip2 $file
31 | case *.gz
32 | gunzip $file
33 | case *.rar
34 | unrar x $file
35 | case *.zip
36 | unzip -uo $file -d (basename $file .zip)
37 | case *.pax
38 | pax -r < $file
39 | case '*'
40 | echo "Extension not recognized, cannot extract $file"
41 | end
42 | else
43 | echo "$file is not a valid file"
44 | end
45 | end
46 | end
47 |
--------------------------------------------------------------------------------
/plugins/grc/_colorize.fish:
--------------------------------------------------------------------------------
1 | function _colorize -d "Colorize command output via grc"
2 | # See: /usr/local/etc/grc.bashrc
3 | grc -es --colour=auto $argv
4 | end
5 |
--------------------------------------------------------------------------------
/plugins/grc/configure.fish:
--------------------------------------------------------------------------------
1 | function configure -d "Configure with colorized output"
2 | _colorize ./configure $argv
3 | end
4 |
--------------------------------------------------------------------------------
/plugins/grc/df.fish:
--------------------------------------------------------------------------------
1 | function df -d "df with colorized output"
2 | _colorize --config=conf.df df $argv
3 | end
4 |
--------------------------------------------------------------------------------
/plugins/grc/diff.fish:
--------------------------------------------------------------------------------
1 | function diff -d "diff with colorized output"
2 | _colorize diff $argv
3 | end
4 |
--------------------------------------------------------------------------------
/plugins/grc/dig.fish:
--------------------------------------------------------------------------------
1 | function dig -d "dig with colorized output"
2 | _colorize dig $argv
3 | end
4 |
--------------------------------------------------------------------------------
/plugins/grc/gcc.fish:
--------------------------------------------------------------------------------
1 | function gcc -d "gcc with colorized output"
2 | _colorize gcc $argv
3 | end
4 |
--------------------------------------------------------------------------------
/plugins/grc/make.fish:
--------------------------------------------------------------------------------
1 | function make -d "Make with colorized output"
2 | _colorize make $argv
3 | end
4 |
--------------------------------------------------------------------------------
/plugins/grc/netstat.fish:
--------------------------------------------------------------------------------
1 | function netstat -d "netstat with colorized output"
2 | _colorize netstat $argv
3 | end
4 |
--------------------------------------------------------------------------------
/plugins/grc/ping.fish:
--------------------------------------------------------------------------------
1 | function ping -d "Ping with colorized output"
2 | _colorize ping $argv
3 | end
4 |
--------------------------------------------------------------------------------
/plugins/grc/ps.fish:
--------------------------------------------------------------------------------
1 | function ps -d "ps with colorized output"
2 | _colorize ps $argv
3 | end
4 |
--------------------------------------------------------------------------------
/plugins/hg/hgc.fish:
--------------------------------------------------------------------------------
1 | function hgc -d "Commit via Mercurial, with sanity checks"
2 | if test -z (hg incoming | grep "no changes found")
3 | echo "Incoming commits found. Run 'hg pull -u' to retrieve."
4 | else
5 | hg commit
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/plugins/pip/completions/pip.fish:
--------------------------------------------------------------------------------
1 | function __completion_needs_command
2 | set cmd (commandline -opc)
3 | if [ (count $cmd) -eq 1 -a $cmd[1] = $argv[1] ]
4 | return 0
5 | end
6 | return 1
7 | end
8 |
9 | function __completion_using_command
10 | set cmd (commandline -opc)
11 | if [ (count $cmd) -gt 1 ]
12 | if [ $argv[1] = $cmd[2] ]
13 | return 0
14 | end
15 | end
16 | return 1
17 | end
18 |
19 |
20 | #keyword
21 | complete --no-files -c pip -n '__completion_needs_command pip' -a install -d 'Install packages.'
22 | complete --no-files -c pip -n '__completion_needs_command pip' -a uninstall -d 'Uninstall packages.'
23 | complete --no-files -c pip -n '__completion_needs_command pip' -a freeze -d 'Output installed packages in requirements format.'
24 | complete --no-files -c pip -n '__completion_needs_command pip' -a list -d 'List installed packages.'
25 | complete --no-files -c pip -n '__completion_needs_command pip' -a show -d 'Show information about installed packages.'
26 | complete --no-files -c pip -n '__completion_needs_command pip' -a search -d 'Search PyPI for packages.'
27 | complete --no-files -c pip -n '__completion_needs_command pip' -a wheel -d 'Build wheels from your requirements.'
28 | complete --no-files -c pip -n '__completion_needs_command pip' -a help -d 'Show help for commands.'
29 |
30 | #general
31 | complete --no-files -c pip -s h, -l help -d 'Show help.'
32 | complete --no-files -c pip -s v, -l verbose -d 'Give more output. Option is additive, and can be used up to 3 times.'
33 | complete --no-files -c pip -s V, -l version -d 'Show version and exit.'
34 | complete --no-files -c pip -s q, -l quiet -d 'Give less output.'
35 | complete --no-files -c pip -l log-file -r -d 'Path to a verbose non-appending log, that only logs failures. This log is active by default at /home/daz/.pip/pip.log.'
36 | complete --no-files -c pip -l log -r -d 'Path to a verbose appending log. This log is inactive by default.'
37 | complete --no-files -c pip -l proxy -r -d 'Specify a proxy in the form [user : passwd@]proxy.server : port.'
38 | complete --no-files -c pip -l timeout -r -d 'Set the socket timeout (default 15 seconds).'
39 | complete --no-files -c pip -l exists-action -r -d 'Default action when a path already exists : (s)witch, (i)gnore, (w)ipe, (b)ackup.'
40 | complete --no-files -c pip -l cert -r -d 'Path to alternate CA bundle.'
41 |
42 | #install
43 | complete --no-files -c pip -n '__completion_using_command install' -s e -l editable -d 'Install a project in editable mode (i.e. setuptools "develop mode") from a local project path or a VCS URL.'
44 | complete --no-files -c pip -n '__completion_using_command install' -s r -l requirement -d 'Install from the given requirements file. This option can be used multiple times.'
45 | complete --no-files -c pip -n '__completion_using_command install' -s b -l build -d 'Directory to unpack packages into and build in. The default in a virtualenv is "/build". The default for global installs is "/pip_build_".'
46 | complete --no-files -c pip -n '__completion_using_command install' -s t -l target -d 'Install packages into .'
47 | complete --no-files -c pip -n '__completion_using_command install' -s d -l download -d 'Download packages into instead of installing them, regardless of what\'s already installed.'
48 | complete --no-files -c pip -n '__completion_using_command install' -l download-cache -d 'Cache downloaded packages in .'
49 | complete --no-files -c pip -n '__completion_using_command install' -l src -d 'Directory to check out editable projects into. The default in a virtualenv is "/src". The default for global installs is "/src".'
50 | complete --no-files -c pip -n '__completion_using_command install' -l upgrade -d 'Upgrade all packages to the newest available version. This process is recursive regardless of whether a dependency is already satisfied.'
51 | complete --no-files -c pip -n '__completion_using_command install' -l force-reinstall -d 'When upgrading, reinstall all packages even if they are already up-to-date.'
52 | complete --no-files -c pip -n '__completion_using_command install' -l ignore-installed -d 'Ignore the installed packages (reinstalling instead).'
53 | complete --no-files -c pip -n '__completion_using_command install' -l no-deps -d 'Don\'t install package dependencies.'
54 | complete --no-files -c pip -n '__completion_using_command install' -l install-option -d 'Extra arguments to be supplied to the setup.py install command (use like --install-option="--install-scripts=/usr/local/bin"). Use multiple --install-option options to pass multiple options to setup.py install. If you are using an option with a directory path, be sure to use absolute path.'
55 | complete --no-files -c pip -n '__completion_using_command install' -l global-option -d 'Extra global options to be supplied to the setup.py call before the install command.'
56 | complete --no-files -c pip -n '__completion_using_command install' -l user -d 'Install using the user scheme.'
57 | complete --no-files -c pip -n '__completion_using_command install' -l egg -d 'Install packages as eggs, not "flat", like pip normally does. This option is not about installing *from* eggs. (WARNING: Because this option overrides pip\'s normal install logic, requirements files may not behave as expected.)'
58 | complete --no-files -c pip -n '__completion_using_command install' -l root -d 'Install everything relative to this alternate root directory.'
59 | complete --no-files -c pip -n '__completion_using_command install' -l compile -d 'Compile py files to pyc'
60 | complete --no-files -c pip -n '__completion_using_command install' -l no-compile -d 'Do not compile py files to pyc'
61 | complete --no-files -c pip -n '__completion_using_command install' -l no-use-wheel -d 'Do not Find and prefer wheel archives when searching indexes and find-links locations.'
62 | complete --no-files -c pip -n '__completion_using_command install' -l pre -d 'Include pre-release and development versions. By default, pip only finds stable versions.'
63 | complete --no-files -c pip -n '__completion_using_command install' -l no-clean -d 'Don\'t clean up build directories.'
64 |
65 | #list
66 | complete --no-files -c pip -n '__completion_using_command list' -s o -l outdated -d 'List outdated packages (excluding editables)'
67 | complete --no-files -c pip -n '__completion_using_command list' -s u -l uptodate -d 'List uptodate packages (excluding editables)'
68 | complete --no-files -c pip -n '__completion_using_command list' -s e -l editable -d 'List editable projects.'
69 | complete --no-files -c pip -n '__completion_using_command list' -s l -l local -d 'If in a virtualenv that has global access, do not list globally-installed packages.'
70 | complete --no-files -c pip -n '__completion_using_command list' -l pre -d 'Include pre-release and development versions. By default, pip only finds stable versions.'
71 |
--------------------------------------------------------------------------------
/plugins/pip/gpip.fish:
--------------------------------------------------------------------------------
1 | function gpip --wraps pip -d "Manage globally-installed Python packages"
2 | env PIP_REQUIRE_VIRTUALENV="0" pip $argv --disable-pip-version-check
3 | end
4 |
--------------------------------------------------------------------------------
/plugins/python/_python.fish:
--------------------------------------------------------------------------------
1 | function _python -d "Use python2 binary if found, otherwise fall back to python"
2 | if which python2
3 | python2 $argv
4 | else
5 | python $argv
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/plugins/python/pyclean.fish:
--------------------------------------------------------------------------------
1 | function pyclean -d "Recursively remove .pyc/.pyo/__pycache__ from current directory"
2 | set -l path_to_clean
3 |
4 | if set -q $argv
5 | set path_to_clean .
6 | else
7 | set path_to_clean $argv
8 | end
9 |
10 | find $path_to_clean -name "*.py[co]" -type f -delete
11 | find $path_to_clean -name "__pycache__" -type d -print0|xargs -0 rm -r --
12 | end
13 |
--------------------------------------------------------------------------------
/plugins/python/pyhttp.fish:
--------------------------------------------------------------------------------
1 | function pyhttp -d "Start an HTTP server, taking an optional parameter for the port number"
2 | if test -n "$argv"
3 | set HTTPPORT $argv
4 | else
5 | set HTTPPORT 8000
6 | end
7 |
8 | _python -m SimpleHTTPServer $HTTPPORT
9 | end
10 |
--------------------------------------------------------------------------------
/plugins/sdl/sdl.fish:
--------------------------------------------------------------------------------
1 | function sdl -d "sudo the last command in history"
2 | eval command sudo $history[1]
3 | end
4 |
--------------------------------------------------------------------------------
/plugins/up/ReadMe.md:
--------------------------------------------------------------------------------
1 | # Update all the things
2 |
3 | ### Problem
4 |
5 | It's hard to remember which parts of your system need updating, as well as the specific commands needed to initiate the update processes.
6 |
7 | ### Solution
8 |
9 | Use the `up` command to update Homebrew, Python, Vundle, Fish completions and TeXLive:
10 |
11 | up all
12 |
13 | If you prefer, you can update individual aspects of your system:
14 |
15 | up python vundle
16 |
17 | ### Python
18 |
19 | Running `up python` makes the assumption that you don't need root permissions in order to install Python packages on Mac OS X, which is the case if you are using [Homebrewed Python][]. On the other hand, it is assumed that you update your _Linux_ systems via `sudo pip install --upgrade foo`.
20 |
21 | If a [virtualenv][] is active, dependencies listed in `requirements.txt` will be upgraded. If no such file is found, any outdated packages in the virtual environment will be upgraded.
22 |
23 | If no virtual environment is active, global Python packages will be updated.
24 |
25 |
26 | [Homebrewed Python]: http://hackercodex.com/guide/python-development-environment-on-mac-osx/
27 | [virtualenv]: http://virtualenv.readthedocs.org/
28 |
--------------------------------------------------------------------------------
/plugins/up/up.fish:
--------------------------------------------------------------------------------
1 | # up: https://github.com/justinmayer/tackle/tree/master/plugins/up
2 | function up -d "Update software to the latest versions"
3 | if contains "all" $argv
4 | git -C $HOME/.tacklebox pull > /dev/null
5 | git -C $HOME/.tackle pull > /dev/null
6 | which brew >/dev/null 2>&1
7 | and begin
8 | brew update
9 | brew upgrade
10 | end
11 | which port >/dev/null 2>&1
12 | and begin
13 | port selfupdate
14 | port upgrade outdated
15 | end
16 | which tlmgr >/dev/null 2>&1
17 | and tlmgr update --self --all
18 | set -l plugins python vundle
19 | for plugin in $plugins
20 | if contains $plugin $tacklebox_plugins
21 | up $plugin
22 | end
23 | end
24 | which apt-get >/dev/null 2>&1
25 | and begin
26 | apt-get update
27 | apt-get upgrade
28 | end
29 | which pacman >/dev/null 2>&1
30 | and begin
31 | sudo pacman -Syy
32 | sudo pacman -Syu
33 | end
34 | fish_update_completions
35 | else
36 | for arg in $argv
37 | if contains $arg $tacklebox_plugins
38 | switch $arg
39 | case "python"
40 | if test -z $VIRTUAL_ENV
41 | set -l os (uname)
42 | if test "$os" = "Linux"
43 | set -l sudo "sudo"
44 | else
45 | set -l sudo ""
46 | end
47 | set -l outdated (env PIP_REQUIRE_VIRTUALENV="" pip list --outdated | cut -d ' ' -f 1)
48 | for pkg in $outdated
49 | set python_packages_to_upgrade $python_packages_to_upgrade $pkg
50 | end
51 | if test -z "$python_packages_to_upgrade"
52 | echo "Python packages are up-to-date."
53 | else
54 | env PIP_REQUIRE_VIRTUALENV="" $sudo pip install --upgrade $python_packages_to_upgrade
55 | set -e python_packages_to_upgrade
56 | end
57 | else
58 | if test -f requirements.txt
59 | pip install --upgrade -r requirements.txt
60 | else
61 | set -l outdated (pip list --outdated | cut -d ' ' -f 1)
62 | pip install --upgrade $outdated
63 | end
64 | end
65 | case "vundle"
66 | env SHELL=/bin/bash vim +PluginInstall! +PluginClean +qall
67 | end
68 | else
69 | echo "Could not locate that plugin in your tacklebox_plugins setting."
70 | end
71 | end
72 | end
73 | end
74 |
--------------------------------------------------------------------------------
/themes/budspencer/README.md:
--------------------------------------------------------------------------------
1 | # Budspencer theme
2 |
3 | A theme for the 70s, makes fish even more powerful. It's equipped with a few
4 | nice functions and key bindings to speed up your workflow.
5 |
6 | ## Demonstration video
7 |
8 | [![video][screenshot]](http://vimeo.com/105546618)
9 |
10 | ## Requirements
11 |
12 | You need an up-to-date fish shell version from [github][fish-git] or a
13 | [nightly build][fish-nightly].
14 |
15 | Non standard tools:
16 |
17 | * xsel
18 | * wmctrl
19 | * git
20 | * [taskwarrior][taskwarrior] (optional)
21 | * [remind][remind] (optional)
22 |
23 | ## Configuration
24 |
25 | ### General configuration
26 |
27 | The theme behaves similar to vim's airline/powerline plugins. Thus, it needs a
28 | [powerline font][font]. Although it works with emacs mode, it's more powerful
29 | with vi mode. In order to enable vi mode, execute:
30 | ```
31 | set -U fish_key_bindings fish_vi_key_bindings
32 | ```
33 |
34 | ### Colors
35 |
36 | Redefine `$budspencer_colors` with the `set` command in order to change the
37 | colors of the prompt.
38 |
39 | Example:
40 | ```
41 | set budspencer_colors 000000 333333 666666 ffffff ffff00 ff6600 ff0000 ff0033 3300ff 0000ff 00ffff
42 | 00ff00
43 | ```
44 | will result in a prompt like this:
45 | ![color replace example][colors]
46 |
47 | Two color schemes for bright and dark environments are predefined. You can
48 | enable them with `day` and `night`, respectively.
49 |
50 | ### Command history
51 | Commands that shouldn't appear in the command history are defined by a universal
52 | list `$budspencer_nocmdhist`. Default:
53 | ```
54 | set -U budspencer_nocmdhist c d ll ls m s
55 | ```
56 |
57 | ### Disable/reenable greeting
58 |
59 | Disable:
60 | ```
61 | set -U budspencer_nogreeting
62 | ```
63 |
64 | Reenable:
65 | ```
66 | set -e budspencer_nogreeting
67 | ```
68 |
69 | ## Outer prompt segments
70 |
71 | - Vi mode is indicated by color of outer segments, cursor color also changes
72 | if terminal supports it:
73 | * blue: NORMAL mode
74 | * yellow: INSERT mode
75 | * magenta: VISUAL mode
76 |
77 | ## Left prompt segments
78 |
79 | - Prompt line number
80 | - Git repository information
81 | - Status symbols
82 | * ✻: keep track of this shell session, can be toggled with `#` to show the number of
83 | the session within the sessions list
84 | * ⌘: present working directory is in bookmark list, can be toggled with `#` to
85 | show the number of the bookmark
86 | * V: vi is parent process
87 | * R: [ranger][ranger] is parent process
88 | * ⚙: there are background jobs, can be toggled with `#` to show the amount of
89 | background jobs
90 | * : no write permissions in present working directory
91 | * ⚔: there are tasks scheduled due today, can be toggled with `#` to
92 | show the amount of tasks
93 | * ⚑: there are appointments for today, can be toggled with `#` to
94 | show the amount of appointments
95 | * ✔: last command succeeded, can be toggled with `#` to show the status value
96 | * ✘: last command failed, can be toggled with `#` to show the status value
97 | * ⚡: superuser indicator
98 | - Present working directory
99 |
100 | ## Right prompt segments
101 |
102 | - Last command's duration time
103 | - Git status symbols:
104 | * ↑: git repository is ahead origin
105 | * ↓: git repository is behind origin
106 | * +: changes have been added to git index
107 | * –: files have been deleted in work tree
108 | * ✱: files have been modified in work tree
109 | * →: files have been renamed in git index
110 | * ═: there are unmerged commits
111 | * ●: there are untracked (new) files
112 | * ✭: there are stashed commits
113 |
114 | ## Toggle prompt segments
115 |
116 | The following shortcuts need vi-mode:
117 | - Style of "present working directory"-segment can be toggled in NORMAL and in
118 | VISUAL mode with space bar
119 | * styles implemented:
120 | - `short` (shows username, short hostname and truncated path; recommended in
121 | most cases)
122 | - `long` (shows username, full hostname and full path; useful for copy-paste
123 | in ssh connections)
124 | - `none` (shows nothing except small delimiter; useful for small terminals)
125 | - If prompt is toggled with `#`, the IP address is shown instead of the
126 | hostname.
127 | * configurable by universal list `$budspencer_pwdstyle` (if not set, defaults to
128 | `short long none`); note that changes to `$budspencer_pwdstyle` keep persistant as it's
129 | a universal variable.
130 |
131 | - Style of symbols can be toggled in NORMAL and in VISUAL mode with `#`
132 | * styles implemented:
133 | - `symbols` (shows status symbols)
134 | - `numbers` (shows numbers instead of symbols in left prompt as well as amount of changes in
135 | right git prompt)
136 |
137 | ## Quickly navigate in history of working directories
138 |
139 | The function `d` shows the history as enumerated list. Unlike fish's builtin
140 | `dirh`, `d` does not show any duplicates. Enter a number to jump to a directory
141 | within the list.
142 |
143 | The following shortcuts need vi-mode:
144 | - Press `H` in NORMAL mode to change present working directory to previous
145 | working directory in history.
146 | - Press `L` in NORMAL mode to change present working directory to next working
147 | directory in history.
148 |
149 | ## Quickly navigate in command history
150 |
151 | The function `c` shows the command history as enumerated list similarly to
152 | the `d` function. Selections are also paste into the X clipboard. It's possible
153 | to load a command of a former prompt by giving the prompt line number as
154 | argument.
155 |
156 | ## Bookmarks
157 |
158 | A bookmark can be created with `mark`. It can be removed with `unmark`.
159 | Bookmarks are universal and thus persistant.
160 | A new shell automatically changes working directory on startup to newest bookmark.
161 | `m` is a function that shows the bookmarks as enumerated list equivalently to `d`.
162 |
163 | The following shortcuts need vi mode:
164 | - Create a bookmark for present working directory with `m` in NORMAL mode.
165 | - Remove a bookmark for present working directory with `M` in NORMAL mode.
166 |
167 | ## Edit commandline with your favorite editor
168 |
169 | The function `edit-commandline` let you edit the commandline with your editor.
170 | It makes the commandline as powerful as your editor. If `$EDITOR` is not set,
171 | vi is used.
172 |
173 | The following shortcut needs vi mode:
174 | - Type `.` in NORMAL mode to edit commandline in editor.
175 |
176 | ## Sessions
177 |
178 | Shell session can be stored with `s `. If a session with `session
179 | name` already exists, the session with this name will be attached. If a session with
180 | `session name` is already active within another terminal, this terminal will be
181 | focussed.
182 |
183 | A list of available sessions can be shown with `s`.
184 |
185 | A session can be erased with `s -e `.
186 |
187 | Type `s -d` to detach current session.
188 |
189 | ## Set window title
190 |
191 | Just type `wt `.
192 |
193 | ## TODO
194 |
195 | - vi REPLACE mode, as soon as REPLACE mode is implemented within fish
196 |
197 | [font]: https://github.com/Lokaltog/powerline-fonts
198 | [ranger]: http://ranger.nongnu.org/
199 | [taskwarrior]: http://taskwarrior.org/
200 | [remind]: http://www.roaringpenguin.com/products/remind
201 | [fish-git]: https://github.com/fish-shell/fish-shell.git
202 | [fish-nightly]: https://github.com/fish-shell/fish-shell/wiki/Nightly-builds
203 | [screenshot]: https://raw.githubusercontent.com/tannhuber/media/master/budspencer.jpg
204 | [colors]: https://raw.githubusercontent.com/tannhuber/media/master/budspencer_replace_colors.jpg
205 |
--------------------------------------------------------------------------------
/themes/budspencer/fish_greeting.fish:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | #
3 | # prompt theme name:
4 | # budspencer
5 | #
6 | # description:
7 | # a sophisticated airline/powerline theme
8 | #
9 | # author:
10 | # joseph tannhuber
11 | #
12 | # sections:
13 | # -> Color definitions
14 | # -> Functions
15 | # -> Help
16 | # -> Environment
17 | # -> Window title
18 | # -> Welcome message
19 | #
20 | ###############################################################################
21 |
22 | ###############################################################################
23 | # => Color definitions
24 | ###############################################################################
25 |
26 | # Define colors
27 | set -U budspencer_night 000000 083743 445659 fdf6e3 b58900 cb4b16 dc121f af005f 6c71c4 268bd2 2aa198 859900
28 | set -U budspencer_day 000000 333333 666666 ffffff ffff00 ff6600 ff0000 ff0033 3300ff 00aaff 00ffff 00ff00
29 | if not set -q budspencer_colors
30 | # Values are: black dark_gray light_gray white yellow orange red magenta violet blue cyan green
31 | set -U budspencer_colors $budspencer_night
32 | end
33 |
34 | # Cursor color changes according to vi-mode
35 | # Define values for: normal_mode insert_mode visual_mode
36 | set -U budspencer_cursors "\033]12;#$budspencer_colors[10]\007" "\033]12;#$budspencer_colors[5]\007" "\033]12;#$budspencer_colors[8]\007" "\033]12;#$budspencer_colors[9]\007"
37 |
38 | # Some terminals cannot change the cursor color
39 | set -l unsupported_terminals 'fbterm' 'st' 'linux' 'screen'
40 | if contains $TERM $unsupported_terminals
41 | set budspencer_cursors '' '' '' ''
42 | end
43 |
44 | ###############################################################################
45 | # => Functions
46 | ###############################################################################
47 |
48 | #########
49 | # => Help
50 | #########
51 | function budspencer_help -d 'Show helpfile'
52 | set -l readme_file "$tacklebox_path/themes/budspencer/README.md"
53 | if set -q PAGER
54 | if [ -e $readme_file ]
55 | eval $PAGER $readme_file
56 | else
57 | set_color $fish_color_error[1]
58 | echo "$readme_file wasn't found."
59 | end
60 | else
61 | open $readme_file
62 | end
63 | end
64 |
65 | ################
66 | # => Environment
67 | ################
68 | function day -d "Set color palette for bright environment."
69 | set budspencer_colors $budspencer_day
70 | set budspencer_cursors "\033]12;#$budspencer_colors[10]\007" "\033]12;#$budspencer_colors[5]\007" "\033]12;#$budspencer_colors[8]\007" "\033]12;#$budspencer_colors[9]\007"
71 | end
72 |
73 | function night -d "Set color palette for dark environment."
74 | set budspencer_colors $budspencer_night
75 | set budspencer_cursors "\033]12;#$budspencer_colors[10]\007" "\033]12;#$budspencer_colors[5]\007" "\033]12;#$budspencer_colors[8]\007" "\033]12;#$budspencer_colors[9]\007"
76 | end
77 |
78 | #################
79 | # => Window title
80 | #################
81 | function wt -d 'Set window title'
82 | set -g window_title $argv
83 | function fish_title
84 | echo -n $window_title
85 | end
86 | end
87 |
88 | ####################
89 | # => Welcome message
90 | ####################
91 | function fish_greeting -d 'Show greeting in login shell.'
92 | if not set -q budspencer_nogreeting
93 | if begin
94 | not set -q -x LOGIN
95 | and not set -q -x RANGER_LEVEL
96 | and not set -q -x VIM
97 | end
98 | echo This is (set_color -b $budspencer_colors[2] $budspencer_colors[10])budspencer(set_color normal) theme for fish, a theme for the 70s.
99 | echo Type (set_color -b $budspencer_colors[2] $budspencer_colors[6])»budspencer_help«(set_color normal) in order to see how you can speed up your workflow.
100 | end
101 | end
102 | end
103 |
--------------------------------------------------------------------------------
/themes/budspencer/fish_prompt.fish:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | #
3 | # Prompt theme name:
4 | # budspencer
5 | #
6 | # Description:
7 | # a sophisticated airline/powerline theme
8 | #
9 | # Author:
10 | # Joseph Tannhuber
11 | #
12 | # Sections:
13 | # -> Key bindings
14 | # -> Files
15 | # -> Functions
16 | # -> Pre execute
17 | # -> Directory history
18 | # -> Command history
19 | # -> Bookmarks
20 | # -> Sessions
21 | # -> Commandline editing with $EDITOR
22 | # -> Git segment
23 | # -> Bind-mode segment
24 | # -> Symbols segment
25 | # -> Prompt initialization
26 | # -> Left prompt
27 | #
28 | ###############################################################################
29 |
30 | ###############################################################################
31 | # => Key bindings
32 | ###############################################################################
33 |
34 | if [ $fish_key_bindings = 'fish_vi_key_bindings' ]
35 | bind '#' __budspencer_toggle_symbols
36 | bind -M visual '#' __budspencer_toggle_symbols
37 | bind ' ' __budspencer_toggle_pwd
38 | bind -M visual ' ' __budspencer_toggle_pwd
39 | bind L __budspencer_cd_next
40 | bind H __budspencer_cd_prev
41 | bind m mark
42 | bind M unmark
43 | bind . __budspencer_edit_commandline
44 | bind -M insert \n __budspencer_preexec
45 | bind \n __budspencer_preexec
46 | end
47 |
48 | ###############################################################################
49 | # => Files
50 | ###############################################################################
51 |
52 | # Config file
53 | set -g budspencer_config "$HOME/.config/fish/budspencer_config.fish"
54 |
55 | # Temporary files
56 | set -g budspencer_tmpfile '/tmp/'(echo %self)'_budspencer_edit.fish'
57 |
58 | ###############################################################################
59 | # => Functions
60 | ###############################################################################
61 |
62 | ################
63 | # => Pre execute
64 | ################
65 | function __budspencer_preexec -d 'Execute after hitting before doing anything else'
66 | set -l cmd (commandline | sed 's|\s\+|\x1e|g')
67 | if [ $_ = 'fish' ]
68 | if [ -z $cmd[1] ]
69 | set -e cmd[1]
70 | end
71 | if [ -z $cmd[1] ]
72 | return
73 | end
74 | set -e budspencer_prompt_error[1]
75 | if not type -q $cmd[1]
76 | if [ -d $cmd[1] ]
77 | set budspencer_prompt_error (cd $cmd[1] ^&1)
78 | and commandline ''
79 | commandline -f repaint
80 | return
81 | end
82 | end
83 | switch $cmd[1]
84 | case 'c'
85 | if begin
86 | [ (count $cmd) -gt 1 ]
87 | and [ $cmd[2] -gt 0 ]
88 | and [ $cmd[2] -lt $pcount ]
89 | end
90 | commandline $prompt_hist[$cmd[2]]
91 | echo $prompt_hist[$cmd[2]] | xsel
92 | commandline -f repaint
93 | return
94 | end
95 | case 'cd'
96 | if [ (count $cmd) -le 2 ]
97 | set budspencer_prompt_error (eval $cmd ^&1)
98 | and commandline ''
99 | if [ (count $budspencer_prompt_error) -gt 1 ]
100 | set budspencer_prompt_error $budspencer_prompt_error[1]
101 | end
102 | commandline -f repaint
103 | return
104 | end
105 | case 'day' 'night'
106 | if [ (count $cmd) -eq 1 ]
107 | eval $cmd
108 | commandline ''
109 | commandline -f repaint
110 | return
111 | end
112 | end
113 | end
114 | commandline -f execute
115 | end
116 |
117 | #####################
118 | # => Fish termination
119 | #####################
120 | function __budspencer_on_termination -s HUP -s INT -s QUIT -s TERM --on-process %self -d 'Execute when shell terminates'
121 | set -l item (contains -i %self $budspencer_sessions_active_pid ^ /dev/null)
122 | __budspencer_detach_session $item
123 | end
124 |
125 | ######################
126 | # => Directory history
127 | ######################
128 | function __budspencer_create_dir_hist -v PWD -d 'Create directory history without duplicates'
129 | if [ "$pwd_hist_lock" = false ]
130 | if contains $PWD $$dir_hist
131 | set -e $dir_hist[1][(contains -i $PWD $$dir_hist)]
132 | end
133 | set $dir_hist $$dir_hist $PWD
134 | set -g dir_hist_val (count $$dir_hist)
135 | end
136 | end
137 |
138 | function __budspencer_cd_prev -d 'Change to previous directory, press H in NORMAL mode.'
139 | if [ $dir_hist_val -gt 1 ]
140 | set dir_hist_val (expr $dir_hist_val - 1)
141 | set pwd_hist_lock true
142 | cd $$dir_hist[1][$dir_hist_val]
143 | commandline -f repaint
144 | end
145 | end
146 |
147 | function __budspencer_cd_next -d 'Change to next directory, press L in NORMAL mode.'
148 | if [ $dir_hist_val -lt (count $$dir_hist) ]
149 | set dir_hist_val (expr $dir_hist_val + 1)
150 | set pwd_hist_lock true
151 | cd $$dir_hist[1][$dir_hist_val]
152 | commandline -f repaint
153 | end
154 | end
155 |
156 | function d -d 'List directory history, jump to directory in list with d '
157 | set -l num_items (expr (count $$dir_hist) - 1)
158 | if [ $num_items -eq 0 ]
159 | set_color $fish_color_error[1]
160 | echo 'Directory history is empty. '(set_color normal)'It will be created automatically'
161 | return
162 | end
163 | for i in (seq $num_items)
164 | if [ (expr \( $num_items - $i \) \% 2) -eq 0 ]
165 | set_color normal
166 | else
167 | set_color $budspencer_colors[4]
168 | end
169 | echo (expr $num_items - $i)\t$$dir_hist[1][$i] | sed "s|$HOME|~|"
170 | end
171 | if [ $num_items -eq 1 ]
172 | set last_item ''
173 | else
174 | set last_item '-'(expr $num_items - 1)
175 | end
176 | echo -en $budspencer_cursors[2]
177 | set input_length (expr length (expr $num_items - 1))
178 | read -p 'echo -n (set_color -b $budspencer_colors[2] $budspencer_colors[5])" ♻ Goto [e|0"$last_item"] "(set_color -b normal $budspencer_colors[2])" "(set_color $budspencer_colors[5])' -n $input_length -l dir_num
179 | switch $dir_num
180 | case (seq 0 (expr $num_items - 1))
181 | cd $$dir_hist[1][(expr $num_items - $dir_num)]
182 | return 0
183 | case 'e'
184 | read -p 'echo -n (set_color -b $budspencer_colors[2] $budspencer_colors[5])" ♻ Erase [0"$last_item"] "(set_color -b normal $budspencer_colors[2])" "(set_color $budspencer_colors[5])' -n $input_length -l dir_num
185 | set -e $dir_hist[1][(expr $num_items - $dir_num)] ^ /dev/null
186 | set dir_hist_val (count $$dir_hist)
187 | return 0
188 | end
189 | return 1
190 | end
191 |
192 | ####################
193 | # => Command history
194 | ####################
195 | function __budspencer_create_cmd_hist -e fish_prompt -d 'Create command history without duplicates'
196 | if [ $_ = 'fish' ]
197 | set pcount (expr $pcount + 1)
198 | set -l IFS ''
199 | set -l cmd (echo $history[1] | fish_indent | expand -t 4)
200 | # Create prompt history
201 | set prompt_hist $prompt_hist $cmd
202 | # Create command history
203 | if not begin
204 | expr $cmd : '[cdms] ' > /dev/null
205 | or contains $cmd $budspencer_nocmdhist
206 | end
207 | if contains $cmd $$cmd_hist
208 | set -e $cmd_hist[1][(contains -i $cmd $$cmd_hist)]
209 | end
210 | set $cmd_hist $$cmd_hist $cmd
211 | end
212 | end
213 | set fish_bind_mode insert
214 | echo -n \a
215 | end
216 |
217 | function c -d 'List command history, load command from prompt with c '
218 | set -l num_items (count $$cmd_hist)
219 | if [ $num_items -eq 0 ]
220 | set_color $fish_color_error[1]
221 | echo 'Command history is empty. '(set_color normal)'It will be created automatically.'
222 | return
223 | end
224 | for i in (seq $num_items)
225 | if [ (expr \( $num_items - $i \) \% 2) -eq 0 ]
226 | set_color normal
227 | else
228 | set_color $budspencer_colors[4]
229 | end
230 | echo -n (expr $num_items - $i)
231 | set -l item (echo $$cmd_hist[1][$i])
232 | echo -n \t$item\n
233 | end
234 | if [ $num_items -eq 1 ]
235 | set last_item ''
236 | else
237 | set last_item '-'(expr $num_items - 1)
238 | end
239 | echo -en $budspencer_cursors[4]
240 | set input_length (expr length (expr $num_items - 1))
241 | read -p 'echo -n (set_color -b $budspencer_colors[2] $budspencer_colors[9])" ↩ Exec [e|0"$last_item"] "(set_color -b normal $budspencer_colors[2])" "(set_color $budspencer_colors[9])' -n $input_length -l cmd_num
242 | switch $cmd_num
243 | case (seq 0 (expr $num_items - 1))
244 | commandline $$cmd_hist[1][(expr $num_items - $cmd_num)]
245 | echo $$cmd_hist[1][(expr $num_items - $cmd_num)] | xsel
246 | return 0
247 | case 'e'
248 | read -p 'echo -n (set_color -b $budspencer_colors[2] $budspencer_colors[9])" ↩ Erase [0"$last_item"] "(set_color -b normal $budspencer_colors[2])" "(set_color $budspencer_colors[9])' -n $input_length -l cmd_num
249 | set -e $cmd_hist[1][(expr $num_items - $cmd_num)] ^ /dev/null
250 | return 0
251 | end
252 | return 1
253 | end
254 |
255 | ##############
256 | # => Bookmarks
257 | ##############
258 | function mark -d 'Create bookmark for present working directory.'
259 | if not contains $PWD $bookmarks
260 | set -U bookmarks $PWD $bookmarks
261 | set pwd_hist_lock true
262 | commandline -f repaint
263 | end
264 | end
265 |
266 | function unmark -d 'Remove bookmark for present working directory.'
267 | if contains $PWD $bookmarks
268 | set -e bookmarks[(contains -i $PWD $bookmarks)]
269 | set pwd_hist_lock true
270 | commandline -f repaint
271 | end
272 | end
273 |
274 | function m -d 'List bookmarks, jump to directory in list with m '
275 | set -l num_items (count $bookmarks)
276 | if [ $num_items -eq 0 ]
277 | set_color $fish_color_error[1]
278 | echo 'Bookmark list is empty. '(set_color normal)'Enter '(set_color $fish_color_command[1])'mark '(set_color normal)'in INSERT mode or '(set_color $fish_color_command[1])'m '(set_color normal)'in NORMAL mode, if you want to add the current directory to your bookmark list.'
279 | return
280 | end
281 | for i in (seq $num_items)
282 | if [ $PWD = $bookmarks[$i] ]
283 | set_color $budspencer_colors[10]
284 | else
285 | if [ (expr \( $num_items - $i \) \% 2) -eq 0 ]
286 | set_color normal
287 | else
288 | set_color $budspencer_colors[4]
289 | end
290 | end
291 | echo (expr $num_items - $i)\t$bookmarks[$i] | sed "s|$HOME|~|"
292 | end
293 | if [ $num_items -eq 1 ]
294 | set last_item ''
295 | else
296 | set last_item '-'(expr $num_items - 1)
297 | end
298 | echo -en $budspencer_cursors[1]
299 | set input_length (expr length (expr $num_items - 1))
300 | read -p 'echo -n (set_color -b $budspencer_colors[2] $budspencer_colors[10])" ⌘ Goto [0"$last_item"] "(set_color -b normal $budspencer_colors[2])" "(set_color $budspencer_colors[10])' -n $input_length -l dir_num
301 | switch $dir_num
302 | case (seq 0 (expr $num_items - 1))
303 | cd $bookmarks[(expr $num_items - $dir_num)]
304 | return 0
305 | end
306 | return 1
307 | end
308 |
309 | #############
310 | # => Sessions
311 | #############
312 | function __budspencer_delete_zombi_sessions -d 'Delete zombi sessions'
313 | for i in $budspencer_sessions_active_pid
314 | if not contains $i %fish
315 | set -l item (contains -i $i $budspencer_sessions_active_pid)
316 | set -e budspencer_sessions_active_pid[$item]
317 | set -e budspencer_sessions_active[$item]
318 | end
319 | end
320 | end
321 |
322 | function __budspencer_create_new_session -d 'Create a new session'
323 | set -U budspencer_session_cmd_hist_$argv[1] $$cmd_hist
324 | set -U budspencer_session_dir_hist_$argv[1] $$dir_hist
325 | set -U budspencer_sessions $argv[1] $budspencer_sessions
326 | end
327 |
328 | function __budspencer_erase_session -d 'Erase current session'
329 | if [ (count $argv) -eq 1 ]
330 | set_color $fish_color_error[1]
331 | echo 'Missing argument: name of session to erase'
332 | return
333 | end
334 | if contains $argv[2] $budspencer_sessions_active
335 | set_color $fish_color_error[1]
336 | echo "Session '$argv[2]' cannot be erased because it's currently active."
337 | return
338 | end
339 | if contains $argv[2] $budspencer_sessions
340 | set -e budspencer_session_cmd_hist_$argv[2]
341 | set -e budspencer_session_dir_hist_$argv[2]
342 | set -e budspencer_sessions[(contains -i $argv[2] $budspencer_sessions)]
343 | else
344 | set_color $fish_color_error[1]
345 | echo "Session '$argv[2]' not found. "(set_color normal)'Enter '(set_color $fish_color_command[1])'s '(set_color normal)'to show a list of all recorded sessions.'
346 | end
347 | end
348 |
349 | function __budspencer_detach_session -d 'Detach current session'
350 | set cmd_hist cmd_hist_nosession
351 | set dir_hist dir_hist_nosession
352 | if [ -z $$dir_hist ] ^ /dev/null
353 | set $dir_hist $PWD
354 | end
355 | set dir_hist_val (count $$dir_hist)
356 | set -e budspencer_sessions_active_pid[$argv] ^ /dev/null
357 | set -e budspencer_sessions_active[$argv] ^ /dev/null
358 | set budspencer_session_current ''
359 | cd $$dir_hist[1][$dir_hist_val]
360 | end
361 |
362 | function __budspencer_attach_session -d 'Attach session'
363 | set argv (echo -sn $argv\n | sed 's|[^[:alnum:]]|_|g')
364 | if contains $argv[1] $budspencer_sessions_active
365 | wmctrl -a "✻ $argv[1]"
366 | else
367 | wt "✻ $argv[1]"
368 | __budspencer_detach_session $argv[-1]
369 | set budspencer_sessions_active $budspencer_sessions_active $argv[1]
370 | set budspencer_sessions_active_pid $budspencer_sessions_active_pid %self
371 | set budspencer_session_current $argv[1]
372 | if not contains $argv[1] $budspencer_sessions
373 | __budspencer_create_new_session $argv[1]
374 | end
375 | set cmd_hist budspencer_session_cmd_hist_$argv[1]
376 | set dir_hist budspencer_session_dir_hist_$argv[1]
377 | if [ -z $$dir_hist ] ^ /dev/null
378 | set $dir_hist $PWD
379 | end
380 | set dir_hist_val (count $$dir_hist)
381 | cd $$dir_hist[1][$dir_hist_val] ^ /dev/null
382 | end
383 | end
384 |
385 | function s -d 'Create, delete or attach session'
386 | __budspencer_delete_zombi_sessions
387 | if [ (count $argv) -eq 0 ]
388 | set -l active_indicator
389 | set -l num_items (count $budspencer_sessions)
390 | if [ $num_items -eq 0 ]
391 | set_color $fish_color_error[1]
392 | echo -n 'Session list is empty. '
393 | set_color normal
394 | echo -n 'Enter '
395 | set_color $fish_color_command[1]
396 | echo -n 's '
397 | set_color $fish_color_param[1]
398 | echo -n 'session-name'
399 | set_color normal
400 | echo ' to record the current session.'
401 | return
402 | end
403 | for i in (seq $num_items)
404 | if [ $budspencer_sessions[$i] = $budspencer_session_current ]
405 | set_color $budspencer_colors[8]
406 | else
407 | if [ (expr \( $num_items - $i \) \% 2) -eq 0 ]
408 | set_color normal
409 | else
410 | set_color $budspencer_colors[4]
411 | end
412 | end
413 | if contains $budspencer_sessions[$i] $budspencer_sessions_active
414 | set active_indicator '✻ '
415 | else
416 | set active_indicator ' '
417 | end
418 | echo (expr $num_items - $i)\t$active_indicator$budspencer_sessions[$i]
419 | end
420 | if [ $num_items -eq 1 ]
421 | set last_item ''
422 | else
423 | set last_item '-'(expr $num_items - 1)
424 | end
425 | echo -en $budspencer_cursors[3]
426 | set input_length (expr length (expr $num_items - 1))
427 | read -p 'echo -n (set_color -b $budspencer_colors[2] $budspencer_colors[8])" ✻ Attach [e|0"$last_item"] "(set_color -b normal $budspencer_colors[2])" "(set_color $budspencer_colors[8])' -n $input_length -l session_num
428 | switch $session_num
429 | case (seq 0 (expr $num_items - 1))
430 | set argv[1] $budspencer_sessions[(expr $num_items - $session_num)]
431 | case 'e'
432 | read -p 'echo -n (set_color -b $budspencer_colors[2] $budspencer_colors[8])" ✻ Erase [0"$last_item"] "(set_color -b normal $budspencer_colors[2])" "(set_color $budspencer_colors[8])' -n $input_length -l session_num
433 | __budspencer_erase_session -e $budspencer_sessions[(expr $num_items - $session_num)]
434 | return 0
435 | case '*'
436 | return 1
437 | end
438 | end
439 | set -l item (contains -i %self $budspencer_sessions_active_pid ^ /dev/null)
440 | switch $argv[1]
441 | case '-e'
442 | __budspencer_erase_session $argv
443 | case '-d'
444 | wt 'fish'
445 | __budspencer_detach_session $item
446 | case '-*'
447 | set_color $fish_color_error[1]
448 | echo "Invalid argument: $argv[1]"
449 | case '*'
450 | __budspencer_attach_session $argv $item
451 | end
452 | end
453 |
454 | #####################################
455 | # => Commandline editing with $EDITOR
456 | #####################################
457 | function __budspencer_edit_commandline -d 'Open current commandline with your editor'
458 | commandline > $budspencer_tmpfile
459 | eval $EDITOR $budspencer_tmpfile
460 | if [ -s $budspencer_tmpfile ]
461 | commandline (sed 's|^\s*||' $budspencer_tmpfile)
462 | else
463 | commandline ''
464 | end
465 | rm $budspencer_tmpfile
466 | end
467 |
468 | ################
469 | # => Git segment
470 | ################
471 | function __budspencer_prompt_git_branch -d 'Return the current branch name'
472 | set -l branch (command git symbolic-ref HEAD ^ /dev/null | sed -e 's|^refs/heads/||')
473 | if not test $branch > /dev/null
474 | set -l position (command git describe --contains --all HEAD ^ /dev/null)
475 | if not test $position > /dev/null
476 | set -l commit (command git rev-parse HEAD ^ /dev/null | sed 's|\(^.......\).*|\1|')
477 | echo -n (set_color -b $budspencer_colors[11])''(set_color $budspencer_colors[1])' ➦ '$commit' '(set_color $budspencer_colors[11])
478 | else
479 | echo -n (set_color -b $budspencer_colors[9])''(set_color $budspencer_colors[1])' '$position' '(set_color $budspencer_colors[9])
480 | end
481 | else
482 | echo -n (set_color -b $budspencer_colors[3])''(set_color $budspencer_colors[1])' '$branch' '(set_color $budspencer_colors[3])
483 | end
484 | end
485 |
486 | ######################
487 | # => Bind-mode segment
488 | ######################
489 | function __budspencer_prompt_bindmode -d 'Displays the current mode'
490 | switch $fish_bind_mode
491 | case default
492 | set budspencer_current_bindmode_color $budspencer_colors[10]
493 | echo -en $budspencer_cursors[1]
494 | case insert
495 | set budspencer_current_bindmode_color $budspencer_colors[5]
496 | echo -en $budspencer_cursors[2]
497 | if [ "$pwd_hist_lock" = true ]
498 | set pwd_hist_lock false
499 | __budspencer_create_dir_hist
500 | end
501 | case visual
502 | set budspencer_current_bindmode_color $budspencer_colors[8]
503 | echo -en $budspencer_cursors[3]
504 | end
505 | if [ (count $budspencer_prompt_error) -eq 1 ]
506 | set budspencer_current_bindmode_color $budspencer_colors[7]
507 | end
508 | set_color -b $budspencer_current_bindmode_color $budspencer_colors[1]
509 | echo -n " $pcount "
510 | set_color -b $budspencer_colors[1] $budspencer_current_bindmode_color
511 | end
512 |
513 | ####################
514 | # => Symbols segment
515 | ####################
516 | function __budspencer_prompt_left_symbols -d 'Display symbols'
517 | set -l jobs (jobs | wc -l)
518 | if [ -e ~/.taskrc ]
519 | set todo (task due.before:tomorrow ^ /dev/null | tail -1 | cut -f1 -d' ')
520 | end
521 | if [ -e ~/.reminders ]
522 | set appointments (rem -a | cut -f1 -d' ')
523 | end
524 | if [ (count $todo) -eq 0 ]
525 | set todo 0
526 | end
527 | if [ (count $appointments) -eq 0 ]
528 | set appointments 0
529 | end
530 | set_color -b $budspencer_colors[2]
531 | echo -n ''
532 |
533 | if [ $symbols_style = 'symbols' ]
534 | if [ $budspencer_session_current != '' ]
535 | set_color -o $budspencer_colors[8]
536 | echo -n ' ✻'
537 | end
538 | if contains $PWD $bookmarks
539 | set_color -o $budspencer_colors[10]
540 | echo -n ' ⌘'
541 | end
542 | if set -q -x VIM
543 | set_color -o $budspencer_colors[9]
544 | echo -n ' V'
545 | end
546 | if set -q -x RANGER_LEVEL
547 | set_color -o $budspencer_colors[9]
548 | echo -n ' R'
549 | end
550 | if [ $jobs -gt 0 ]
551 | set_color -o $budspencer_colors[11]
552 | echo -n ' ⚙'
553 | end
554 | if [ ! -w . ]
555 | set_color -o $budspencer_colors[6]
556 | echo -n ' '
557 | end
558 | if [ $todo -gt 0 ]
559 | set_color -o $budspencer_colors[4]
560 | echo -n ' ⚔'
561 | end
562 | if [ $appointments -gt 0 ]
563 | set_color -o $budspencer_colors[5]
564 | echo -n ' ⚑'
565 | end
566 | if [ $last_status -eq 0 ]
567 | set_color -o $budspencer_colors[12]
568 | echo -n ' ✔'
569 | else
570 | set_color -o $budspencer_colors[7]
571 | echo -n ' ✘'
572 | end
573 | if [ $USER = 'root' ]
574 | set_color -o $budspencer_colors[6]
575 | echo -n ' ⚡'
576 | end
577 | else
578 | if [ $budspencer_session_current != '' ] ^ /dev/null
579 | set_color $budspencer_colors[8]
580 | echo -n ' '(expr (count $budspencer_sessions) - (contains -i $budspencer_session_current $budspencer_sessions))
581 | end
582 | if contains $PWD $bookmarks
583 | set_color $budspencer_colors[10]
584 | echo -n ' '(expr (count $bookmarks) - (contains -i $PWD $bookmarks))
585 | end
586 | if set -q -x VIM
587 | set_color -o $budspencer_colors[9]
588 | echo -n ' V'
589 | set_color normal
590 | end
591 | if set -q -x RANGER_LEVEL
592 | set_color -b $budspencer_colors[2] $budspencer_colors[9]
593 | echo -n ' '$RANGER_LEVEL
594 | end
595 | if [ $jobs -gt 0 ]
596 | set_color -b $budspencer_colors[2] $budspencer_colors[11]
597 | echo -n ' '$jobs
598 | end
599 | if [ ! -w . ]
600 | set_color -o $budspencer_colors[6]
601 | echo -n ' '
602 | set_color normal
603 | end
604 | if [ $todo -gt 0 ]
605 | set_color -b $budspencer_colors[2] $budspencer_colors[4]
606 | echo -n " $todo"
607 | end
608 | if [ $appointments -gt 0 ]
609 | set_color -b $budspencer_colors[2] $budspencer_colors[5]
610 | echo -n " $appointments"
611 | end
612 | if [ $last_status -eq 0 ]
613 | set_color -b $budspencer_colors[2] $budspencer_colors[12]
614 | echo -n ' '$last_status
615 | else
616 | set_color -b $budspencer_colors[2] $budspencer_colors[7]
617 | echo -n ' '$last_status
618 | end
619 | if [ $USER = 'root' ]
620 | set_color -o $budspencer_colors[6]
621 | echo -n ' ⚡'
622 | end
623 | end
624 | echo -n ' '
625 | set_color -b normal $budspencer_colors[2]
626 | end
627 |
628 | ###############################################################################
629 | # => Prompt initialization
630 | ###############################################################################
631 |
632 | # Initialize some global variables
633 | set -g budspencer_prompt_error
634 | set -g budspencer_current_bindmode_color
635 | set -U budspencer_sessions_active $budspencer_sessions_active
636 | set -U budspencer_sessions_active_pid $budspencer_sessions_active_pid
637 | set -g budspencer_session_current ''
638 | set -g cmd_hist_nosession
639 | set -g cmd_hist cmd_hist_nosession
640 | set -g CMD_DURATION 0
641 | set -g dir_hist_nosession
642 | set -g dir_hist dir_hist_nosession
643 | set -g pwd_hist_lock false
644 | set -g pcount 1
645 | set -g prompt_hist
646 | set -g symbols_style 'symbols'
647 |
648 | # Load user defined key bindings
649 | if functions --query fish_user_key_bindings
650 | fish_user_key_bindings
651 | end
652 |
653 | # Set favorite editor
654 | if not set -q EDITOR
655 | set -g EDITOR vi
656 | end
657 |
658 | # Source config file
659 | if [ -e $budspencer_config ]
660 | source $budspencer_config
661 | end
662 |
663 | # Don't save in command history
664 | if not set -q budspencer_nocmdhist
665 | set -U budspencer_nocmdhist 'c' 'd' 'll' 'ls' 'm' 's'
666 | end
667 |
668 | # Set PWD segment style
669 | if not set -q budspencer_pwdstyle
670 | set -U budspencer_pwdstyle short long none
671 | end
672 | set pwd_style $budspencer_pwdstyle[1]
673 |
674 | # Cd to newest bookmark if this is a login shell
675 | if not begin
676 | set -q -x LOGIN
677 | or set -q -x RANGER_LEVEL
678 | or set -q -x VIM
679 | end ^ /dev/null
680 | cd $bookmarks[1]
681 | end
682 | set -x LOGIN $USER
683 |
684 | ###############################################################################
685 | # => Left prompt
686 | ###############################################################################
687 |
688 | function fish_prompt -d 'Write out the left prompt of the budspencer theme'
689 | set -g last_status $status
690 | echo -n -s (__budspencer_prompt_bindmode) (__budspencer_prompt_git_branch) (__budspencer_prompt_left_symbols) '' ' '
691 | end
692 |
--------------------------------------------------------------------------------
/themes/budspencer/fish_right_prompt.fish:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | #
3 | # Prompt theme name:
4 | # budspencer
5 | #
6 | # Description:
7 | # a sophisticated airline/powerline theme
8 | #
9 | # Author:
10 | # Joseph Tannhuber
11 | #
12 | # Sections:
13 | # -> Functions
14 | # -> Toggle functions
15 | # -> Command duration segment
16 | # -> Git segment
17 | # -> PWD segment
18 | # -> Prompt
19 | #
20 | ###############################################################################
21 |
22 | ###############################################################################
23 | # => Functions
24 | ###############################################################################
25 |
26 | #####################
27 | # => Toggle functions
28 | #####################
29 | function __budspencer_toggle_symbols -d 'Toggles style of symbols, press # in NORMAL or VISUAL mode'
30 | if [ $symbols_style = 'symbols' ]
31 | set symbols_style 'numbers'
32 | else
33 | set symbols_style 'symbols'
34 | end
35 | set pwd_hist_lock true
36 | commandline -f repaint
37 | end
38 |
39 | function __budspencer_toggle_pwd -d 'Toggles style of pwd segment, press space bar in NORMAL or VISUAL mode'
40 | for i in (seq (count $budspencer_pwdstyle))
41 | if [ $budspencer_pwdstyle[$i] = $pwd_style ]
42 | set pwd_style $budspencer_pwdstyle[(expr $i \% (count $budspencer_pwdstyle) + 1)]
43 | set pwd_hist_lock true
44 | commandline -f repaint
45 | break
46 | end
47 | end
48 | end
49 |
50 | #############################
51 | # => Command duration segment
52 | #############################
53 | function __budspencer_cmd_duration -d 'Displays the elapsed time of last command'
54 | set -l seconds ''
55 | set -l minutes ''
56 | set -l hours ''
57 | set -l days ''
58 | set -l cmd_duration (expr $CMD_DURATION / 1000)
59 | if [ $cmd_duration -gt 0 ]
60 | set seconds (expr $cmd_duration \% 68400 \% 3600 \% 60)'s'
61 | if [ $cmd_duration -ge 60 ]
62 | set minutes (expr $cmd_duration \% 68400 \% 3600 / 60)'m'
63 | if [ $cmd_duration -ge 3600 ]
64 | set hours (expr $cmd_duration \% 68400 / 3600)'h'
65 | if [ $cmd_duration -ge 68400 ]
66 | set days (expr $cmd_duration / 68400)'d'
67 | end
68 | end
69 | end
70 | if [ $last_status -ne 0 ]
71 | echo -n (set_color $budspencer_colors[2])''(set_color -b $budspencer_colors[2] $budspencer_colors[7])' '$days$hours$minutes$seconds
72 | else
73 | echo -n (set_color $budspencer_colors[2])''(set_color -b $budspencer_colors[2] $budspencer_colors[12])' '$days$hours$minutes$seconds
74 | end
75 | end
76 | end
77 |
78 | ################
79 | # => Git segment
80 | ################
81 | function __budspencer_is_git_ahead_or_behind -d 'Check if there are unpulled or unpushed commits'
82 | command git rev-list --count --left-right 'HEAD...@{upstream}' ^ /dev/null | sed 's|\s\+|\n|g'
83 | end
84 |
85 | function __budspencer_git_status -d 'Check git status'
86 | set -l git_status (command git status --porcelain ^/dev/null | cut -c 1-2)
87 | set -l added (echo -sn $git_status\n | egrep -c "[ACDMT][ MT]|[ACMT]D")
88 | set -l deleted (echo -sn $git_status\n | egrep -c "[ ACMRT]D")
89 | set -l modified (echo -sn $git_status\n | egrep -c ".[MT]")
90 | set -l renamed (echo -sn $git_status\n | egrep -c "R.")
91 | set -l unmerged (echo -sn $git_status\n | egrep -c "AA|DD|U.|.U")
92 | set -l untracked (echo -sn $git_status\n | egrep -c "\?\?")
93 | echo -n $added\n$deleted\n$modified\n$renamed\n$unmerged\n$untracked
94 | end
95 |
96 | function __budspencer_is_git_stashed -d 'Check if there are stashed commits'
97 | set -l isgitstashed (string trim -l (command git log --format="%gd" -g $argv 'refs/stash' -- ^ /dev/null | wc -l))
98 | echo -n $isgitstashed
99 | end
100 |
101 | function __budspencer_prompt_git_symbols -d 'Displays the git symbols'
102 | set -l is_repo (command git rev-parse --is-inside-work-tree ^/dev/null)
103 | if [ -z $is_repo ]
104 | return
105 | end
106 |
107 | set -l git_ahead_behind (__budspencer_is_git_ahead_or_behind)
108 | set -l git_status (__budspencer_git_status)
109 | set -l git_stashed (__budspencer_is_git_stashed)
110 |
111 | if [ (expr $git_status[1] + $git_status[2] + $git_status[3] + $git_status[4] + $git_status[5] + $git_status[6] + $git_stashed) -ne 0 ]
112 | set_color $budspencer_colors[3]
113 | echo -n ''
114 | set_color -b $budspencer_colors[3]
115 | if [ $symbols_style = 'symbols' ]
116 | if [ (count $git_ahead_behind) -eq 2 ]
117 | if [ $git_ahead_behind[1] -gt 0 ]
118 | set_color -o $budspencer_colors[5]
119 | echo -n ' ↑'
120 | end
121 | if [ $git_ahead_behind[2] -gt 0 ]
122 | set_color -o $budspencer_colors[5]
123 | echo -n ' ↓'
124 | end
125 | end
126 | if [ $git_status[1] -gt 0 ]
127 | set_color -o $budspencer_colors[12]
128 | echo -n ' +'
129 | end
130 | if [ $git_status[2] -gt 0 ]
131 | set_color -o $budspencer_colors[7]
132 | echo -n ' –'
133 | end
134 | if [ $git_status[3] -gt 0 ]
135 | set_color -o $budspencer_colors[10]
136 | echo -n ' ✱'
137 | end
138 | if [ $git_status[4] -gt 0 ]
139 | set_color -o $budspencer_colors[8]
140 | echo -n ' →'
141 | end
142 | if [ $git_status[5] -gt 0 ]
143 | set_color -o $budspencer_colors[9]
144 | echo -n ' ═'
145 | end
146 | if [ $git_status[6] -gt 0 ]
147 | set_color -o $budspencer_colors[4]
148 | echo -n ' ●'
149 | end
150 | if [ $git_stashed -gt 0 ]
151 | set_color -o $budspencer_colors[11]
152 | echo -n ' ✭'
153 | end
154 | else
155 | if [ (count $git_ahead_behind) -eq 2 ]
156 | if [ $git_ahead_behind[1] -gt 0 ]
157 | set_color $budspencer_colors[5]
158 | echo -n ' '$git_ahead_behind[1]
159 | end
160 | if [ $git_ahead_behind[2] -gt 0 ]
161 | set_color $budspencer_colors[5]
162 | echo -n ' '$git_ahead_behind[2]
163 | end
164 | end
165 | if [ $git_status[1] -gt 0 ]
166 | set_color $budspencer_colors[12]
167 | echo -n ' '$git_status[1]
168 | end
169 | if [ $git_status[2] -gt 0 ]
170 | set_color $budspencer_colors[7]
171 | echo -n ' '$git_status[2]
172 | end
173 | if [ $git_status[3] -gt 0 ]
174 | set_color $budspencer_colors[10]
175 | echo -n ' '$git_status[3]
176 | end
177 | if [ $git_status[4] -gt 0 ]
178 | set_color $budspencer_colors[8]
179 | echo -n ' '$git_status[4]
180 | end
181 | if [ $git_status[5] -gt 0 ]
182 | set_color $budspencer_colors[9]
183 | echo -n ' '$git_status[5]
184 | end
185 | if [ $git_status[6] -gt 0 ]
186 | set_color $budspencer_colors[4]
187 | echo -n ' '$git_status[6]
188 | end
189 | if [ $git_stashed -gt 0 ]
190 | set_color $budspencer_colors[11]
191 | echo -n ' '$git_stashed
192 | end
193 | end
194 | set_color -b $budspencer_colors[3] normal
195 | end
196 | end
197 |
198 | ################
199 | # => PWD segment
200 | ################
201 | function __budspencer_prompt_pwd -d 'Displays the present working directory'
202 | set -l user_host ' '
203 | if set -q SSH_CLIENT
204 | if [ $symbols_style = 'symbols' ]
205 | switch $pwd_style
206 | case short
207 | set user_host " $USER@"(hostname -s)':'
208 | case long
209 | set user_host " $USER@"(hostname -f)':'
210 | end
211 | else
212 | set user_host " $USER@"(hostname -i)':'
213 | end
214 | end
215 | set_color $budspencer_current_bindmode_color
216 | echo -n ''
217 | set_color normal
218 | set_color -b $budspencer_current_bindmode_color $budspencer_colors[1]
219 | if [ (count $budspencer_prompt_error) != 1 ]
220 | switch $pwd_style
221 | case short
222 | echo -n $user_host(prompt_pwd)' '
223 | case long
224 | echo -n $user_host(pwd)' '
225 | end
226 | else
227 | echo -n " $budspencer_prompt_error "
228 | set -e budspencer_prompt_error[1]
229 | end
230 | set_color normal
231 | end
232 |
233 | ###############################################################################
234 | # => Prompt
235 | ###############################################################################
236 |
237 | function fish_right_prompt -d 'Write out the right prompt of the budspencer theme'
238 | echo -n (__budspencer_cmd_duration) (__budspencer_prompt_git_symbols) (__budspencer_prompt_pwd)
239 | set_color normal
240 | end
241 |
--------------------------------------------------------------------------------
/themes/entropy/ReadMe.md:
--------------------------------------------------------------------------------
1 | # Entropy
2 |
3 | Entropy provides a crisp-looking appearance for your prompt, including support for [virtualenv][], [Git][], and [Mercurial][].
4 |
5 | ![Entropy prompt screenshot][screenshot]
6 |
7 | ## Version Control Status
8 |
9 | If you only use Git, then you're all ready to go.
10 |
11 | ### vcprompt
12 |
13 | If you use Mercurial and want to see repository status in this theme’s prompt, you **must** have [vcprompt][] installed, which on macOS can be done via:
14 |
15 | brew install vcprompt
16 |
17 | Enable [vcprompt][] in your Fish configuration via:
18 |
19 | set __use_vcprompt
20 |
21 | Why use [vcprompt][]? Determining whether the current working directory is under version control is cumbersome and adds latency to the prompt. It doesn't make sense to have a slow terminal prompt on a 3+ GHz machine, right? [vcprompt][] is a tiny C program that is also extremely fast, which makes it perfectly suited to making this determination.
22 |
23 | ### hg-prompt
24 |
25 | If you use Mercurial, you'll also need to install [hg-prompt][], which populates the prompt with relevant information when the current working directory is inside a Mercurial repository.
26 |
27 | [hg-prompt]: http://sjl.bitbucket.org/hg-prompt/
28 | [Git]: http://git-scm.com/
29 | [Mercurial]: http://mercurial.selenic.com/
30 | [screenshot]: https://i.imgur.com/ESkmQKF.png
31 | [vcprompt]: https://bitbucket.org/gward/vcprompt
32 | [virtualenv]: http://virtualenv.readthedocs.org/
33 |
--------------------------------------------------------------------------------
/themes/entropy/fish_prompt.fish:
--------------------------------------------------------------------------------
1 | # Entropy prompt theme, by Justin Mayer
2 | function fish_prompt -d "Write out the prompt"
3 |
4 | # Just calculate these once, to save a few cycles when displaying the prompt
5 | if not set -q __fish_prompt_hostname
6 | set -g __fish_prompt_hostname (hostname|cut -d . -f 1)
7 | end
8 |
9 | if not set -q __fish_prompt_normal
10 | set -g __fish_prompt_normal (set_color normal)
11 | end
12 |
13 | if not set -q __fish_prompt_virtualenv_color
14 | set -g __fish_prompt_virtualenv_color (set_color blue)
15 | end
16 |
17 | if not set -q __fish_prompt_userhost_color
18 | set -g __fish_prompt_userhost_color (set_color blue)
19 | end
20 |
21 | if not set -q __fish_prompt_repo_branch_color
22 | set -g __fish_prompt_repo_branch_color (set_color magenta)
23 | end
24 |
25 | if not set -q __fish_prompt_repo_status_color
26 | set -g __fish_prompt_repo_status_color (set_color blue)
27 | end
28 |
29 | if not set -q __fish_prompt_gray
30 | set -g __fish_prompt_gray (set_color -o black)
31 | end
32 |
33 | # Git prompt settings
34 | _ifnotset __fish_git_prompt_showdirtystate "true"
35 | _ifnotset __fish_git_prompt_char_dirtystate "!"
36 | _ifnotset __fish_git_prompt_color_dirtystate "blue"
37 | _ifnotset __fish_git_prompt_showuntrackedfiles "true"
38 | _ifnotset __fish_git_prompt_char_untrackedfiles "?"
39 | _ifnotset __fish_git_prompt_color_untrackedfiles "blue"
40 | _ifnotset __fish_git_prompt_color_branch "magenta"
41 |
42 | # Only use vcprompt if __use_vcprompt is set; otherwise assume Git-only
43 | if not set -q __use_vcprompt
44 | set -g __vcprompt $__fish_prompt_gray' on '(__fish_git_prompt "%s" | sed 's/ //')
45 | else
46 | # If vcprompt detects PWD is a git/hg repo, call native VCS prompt function
47 | set -g __vcsystem (vcprompt -f "%n")
48 |
49 | if test -z $__vcsystem
50 | set -g __vcprompt
51 | else
52 |
53 | switch $__vcsystem
54 |
55 | case 'git*'
56 |
57 | set -g __vcprompt $__fish_prompt_gray' on '(__fish_git_prompt "%s" | sed 's/ //')
58 |
59 | case 'hg*'
60 |
61 | set hg_promptstring "$__fish_prompt_gray< on $__fish_prompt_repo_branch_color>$__fish_prompt_repo_status_color$__fish_prompt_normal"
62 | set -g __vcprompt (hg prompt --angle-brackets $hg_promptstring)
63 |
64 | end
65 | end
66 | end
67 |
68 | switch $USER
69 |
70 | case root
71 |
72 | if not set -q __fish_prompt_cwd
73 | if set -q fish_color_cwd_root
74 | set -g __fish_prompt_cwd (set_color $fish_color_cwd_root)
75 | else
76 | set -g __fish_prompt_cwd (set_color $fish_color_cwd)
77 | end
78 | end
79 |
80 | set -g __fish_prompt_char ' # '
81 |
82 | case '*'
83 |
84 | if not set -q __fish_prompt_cwd
85 | set -g __fish_prompt_cwd (set_color $fish_color_cwd)
86 | end
87 |
88 | set -g __fish_prompt_char ' ➤ '
89 |
90 | end
91 |
92 | if [ -z $SSH_CONNECTION ]
93 |
94 | if not set -q __fish_prompt_userhost
95 | set -g __fish_prompt_userhost
96 | end
97 |
98 | else
99 |
100 | if not set -q __fish_prompt_userhost
101 | set -g __fish_prompt_userhost $__fish_prompt_userhost_color$USER"@"$__fish_prompt_hostname" "
102 | end
103 |
104 | end
105 |
106 | if set -q VIRTUAL_ENV
107 | if not set -q __fish_prompt_virtualenv
108 | set __fish_prompt_virtualenv $__fish_prompt_virtualenv_color"("(basename "$VIRTUAL_ENV")")"$__fish_prompt_normal" "
109 | end
110 | end
111 |
112 | echo -n -s "$__fish_prompt_userhost" "$__fish_prompt_virtualenv" "$__fish_prompt_cwd" (prompt_pwd) "$__vcprompt" "$__fish_prompt_normal" "$__fish_prompt_char"
113 |
114 | end
115 |
--------------------------------------------------------------------------------
/themes/entropy/fish_title.fish:
--------------------------------------------------------------------------------
1 | function fish_title -d "Show host/process (if relevant) and PWD in title"
2 | if [ $SSH_CONNECTION ]
3 | echo "$__fish_prompt_hostname "
4 | end
5 | if [ $_ != fish ]
6 | echo "$_: "
7 | end
8 | prompt_pwd
9 | end
10 |
--------------------------------------------------------------------------------
/themes/urdh/ReadMe.md:
--------------------------------------------------------------------------------
1 | # urdh
2 |
3 | urdh provides a pretty simple prompt, with support [Git][] and [Mercurial][].
4 |
5 | ![urdh prompt screenshot][screenshot]
6 |
7 | ## Requirements
8 |
9 | ### vcprompt
10 |
11 | You **must** have [vcprompt][] installed to use this theme, which on Mac OS X can be done via:
12 |
13 | brew install vcprompt
14 |
15 | Why the hard requirement? Determining whether the current working directory is under version control is cumbersome and adds latency to the prompt. It doesn't make sense to have a slow terminal prompt on a 3+ GHz machine, right? [vcprompt][] is a tiny C program that is also extremely fast, which makes it perfectly suited to making this determination.
16 |
17 | If you only use Git, then you're all ready to go.
18 |
19 | ### hg-prompt
20 |
21 | If you use Mercurial, you'll also need to install [hg-prompt][], which populates the prompt with relevant information when the current working directory is inside a Mercurial repository.
22 |
23 | [hg-prompt]: http://sjl.bitbucket.org/hg-prompt/
24 | [Git]: http://git-scm.com/
25 | [Mercurial]: http://mercurial.selenic.com/
26 | [screenshot]: http://i.imgur.com/zoa85vj.png
27 | [vcprompt]: https://bitbucket.org/gward/vcprompt
28 |
--------------------------------------------------------------------------------
/themes/urdh/fish_greeting.fish:
--------------------------------------------------------------------------------
1 | # urdh prompt theme, by Simon Sigurdhsson
2 | function fish_greeting --description 'Print the shell greeting'
3 | set -l c_n (set_color normal)
4 | set -l c_w (set_color cyan)
5 |
6 | set -l location (printf "%sWelcome to %s%s%s" $c_n $c_w (hostname) $c_n)
7 | set -l system (printf "%sRunning %s%s%s on %s%s%s" $c_n $c_w (uname -mrs) $c_n $c_w (tty | sed -e 's/.*tty\(.*\)/\1/') $c_n)
8 | set -l datetime (printf "%sIt is %s%s%s (%s) on %s%s%s" $c_n $c_w (date +%T) $c_n (date +%Z) $c_w (date +%F) $c_n)
9 |
10 | printf "\n %s\n %s\n %s\n\n" $location $system $datetime
11 | end
12 |
--------------------------------------------------------------------------------
/themes/urdh/fish_prompt.fish:
--------------------------------------------------------------------------------
1 | # urdh prompt theme, by Simon Sigurdhsson
2 | function _urdh_theme_user --description 'Print user name'
3 | switch $USER
4 | case root
5 | printf '%s%s%s' (set_color red) $USER (set_color normal)
6 | case '*'
7 | printf '%s' $USER
8 | end
9 | end
10 |
11 | function _urdh_theme_cwd --description 'Print current working directory'
12 | printf '%s%s%s' (set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
13 | end
14 |
15 | function _urdh_theme_vcs --description 'Write out the VCS prompt'
16 | set -l ___vcs (vcprompt -f '%n')
17 | if test -n "$___vcs"
18 | switch $___vcs
19 | case 'git*'
20 | set -g __fish_git_prompt_color_branch 'black' '--bold'
21 | set -g __fish_git_prompt_color_merging 'red' '--bold'
22 | __fish_git_prompt ' %s'
23 | case 'hg*'
24 | printf ' %s%s%s' (set_color -o black) (vcprompt -f '%b') (set_color normal)
25 | end
26 | end
27 | end
28 |
29 | function fish_prompt --description 'Write out the prompt'
30 | # precalc some variables
31 | if not set -q _urdh_theme_hostname
32 | set -g _urdh_theme_hostname (hostname|cut -d . -f 1)
33 | end
34 | # print the prompt
35 | set -l ___host (printf '%s@%s' (_urdh_theme_user) $_urdh_theme_hostname)
36 | set -l ___cwd (_urdh_theme_cwd)
37 | set -l ___vcs (printf '%s%s' (_urdh_theme_vcs))
38 | printf '%s %s%s> ' $___host $___cwd $___vcs
39 | end
40 |
--------------------------------------------------------------------------------
/themes/urdh/fish_right_prompt.fish:
--------------------------------------------------------------------------------
1 | # urdh prompt theme, by Simon Sigurdhsson
2 | function fish_right_prompt --description 'Write out the right-hand prompt'
3 | set -l ___vcs (vcprompt -f '%n')
4 | if test -n "$___vcs"
5 | switch $___vcs
6 | case 'git*'
7 | set -l __fish_git_prompt_showstashstate 'yes'
8 | set -l __fish_git_prompt_showdirtystate 'yes'
9 | set -l __fish_git_prompt_showuntrackedfiles 'yes'
10 | set -l __fish_git_prompt_show_informative_status 'yes'
11 | set -l __fish_git_prompt_showupstream 'informative git'
12 |
13 | set -g ___fish_git_prompt_color_cleanstate (set_color --bold green)
14 | set -g ___fish_git_prompt_color_stagedstate (set_color --bold green)
15 | set -g ___fish_git_prompt_color_invalidstate (set_color --bold red)
16 | set -g ___fish_git_prompt_color_dirtystate (set_color --bold yellow)
17 | set -g ___fish_git_prompt_color_untrackedfiles (set_color --bold red)
18 | set -g ___fish_git_prompt_color_stashstate (set_color --bold cyan)
19 |
20 | set -g ___fish_git_prompt_char_upstream_equal ''
21 | set -g ___fish_git_prompt_char_upstream_ahead '⬘'
22 | set -g ___fish_git_prompt_char_upstream_behind '⬙'
23 | set -g ___fish_git_prompt_char_upstream_diverged '⬥'
24 | set -g ___fish_git_prompt_char_stateseparator ''
25 | set -g ___fish_git_prompt_char_dirtystate '●'
26 | set -g ___fish_git_prompt_char_invalidstate '⦻'
27 | set -g ___fish_git_prompt_char_stagedstate '●'
28 | set -g ___fish_git_prompt_char_untrackedfiles '○'
29 | set -g ___fish_git_prompt_char_cleanstate '✔ '
30 | set -g ___fish_git_prompt_char_stashstate '▣'
31 |
32 | set -g __fish_git_prompt_hide_dirtystate 'yes'
33 | set -g __fish_git_prompt_hide_invalidstate 'yes'
34 | set -g __fish_git_prompt_hide_stagedstate 'yes'
35 | set -g __fish_git_prompt_hide_untrackedfiles 'yes'
36 |
37 | set -l i (__fish_git_prompt_informative_status)
38 | set -l s
39 | if test -r (command git rev-parse --git-dir)/refs/stash
40 | set s $___fish_git_prompt_char_stashstate
41 | set s "$___fish_git_prompt_color_stashstate$s"
42 | set s "$s$___fish_git_prompt_color_stashstate_done"
43 | end
44 | set -l u (__fish_git_prompt_show_upstream)
45 |
46 | printf '%s%s%s%s%s' $i (set_color -o black) $s $u (set_color normal)
47 | case 'hg*'
48 | printf ' %s%s%s' (set_color -o red) (hg prompt '{status}') (set_color normal)
49 | end
50 | end
51 | end
52 |
--------------------------------------------------------------------------------
/themes/urdh/fish_title.fish:
--------------------------------------------------------------------------------
1 | # urdh prompt theme, by Simon Sigurdhsson
2 | function fish_title --description 'Set terminal title'
3 | if set -q fish_title_disabled
4 | return
5 | end
6 |
7 | set -l pwd (prompt_pwd)
8 | switch "$_"
9 | case 'ssh'
10 | set -g fish_title_string 'ssh'
11 | case 'fish'
12 | set -g fish_title_string (printf 'idle in %s' $pwd)
13 | case '*'
14 | set -g fish_title_string (printf 'running %s in %s' $_ $pwd)
15 | end
16 |
17 | if test -n "$SSH_CONNECTION"
18 | printf 'fish on %s: %s' (hostname|cut -d . -f 1) $fish_title_string
19 | else
20 | printf 'fish: %s' $fish_title_string
21 | end
22 | end
23 |
--------------------------------------------------------------------------------