fish
​fish is a non-POSIX commplient shell which I find to be really good for day to day use.

Managing fish plugins

    fisher - plugin manager

Miscellaneous tips

    Directory variables
    1
    # Useful directories
    2
    set -x Dropbox $HOME/Dropbox
    3
    set -x Projects $Dropbox/Projects
    Copied!
    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,
    1
    rg '__main__' $Projects
    Copied!
    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+f, Alt+b - to go forward adn backward in currently editing command. These are Emacs readline keys which fish prompt support out of the box.

Useful functions

    Run in directory
    1
    # Mnemonic - Run in Directory
    2
    function rd --description "run given commands in directory without changing current directory"
    3
    set dir $argv[1]
    4
    set --erase argv[1]
    5
    if test -n "$dir"
    6
    # Run in a sub shell so that we do not change directory stack
    7
    fish -c "
    8
    pushd $dir
    9
    eval $argv
    10
    "
    11
    end
    12
    end
    Copied!
    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,
    1
    # From - http://unix.stackexchange.com/questions/125385/combined-mkdir-and-cd
    2
    function mkcd --argument-names 'path'
    3
    if test -n "$path"
    4
    mkdir -p -- "$path"; and cd "$path"
    5
    end
    6
    end
    Copied!
    Find out the ID of the running container for given search term
    1
    function container-id
    2
    set search $argv[1]
    3
    set --erase argv[1]
    4
    if test -n "$search"
    5
    docker ps | grep "$search" | cut -f1 -d' '
    6
    end
    7
    end
    Copied!
    Usage example: To find out currently running Postgres instance - container-id postgres.
Last modified 1yr ago