fish/config.fish @ d1b9a524e5fe default tip
More
| author | Steve Losh <steve@stevelosh.com> |
|---|---|
| date | Wed, 22 Oct 2025 15:48:44 -0400 |
| parents | 890e2d48b6f7 |
| children | (none) |
# Useful functions {{{ function eb; nvim ~/Dropbox/bitly.txt; end function ed; nvim ~/.vim/custom-dictionary.utf-8.add; end function ef; nvim ~/.config/fish/config.fish; end function eg; nvim ~/.gitconfig; end function eh; nvim ~/.hgrc; end function ei; hg -R ~/src/inventory/ pull -u; and nvim ~/src/inventory/inventory.markdown; and hg -R ~/src/inventory/ ci -m 'Update inventory'; and hg -R ~/src/inventory/ push; end function em; nvim ~/.mutt/muttrc; end function es; pushd ~/src/dotfiles/stumpwm; e stumpwmrc; popd; end function ev; nvim ~/.vimrc; end function evm; nvim ~/.vimrc-minimal; end function eff; nvim ~/.config/fish/functions; end function efh; nvim ~/.local/share/fish/fish_history; end # I have visited https://github.com/fish-shell/fish-shell/issues/862 nine thousand times and I'm fucking sick of opening a web browser to figure out where the fuck fish keeps its equivalent of ~/.bash_history function essh; nvim ~/.ssh/config; end function est; nvim ~/Sync/school/TODO; end function js; cd ~/scratch; end function jd; cd /dump; end function jl; cd ~/scratch/logs; end function histgrep; history | grep "$argv" | tac; end function ..; cd ..; end function ...; cd ../..; end function ....; cd ../../..; end function .....; cd ../../../..; end function eatshit if test "$argv[1]" = '-u' echo -n 'http://bit.ly/eat-shit' | pbcopy else echo -n '≣:D ⊃-' | pbcopy end end function mcd --argument dir mkdir "$dir"; and cd "$dir" end alias sin singularity alias sm snakemake # I give up alias :q exit alias :qa exit alias :wqa exit # }}} # Abbreviations {{{ abbr --add ai "sudo apt install" abbr --add sc "sudo systemctl" abbr --add paper --set-cursor=% "cp -t . ~/Sync/papers/files/%" abbr --add i "qimgv" # }}} # Completions {{{ function make_completion --argument alias command complete -c $alias -xa "( set -l cmd (commandline -pc | sed -e 's/^ *\S\+ *//' ); complete -C\"$command \$cmd\"; )" end complete -c s -w ssh complete -c cw -w which complete -c ew -w which complete -c h -w hg complete -c g -w git complete -c hl -w less # }}} # Bind Keys {{{ # Backwards compatibility? Screw that, it's more important that our function # names have underscores so they look pretty. function please_fish_just_bind_the_keys bind \cn accept-autosuggestion bind \cw backward-kill-word end function fish_user_keybindings please_fish_just_bind_the_keys end function fish_user_key_bindings please_fish_just_bind_the_keys end # }}} # Environment variables {{{ set -g -x NIX_LINK "$HOME/.nix-profile" set -g -x RLWRAP_HOME "$HOME/.rlwrap" function prepend_to_path -d "Prepend the given dir to PATH if it exists and is not already in it" if test -d $argv[1] if not contains $argv[1] $PATH set -gx PATH "$argv[1]" $PATH end end end set -gx PATH "/sbin" prepend_to_path "/snap/bin" prepend_to_path "/usr/sbin" prepend_to_path "/bin" prepend_to_path "/usr/bin" prepend_to_path "/usr/local/bin" prepend_to_path "/usr/local/go/bin" prepend_to_path "/usr/local/sbin" prepend_to_path "/usr/games" prepend_to_path "$HOME/.local/bin" prepend_to_path "$HOME/src/dotfiles/lisp/bin" prepend_to_path "$HOME/src/dotfiles/bin" prepend_to_path "$HOME/src/hg" prepend_to_path "$HOME/bin" prepend_to_path "$HOME/.go/bin" prepend_to_path "$HOME/bin/jdk-21.0.2/bin" set BROWSER open set -g -x fish_greeting '' set -g -x EDITOR nvim set -g -x COMMAND_MODE unix2003 set -g -x RUBYOPT rubygems set -g -x PAGER 'less -iX' # set -g -x _JAVA_OPTIONS "-Djava.awt.headless=true" set -g -x JAVA_HOME "$HOME/bin/jdk-21.0.2/" set -g -x GPG_TTY (tty) # Less Colors for Man Pages set -g -x LESS_TERMCAP_mb (printf '\e[01;31m') # begin blinking set -g -x LESS_TERMCAP_md (printf '\e[01;38;5;74m') # begin bold set -g -x LESS_TERMCAP_me (printf '\e[0m') # end mode set -g -x LESS_TERMCAP_se (printf '\e[0m') # end standout-mode set -g -x LESS_TERMCAP_so (printf '\e[38;5;246m') # begin standout-mode - info box set -g -x LESS_TERMCAP_ue (printf '\e[0m') # end underline set -g -x LESS_TERMCAP_us (printf '\e[04;38;5;146m') # begin underline set -g -x ANSIBLE_NOCOWS 1 set -g -x DFT_COLOR 'always' # disable stupid pipe detection set -g -x DFT_WIDTH 10000000000 # stop trying to be smart set -g -x DFT_TAB_WIDTH 8 # tabs are 8 characters wide set -g -x DFT_DISPLAY side-by-side set -g -x DFT_CONTEXT 8 # more context set -g -x DFT_SYNTAX_HIGHLIGHT off # my eyes # }}} # Disable Spyware {{{ set -g -x DO_NOT_TRACK 1 set -g -x STRIPE_CLI_TELEMETRY_OPTOUT 1 set -g -x GOTELEMETRY off set -g -x GOPROXY direct set -g -x VAGRANT_CHECKPOINT_DISABLE 1 set -g -x CHECKPOINT_DISABLE 1 # }}} # Python {{{ set -g -x PIP_DOWNLOAD_CACHE "$HOME/.pip/cache" set -g -x PYTHONPATH "" set PYTHONPATH "$HOME/lib/hg/hg:$PYTHONPATH" # }}} # Go {{{ set -g -x GOPATH "$HOME/.go" set -g -x GOSUMDB off # }}} # R {{{ set -g -x R_LIBS_USER "$HOME/.R" # }}} # Z {{{ if test -e ~/src/z-fish/z.fish . ~/src/z-fish/z.fish end # }}} # Prompt {{{ if status --is-interactive set normal (set_color normal) set magenta (set_color magenta) set yellow (set_color yellow) set green (set_color green) set cyan (set_color cyan) set gray (set_color -o black) set hg_promptstring "\ < on $magenta<branch>$normal>\ < at $cyan<bookmark>$normal>\ $green<status|modified|unknown><update>$normal\ " 2>/dev/null if test -n "$SSH_CLIENT" or test -n "$SSH_TTY" set host_color (set_color cyan) set want_vcs_prompts 0 else set host_color (set_color yellow) set want_vcs_prompts 1 end end function hg-managed set --local d "$(pwd)" while test "/" != "$d" if test -d "$d/.hg" return 0 end set d (path dirname "$d") end return 1 end function hg_prompt if test -z "$NOVCSPROMPT" if hg-managed hg prompt --angle-brackets $hg_promptstring 2>/dev/null end end end function git_prompt if test -z "$NOVCSPROMPT" if git root >/dev/null 2>&1 set_color normal printf ' on ' set_color magenta printf '%s' (git current-branch 2>/dev/null) set_color green git_prompt_status set_color normal end end end function prompt_pwd --description 'Print the current working directory, shortend to fit the prompt' echo $PWD | sed -e "s|^$HOME|~|" end set elapsed_start 0 set elapsed 0 function prompt_time_elapsed --description 'Print the time taken by the previous command, if significant.' if test $elapsed -gt 2 echo -n ' ('$elapsed's)' end end function elapsed_timer_pre -e fish_preexec set elapsed_start (date '+%s') end function elapsed_timer_post -e fish_postexec set elapsed (math (date '+%s') - $elapsed_start) end function fish_prompt set last_status $status echo set_color magenta printf '%s' (whoami) set_color normal printf ' at ' printf "$host_color%s" (hostname|cut -d . -f 1) set_color normal printf ' in ' set_color $fish_color_cwd printf '%s' (prompt_pwd) set_color normal if test $want_vcs_prompts -eq 1 hg_prompt git_prompt end set_color brblack prompt_time_elapsed echo if test $last_status -eq 0 set_color white -o printf '><((°> ' else set_color red -o printf '[%d] ><((ˣ> ' $last_status end set_color normal end # }}} # Local {{{ if test -f $HOME/.local.fish . $HOME/.local.fish end # }}} true