Fish Shell Snippets
# Open Helphelp
# Open fish shell configuration web interfacefish_config
# Set a promptfish_config prompt choose informative_vcs
# Find value of variableecho My home directory is $HOME
# Set value of variable, the quotes ensure the variable name is one stringset name 'John Doe'echo $name
# Remove variableset -e name
# Export variable to be used by external commandsset -x MyVariable SomeValueenv | grep MyVariable# Note if fish is started by something else, it inherits the environment variables from the parent's exposed variables (e.g. bash)
# Unexport variableset -u MyVariable
# View PATH which can have multiple values and are a listecho $PATH# Get length of a list with the name PATHcount $PATH# Append to a list by setting the list to itselfset PATH $PATH ~/bin# Access individual elements for the listecho $PATH[1]
# Separate commands with ; or new linessudo apt upgrade; sudo apt update
sudo apt upgradesudo apt update
# Search historyhistory search [SEARCH_STRING ...]
# Delete a history containing a specific 'substring'history delete --contains substring# alsohistory delete -c substring
# Print Working Directorypwd
# Navigate to recent directoriescdh
# Move backward in directory historyprevd
# Move forward in directory historynextd
# Combine commands with &&./configure && make && sudo make install# fish also support and, or, and notcp file1 file1_bak && cp file2 file2_bak; and echo "Backup successful"; or echo "Backup failed"
See Also
Section titled “See Also”Resources
Section titled “Resources”Tutorial and interactive use for more:
- if else
- Functions
- while true loops
- fish configuration
- autoloading functions
- Interactive
- Autosuggestions and completions
- Writing your own completions
- Syntax highlighting
- Abbreviations = aliases
- Key bindings and custom keybindings