FISH-FAQ(1) fish-shell FISH-FAQ(1) (NAME) fish-faq - fish (DESCRIPTION) (FAQ) fish . ( ) (WHAT IS THE EQUIVALENT TO THIS THING FROM BASH (OR OTHER SHELLS)?) fish-for-bash-users(1) <> . (HOW DO I SET OR CLEAR AN ENVIRONMENT VARIABLE?) set <> : set -x key value # typically set -gx key value set -e key 3.1 key=value some command . - value : key=value echo $key begin; set -lx key value; echo $key; end " (exported)" (scope) <#variables-scope> . . (global) . (HOW DO I CHECK WHETHER A VARIABLE IS DEFINED?) set -q var . if set -q var; echo variable defined; end. and or : if set -q var1; or set -q var2 echo either variable defined end ( set var ) ( set var "" ). . (HOW DO I CHECK WHETHER A VARIABLE IS NOT EMPTY?) string length -q -- $var . if string length -q -- $var; echo not empty; end. string length ( / or) : if string length -q -- $var1 $var2 $var3 echo at least one of these variables is not empty end test -n "$var" () . if test -n "$var"; echo not empty; end. test <<>> (-a) <<>> (-o) : if test -n "$var1" -o -n "$var2" -o -n "$var3" echo at least one of these variables is not empty end set -q var[1] . set -Ux ( ) (WHY DOESN'T SET -UX (EXPORTED UNIVERSAL VARIABLES) SEEM TO WORK?) (global) . EDITOR TZ set -Ux (universal) . ( ) . <#variables-scope> << >> . . . <#configuration> ( ~/.config/fish/config.fish) : set -gx EDITOR vim bashrc. profile. (HOW DO I RUN A COMMAND EVERY LOGIN? WHAT'S FISH'S EQUIVALENT TO .BASHRC OR .PROFILE?) ~/.config/fish/config.fish [1] ( ). bashrc. profile. . status is-interactive : if status is-interactive # use the coolbeans theme fish_config theme choose coolbeans end [1] "~/.config" $XDG_CONFIG_HOME . () (HOW DO I SET MY PROMPT?) fish_prompt . ~/.config/fish/functions/fish_prompt.fish . : function fish_prompt set_color $fish_color_cwd echo -n (prompt_pwd) set_color --reset echo -n ' > ' end fish_config <> . fish_config : > fish_config prompt show # displays all the prompts fish ships with > fish_config prompt choose disco # loads the disco prompt in the current shell > fish_config prompt save # makes the change permanent funced <> funcsave <> : >_ funced fish_prompt # This opens up your editor (set in $EDITOR). # Modify the function, # save the file and repeat to your liking. # Once you are happy with it: >_ funcsave fish_prompt fish_right_prompt <> fish_mode_prompt <> . [I] (WHY DOES MY PROMPT SHOW A [I]?) fish_mode_prompt <> . fish_vi_key_bindings vi . vi . fish_mode_prompt funced <> . (HOW DO I CUSTOMIZE MY SYNTAX HIGHLIGHTING COLORS?) fish_config <> fish_color <#variables-color> fish_config theme <> : > fish_config theme show # to demonstrate all the colorschemes > fish_config theme choose coolbeans # to load the "coolbeans" theme (HOW DO I CHANGE THE GREETING MESSAGE?) fish_greeting fish_greeting <> . : set -U fish_greeting : set -g fish_greeting config.fish <#configuration>. (HOW DO I RUN A COMMAND FROM HISTORY?) (^) (v) ctrl-r (pager) . ctrl-r ctrl-s . ctrl-p () ctrl-n () . <#history-search> . ( . . : . sudo !! . alt-s sudo ( sudo ). : o (up) !! . o . . "!vi" "!?bar.c" . ctrl-r . o alt-up . "!$" . <#editor> . (Abbreviations) <#abbreviations> . !! : function last_history_item; echo $history[1]; end abbr -a !! --position anywhere --function last_history_item !! . config.fish <#configuration> . ! (HOW DO I RUN A SUBCOMMAND? THE BACKTICK DOESN'T WORK!) fish . : for i in (ls) echo $i end $() . (backtick) POSIX ('') . ( pkg-config) (MY COMMAND (PKG-CONFIG) GIVES ITS OUTPUT AS A SINGLE LONG STRING?) (newline) $IFS. : count (printf '%s ' a b c) 1 "a b c " . : count (printf '%s\n' a b c) 3 "a" "b" "c" count . . pkg-config . string split -n " " : g++ example_01.cpp (pkg-config --cflags --libs gtk+-2.0 | string split -n " ") -n POSIX . (Exit Status) (HOW DO I GET THE EXIT STATUS OF A COMMAND?) $status . $? . somecommand if test $status -eq 7 echo "That's my lucky number!" end if : if somecommand echo "Command succeeded" else echo "Command failed" end and or : somecommand or someothercommand <#syntax-conditional> test <> if <> . : (wildcard) <#quotes> (escape) <#escapes> : scp user@ip:/dir/"string-*" * <#expand-wildcard> . . : > echo *this*does*not*exist fish: No matches for wildcard '*this*does*not*exist'. See `help expand`. echo *this*does*not*exist ^ bash . : scp user@ip:/dir/string-* apt install postgres-* string-* . bash : for f in ./*.mpg; do # We need to test if the file really exists because # the wildcard might have failed to match. test -f "$f" || continue mympgviewer "$f" done ( ) . "failglob" bash . SSH/SCP/RSYNC (WHY WON'T SSH/SCP/RSYNC CONNECT PROPERLY WHEN FISH IS MY LOGIN SHELL?) "Received message too long" "open terminal failed: not a terminal" "Bad packet length" "Connection refused" ssh_exchange_identification . <#configuration> (~/.config/fish/config.fish) . config.fish ssh/scp/rsync . config.fish status is-interactive ( status is-login) : if status is-interactive ... end tmux config.fish sessions should be nested with care, unset $TMUX to force . ( ...) (I'M GETTING WEIRD GRAPHICAL GLITCHES (A STAIRCASE EFFECT, GHOST CHARACTERS, CURSOR IN THE WRONG POSITION,...)?) . . . : o - . o - . o <<>> (ambiguous) X Y . $fish_ambiguous_width . o (emoji) . $fish_emoji_width 1 . : o ( Non-monospace) - . o - . (FISH DOES NOT WORK IN A SPECIFIC TERMINAL) <> . . (UNINSTALLING FISH) . chsh -s /bin/bash . . usr/local/ : rm -Rf /usr/local/etc/fish /usr/local/share/fish ~/.config/fish rm /usr/local/share/man/man1/fish*.1 cd /usr/local/bin rm -f fish fish_indent (AUTHOR) fish (COPYRIGHT) fish 4.9 September 7, 2026 FISH-FAQ(1)