fish shell cheat sheet
1 My fish shell config tips
2 fish config files:
~/.config (has configs for GNS3, wireshark, htop, and now fish ~/.config/fish/config.fish ~/.config/fish/functions/fishprompt.fish
3 fish environment variables
set PYENVVERSION 3.7.5 echo $PYENVVERSION
set -x PYENVVERSION 3.7.5
env | grep PYENVVERSION
The run #!/usr/bin/env python
4 fish shell specific commands: functions,
5 omf themes
Once fish and omf have been installed, you can issue omf commands to choose themes and plugins.
- Note that you won't find omf as a command: i.e. which omf returns null. But fish has 'omf' saved as an abbreviation, 'abbrev'.
omf themes
To install one of these themes use
omf install flash
omf install hulk
Note to self: this updates the file ~/.config/omf/theme to the one line 'hulk'
omf install chain
To see help for omf type:
omf help
COMMANDS cd Change to root or package directory. channel Get or change the update channel. describe Show information about a package. destroy Uninstall Oh My Fish. doctor Troubleshoot Oh My Fish. help Shows help about a command. install Install one or more packages. list List installed packages. new Create a new package from a template. reload Reload the current shell. remove Remove a package. repositories Manage package repositories. search Search for a package or theme. theme Install and list themes. update Update Oh My Fish. version Display version and exit.
( ) Users ) zintis ) omf theme 20:00:58 ≡ 2 Installed: default flash Available: agnoster emoji-powerline lolfish scorphish aight es mars separation ays fishbone mish shellder batman fishface mokou simple-ass-prompt beloglazov fishy-drupal mtahmed simplevi bira fisk nai slacker bobthefish flash nelsonjchen slavic-cat bongnoster fox neolambda spacefish boxfish gentoo numist sushi budspencer gianu ocean syl20bnr cbjohnson gitstatus one taktoa chain gnuykeaj pastfish technopagan clearance godfather perryh toaster cmorrell graystatus pie tomita coffeeandcode harleen plain trout cor idan pure tweetjay cyan integral pygmalion uggedal dangerous jacaetevha random will default johanson randomrussel wolf-theme dmorrell kawasaki redfish yimmy doughsay krisleech red-snapper zeit eclm l rider zephyr edan lambda robbyrussell zish eden lavender sashimi ( ) Users ) zintis ) omf install robbyrussell
6 other fish commands:
See the docs at fishshell.com
6.1 abbr
abbr –add [SCOPE] WORD EXPANSION abbr –erase word abbr –show abbr –list
6.2 functions fishprompt
functions fish_prompt
is a very useful command to see where the fish prompt
is coming from. You may have omf instll a theme, but not change the prompt
if there is a fishprompt in you function path that is taking precedence over
the omf theme installed version.
Look for the first line that says somthing like:
6.2.1 Most likely directory that holds the fishprompt files.
The directory Users/zintis.config/fish/functions hold the current active fishprompt.fish file, However.. it is a symlink to the themed fishprompt.fish files.
These omf themed directories are all located in: ~/.local/share/omf/themes
So that means there is a fishprompt.fish file in each of: default/fishprompt.fish clearance/fishprompt.fish flash/fishprompt.fish etc….
6.3 omf remove flash
you can remove the themes you no longer want with this command. Good idea to to an omf list first
6.4 omf list
Shows you what plugins and what themes you have instlled, and which ones are active.
6.5 omf theme
changes to a theme that is already installed
Once installed, it will have clobbered any existing fishprompt.fish file that was located in the .local/share/omf/themes/themname directory.
So a good idea is to record the changes you make to these themed prompts so that you can tweak them again. I have typically changed to "promptpwd" to "pwd" as I like to see the whole directory.
6.6 omf install
installs a theme. You can get the list from omf list
6.7 omf doctor
I did this when working out my prompt, and what themes I liked. This is what I got
➜ zintis omf doctor Oh My Fish version: 6 OS type: Darwin Fish version: fish, version 3.0.2 Git version: git version 2.23.0 Git core.autocrlf: no Warning: fish_prompt.fish is overridden. fish_config command persists the prompt to ~/.config/fish/functions/fish_prompt.fish That file takes precedence over Oh My Fish's themes. Remove the file to fix it: rm ~/.config/fish/functions/fish_prompt.fish If everything you use Oh My Fish for is working fine, please don't worry and just ignore the warnings. Thanks! ➜ zintis
Note: since the file ~/.config/fish/functions/fishprompt.fish is just a symbolic link, I typically don't hesitate to delete it.
Then I can issue the command omf theme x to switch to theme x, and omf will then cretae a new version of ~/.config/fish/functions/fishprompt.fish
7 bobthefish theme customization
Display all possible bobthefish colour themes:
bobthefish_display_colors --all
Can change them by editing: ~/.config/fish/functions/bobthefishcolors.fish
7.1 powerline fonts:
https://github.com/powerline/fonts
These can be tried at a later time
7.2 options not yet tried:
7.2.1 option 1
function fishmodeprompt end
7.2.2 option 2
8 Useful commands:
8.1 recursive searches
ls /var/**.log will do a recursive listing of all files ending in .log This is a very useful feature… ** says do the search with *, but the second * means do it for all subdirectories too.
8.2 auto suggestions from history
as you type, fish will narrow down your choices from your history buffer. When you see what you want, you can: rightarrow to accept C-f to accept M-rightarrow to accept a single workd of the suggest
8.3 Tab completions
tab will try to complete the arugument, command, or path. if there are more than one option, fish (tab) will show them as you type
8.4 omf
omf (for oh my fish) omf theme # to list the available themes
My fish shell did not find omf as a command. ????? Feb 6, 2020
8.5 prompt
Bobthefish prompt has an extensive options sample on github
set -g themedisplaygit no set -g themedisplaygituntracked no set -g themedisplaygitaheadverbose yes set -g themegitworktreesupport yes set -g themedisplayvagrant yes set -g themedisplaydockermachine no set -g themedisplayhg yes set -g themedisplayvirtualenv no set -g themedisplayruby no set -g themedisplayuser yes set -g themedisplayvi no set -g themedisplaydate no set -g themedisplaycmdduration yes set -g themetitledisplayprocess yes set -g themetitledisplaypath no set -g themetitleuseabbreviatedpath no set -g themedateformat "+%a %H:%M" set -g themeavoidambiguousglyphs yes set -g themepowerlinefonts no set -g themenerdfonts yes set -g themeshowexitstatus yes set -g defaultuser yournormaluser set -g themecolorscheme dark set -g fishpromptpwddirlength 0 set -g themeprojectdirlength 1
8.6 ~/.config/fish/conf.d/omf.fish
I found these in the file ~/.config/fish/conf.d/omf.fish set -g themedisplayrust yes set -g themedisplaynode yes set -g themedisplaypwdonsecondline yes set -g themedisplaygitonfirstline yes set -g themedisplayruby no
Compare these locations: ~/.config/fish/conf.d/omf.fish ~/.config/fish/config.fish
function _bobthefishpwd -d 'Get a normalized $PWD'
builtin pwd -P 2>/dev/null or echo $PWD end
-——————————from some other dump (to review) ——————— Quick list for aliasing:
functions aliasname
functions -n
functions -c newalias aliasname
functions -e aliasname
To list what aliases you have already defined:
ls -la ~/.config/fish/functions/ To see what is contained in the functions, use:
type functionName
functions functionName To create an alias:
alias lss 'ls -lart | sort -k9,9' To save said alias:
funcsave lss View the contents of the function:
functions lss
function lss –description 'alias lss ls -lart | sort -k9,9' ls -lart | sort -k9,9 $argv; end To remove an alias:
rm ~/.config/fish/functions/aliasname.fish or use:
functions -e aliasname Oh My Fish https://github.com/oh-my-fish/oh-my-fish
Use nvm with fish If you have Oh My Fish installed then install the bass plugin:
omf install bass Then add the following to your config.fish file:
function nvm bass source (brew –prefix nvm)/nvm.sh –no-use ';' nvm $argv end
set -x NVMDIR ~/.nvm nvm use default –silent Then source the config.fish file:
source ~/.config/fish/config.fish List out added aliases I found this handy function on Stack Overflow which will list out your functions:
function aliases –description "list all fish aliases";for f in (functions);functions $f | grep \'alias;end;end; Then you save it funcsave aliases and use it:
aliases function c –description 'alias c code .' function g –description 'alias g git' function lss –description 'alias lss ls -lart | sort -k9,9' function ni –description 'alias ni npm i' function nid –description 'alias nid npm i -D' function nig –description 'alias nig npm i -g' function no –description 'alias no npm outdated' function nog –description 'alias nog npm outdated -g –depth=0' function nr –description 'alias nr npm run' function nrb –description 'alias nrb npm run build' function nrd –description 'alias nrd npm run dev' function nrf –description 'alias nrf npm run format' function nrs –description 'alias nrs npm run start' function nug –description 'alias nug npm -g un' function nun –description 'alias nu npm un' function r –description 'alias r cd mnt/d/repos' function yd –description 'alias yd yarn dev' function yg –description 'alias yg yarn go' function ys –description 'alias ys yarn start' The following you can copy pate into fish:
alias c 'code .';funcsave c;alias g 'git';funcsave g;alias lss 'ls -lart | sort -k9,9';funcsave lss;alias ni