fish is a non-POSIX commplient shell which I find to be really good for day to day use.
fisher - plugin manager
# Useful directoriesset -x Dropbox $HOME/Dropboxset -x Projects $Dropbox/Projects
This makes it pretty easy to run commands regardless of the current working directory. Example, to search for all files with
__main__ in projects directory,
rg '__main__' $Projects
Alt+Back - to go back in directory history and
Alt+Right to forward.
Alt+v - to edit command with shell's default editor. This is looked up via the
$EDITOR environment variable.
Alt+b - to go forward adn backward in currently editing command. These are Emacs readline keys which fish prompt support out of the box.
Run in directory
# Mnemonic - Run in Directoryfunction rd --description "run given commands in directory without changing current directory"set dir $argvset --erase argvif test -n "$dir"# Run in a sub shell so that we do not change directory stackfish -c "pushd $direval $argv"endend
This is pretty useful to run a command in a different directory from the one you are currently working in. For example, I use this frequently to check the
git status of the notes directory with -
rd $Notes git status, where
$Notes is a directory alias to the Notes directory. Since the subcommands run in a fish shell, you can use usual conviniences such a abbreviations and aliases. Thus above command can be shortened to,
rd $Notes gs in my configuration.
Create directory and
cd into it,
# From - http://unix.stackexchange.com/questions/125385/combined-mkdir-and-cdfunction mkcd --argument-names 'path'if test -n "$path"mkdir -p -- "$path"; and cd "$path"endend
Find out the ID of the running container for given search term
function container-idset search $argvset --erase argvif test -n "$search"docker ps | grep "$search" | cut -f1 -d' 'endend
Usage example: To find out currently running Postgres instance -