Skip to content

Instantly share code, notes, and snippets.

@ScottGuthart
Created July 9, 2021 14:33
Show Gist options
  • Save ScottGuthart/ed0f41f8bba65cda9f2d073c3f174559 to your computer and use it in GitHub Desktop.
Save ScottGuthart/ed0f41f8bba65cda9f2d073c3f174559 to your computer and use it in GitHub Desktop.

Revisions

  1. ScottGuthart created this gist Jul 9, 2021.
    36 changes: 36 additions & 0 deletions example.zsh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    # You can put files here to add functionality separated per file, which
    # will be ignored by git.
    # Files on the custom/ directory will be automatically loaded by the init
    # script, in alphabetical order.

    # For example: add yourself some shortcuts to projects you often work on.
    #
    # brainstormr=~/Projects/development/planetargon/brainstormr
    # cd $brainstormr
    alias brew='env PATH=${PATH//$(pyenv root)\/shims:/} brew'
    alias cdw='~/workspace'

    # Attach to tmux
    # if command -v tmux &> /dev/null && [ -n "$PS1" ] && [[ ! "$TERM" =~ screen ]] && [[ ! "$TERM" =~ tmux ]] && [ -z "$TMUX" ]; then
    # exec tmux new-session -A -s Default
    # fi

    # fkill - kill processes - list only the ones you can kill. Modified the earlier script.
    fkill() {
    local pid
    if [ "$UID" != "0" ]; then
    pid=$(ps -f -u $UID | sed 1d | fzf -m | awk '{print $2}')
    else
    pid=$(ps -ef | sed 1d | fzf -m | awk '{print $2}')
    fi

    if [ "x$pid" != "x" ]
    then
    echo $pid | xargs kill -${1:-9}
    fi
    }

    # fh - repeat history
    fh() {
    print -z $( ([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s --tac | sed -E 's/ *[0-9]*\*? *//' | sed -E 's/\\/\\\\/g')
    }