Skip to content

Instantly share code, notes, and snippets.

@bendog
Last active August 27, 2025 04:07
Show Gist options
  • Save bendog/b55df6d90385e7dd475b12fbb0b1024f to your computer and use it in GitHub Desktop.
Save bendog/b55df6d90385e7dd475b12fbb0b1024f to your computer and use it in GitHub Desktop.

Revisions

  1. bendog revised this gist Jun 9, 2025. 1 changed file with 16 additions and 0 deletions.
    16 changes: 16 additions & 0 deletions apple_macos_install_and_setup_zsh.md
    Original file line number Diff line number Diff line change
    @@ -103,6 +103,22 @@ HISTSIZE=1000000
    SAVEHIST=$HISTSIZE
    ```

    ### ZSH editor defaults

    Sick of having to remember the `:q!` command to get out of vim? change your default editor!

    ```shell

    # Preferred editor for local and remote sessions
    if [[ -n $SSH_CONNECTION ]]; then
    # If we're in an SSH session, use nano
    export EDITOR='nano'
    else
    # If we're not in an SSH session, use code
    export EDITOR='code --wait'
    fi
    ```
    ### When ready

    Reopen your terminal, now you should be able to use the auto suggestions and syntax highlighting.

  2. bendog revised this gist Jun 9, 2025. 1 changed file with 19 additions and 2 deletions.
    21 changes: 19 additions & 2 deletions apple_macos_install_and_setup_zsh.md
    Original file line number Diff line number Diff line change
    @@ -69,14 +69,16 @@ if for some reason you need to re-run your config, you can use this command.

    ## additional zsh tools

    Download zsh-autosuggestions :
    ### Download zsh-autosuggestions :

    git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions

    Download zsh-syntax-higlighting :
    ### Download zsh-syntax-higlighting :

    git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

    ### Oh-my-zsh plugins

    Edit `~/.zshrc` file, find plugins=(git) replace plugins=(git) with :

    ```shell
    @@ -89,4 +91,19 @@ plugins=(
    )
    ```

    ### ZSH History file length maxium uplift

    Set the history size of your file to be larger than the default 50k lines/

    Find the history section in your ~/.zshrc file and add teh HISTSIZE and SAVEHIST values as below.

    ```shell
    # HIST_STAMPS="mm/dd/yyyy"
    HISTSIZE=1000000
    SAVEHIST=$HISTSIZE
    ```


    Reopen your terminal, now you should be able to use the auto suggestions and syntax highlighting.


  3. bendog revised this gist May 30, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion setup_homebrew_extra.md
    Original file line number Diff line number Diff line change
    @@ -26,5 +26,5 @@ glab alias set view 'repo view -w'

    Add gl alias for glab
    ```bash
    echo "alias gl='glab'" >> $HOME/.aliases
    echo "\nalias gl='glab'\n" >> $HOME/.aliases
    ```
  4. bendog revised this gist May 30, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion setup_homebrew_extra.md
    Original file line number Diff line number Diff line change
    @@ -26,5 +26,5 @@ glab alias set view 'repo view -w'

    Add gl alias for glab
    ```bash
    echo "alias gl='glab'" >> ~/.aliases
    echo "alias gl='glab'" >> $HOME/.aliases
    ```
  5. bendog revised this gist May 30, 2025. 1 changed file with 22 additions and 1 deletion.
    23 changes: 22 additions & 1 deletion setup_homebrew_extra.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,30 @@
    # Extra tools from homebrew

    some extra tooling which would be good from homebrew
    ## some extra tooling which would be good from homebrew

    brew install aws-cdk aws-sam-cli awscli bat black cmake \
    diceware eksctl gh glab httpie iredis isort jq k9s kubernetes-cli \
    make openssl pgcli pillow pipx pre-commit rename ruff telnet \
    terraform terraform-docs tflint tfsec thefuck trivy vite watch yarn


    ## congifure git helper apps

    ### GitHub CLI

    ```bash
    gh auth login
    gh alias set view 'repo view --web'
    ```

    ### GitLab CLI

    ```bash
    glab auth login
    glab alias set view 'repo view -w'
    ```

    Add gl alias for glab
    ```bash
    echo "alias gl='glab'" >> ~/.aliases
    ```
  6. bendog revised this gist May 22, 2025. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions setup_aliases.md
    Original file line number Diff line number Diff line change
    @@ -129,4 +129,6 @@ function git_remote_bulk_rename() {

    alias git-prune='git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d'

    alias git-fetch-all-branches='for remote in `git branch -r`; do git branch --track ${remote#origin/} $remote; done'

    ```
  7. bendog revised this gist May 22, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion apple_macos_install_and_setup_zsh.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # setting up zsh
    # setting up a Mac with zsh

    ## install HomeBrew for Mac

  8. bendog renamed this gist May 20, 2025. 1 changed file with 0 additions and 0 deletions.
  9. bendog revised this gist May 7, 2025. 1 changed file with 9 additions and 2 deletions.
    11 changes: 9 additions & 2 deletions setup_aliases.md
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,6 @@ fi
    edit the ~/.aliases file with `code ~/.aliases` and add these lines

    ```shell

    # enable color support of ls and also add handy aliases
    if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    @@ -40,8 +39,14 @@ alias ls="lsd"
    alias ll='ls -alF'
    alias la='ls -A'
    alias l='ls -CF'

    # Use eza for tree
    alias tree='eza --tree --long'

    # use bat for help docs
    alias -g -- -h='-h 2>&1 | bat --language=help --style=plain'
    alias -g -- --help='--help 2>&1 | bat --language=help --style=plain'

    # mac DNS flush
    alias flushdnscache='sudo killall -HUP mDNSResponder; sleep 1; echo "macOS DNS Cache Reset"'

    @@ -62,7 +67,7 @@ function docker_rm_images() {
    docker rmi $2 $(docker image ls | grep $1 | awk '{print $3}' )
    }

    PROJECT_DIR="$HOME/Projects"
    export PROJECT_DIR="$HOME/Projects"

    function project() {
    local sub_dir="$1"
    @@ -85,6 +90,8 @@ function project() {
    cd "$dir"
    }

    alias pj='project'

    # Git Tools

    alias gs='git status'
  10. bendog revised this gist Mar 17, 2025. 2 changed files with 2 additions and 1 deletion.
    File renamed without changes.
    3 changes: 2 additions & 1 deletion setup_aliases.md
    Original file line number Diff line number Diff line change
    @@ -62,10 +62,11 @@ function docker_rm_images() {
    docker rmi $2 $(docker image ls | grep $1 | awk '{print $3}' )
    }

    PROJECT_DIR="$HOME/Projects"

    function project() {
    local sub_dir="$1"
    local dir="$HOME/projects/${sub_dir}"
    local dir="$PROJECT_DIR/${sub_dir}"
    echo "$dir"
    if [[ ! -e "$dir" ]]
    then
  11. bendog revised this gist Mar 6, 2025. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion setup_homebrew_extra.md
    Original file line number Diff line number Diff line change
    @@ -2,5 +2,8 @@

    some extra tooling which would be good from homebrew

    $ brew install aws-cdk aws-sam-cli awscli bat black cmake diceware eksctl gh glab httpie iredis isort jq k9s kubernetes-cli make openssl pgcli pillow pipx pre-commit rename ruff telnet terraform terraform-docs tflint tfsec thefuck trivy vite watch yarn
    brew install aws-cdk aws-sam-cli awscli bat black cmake \
    diceware eksctl gh glab httpie iredis isort jq k9s kubernetes-cli \
    make openssl pgcli pillow pipx pre-commit rename ruff telnet \
    terraform terraform-docs tflint tfsec thefuck trivy vite watch yarn

  12. bendog revised this gist Mar 6, 2025. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion setup_homebrew_extra.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,6 @@
    # Extra tools from homebrew

    some extra tooling which would be good from homebrew

    $ brew install aws-cdk aws-sam-cli awscli bat black cmake diceware eksctl gh glab httpie iredis isort jq k9s kubernetes-cli make openssl pgcli pillow pipx pre-commit rename ruff telnet terraform terraform-docs tflint tfsec thefuck trivy vite watch yarn
    $ brew install aws-cdk aws-sam-cli awscli bat black cmake diceware eksctl gh glab httpie iredis isort jq k9s kubernetes-cli make openssl pgcli pillow pipx pre-commit rename ruff telnet terraform terraform-docs tflint tfsec thefuck trivy vite watch yarn

  13. bendog revised this gist Mar 6, 2025. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions setup_homebrew_extra.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    some extra tooling which would be good from homebrew

    $ brew install aws-cdk aws-sam-cli awscli bat black cmake diceware eksctl gh glab httpie iredis isort jq k9s kubernetes-cli make openssl pgcli pillow pipx pre-commit rename ruff telnet terraform terraform-docs tflint tfsec thefuck trivy vite watch yarn

  14. bendog revised this gist Mar 6, 2025. 2 changed files with 9 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions python.md
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,12 @@
    commands for installing python
    # Setup Python

    ## commands for installing python

    brew install python
    brew install pyenv
    brew install uv poetry

    confirm uv and poetry
    ## confirm uv and poetry

    $ uv --version
    uv 0.6.4 (Homebrew 2025-03-03)
    @@ -18,7 +20,7 @@ confirm uv and poetry
    $ which poetry
    /opt/homebrew/bin/poetry

    add pyenv settings to ~/.zprofile
    ## add pyenv settings to ~/.zprofile

    ```shell
    cat <<'EOF' >> ~/.zprofile
    @@ -34,6 +36,8 @@ then run source on that file

    source ~/.zprofile

    ## update zsh plugins

    edit `~/.zshrc` and add **pyenv** and **pipenv** to the plugins

    ```shell
    2 changes: 2 additions & 0 deletions setup_git.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # Setup Git

    ## install new git tools

    ```shell
  15. bendog revised this gist Mar 6, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion setup_git.md
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ git config --global core.excludesFile ~/.gitignore
    ## add git lg alias for better git log

    ```shell
    cat <<EOF >> ~/.gitconfig
    cat <<'EOF' >> ~/.gitconfig
    [alias]
    lg = lg1
    lg1 = lg1-specific --all
  16. bendog revised this gist Mar 6, 2025. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions python.md
    Original file line number Diff line number Diff line change
    @@ -22,9 +22,11 @@ add pyenv settings to ~/.zprofile

    ```shell
    cat <<'EOF' >> ~/.zprofile
    # PyEnv settings
    export PYENV_ROOT="$HOME/.pyenv"
    export PATH="$PYENV_ROOT/bin:$PATH"
    eval "$(pyenv init --path)"
    # end of PyEnv settings
    EOF
    ```

  17. bendog revised this gist Mar 6, 2025. 2 changed files with 3 additions and 1 deletion.
    2 changes: 1 addition & 1 deletion python.md
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,7 @@ confirm uv and poetry
    add pyenv settings to ~/.zprofile

    ```shell
    cat <<EOF >> ~/.zprofile
    cat <<'EOF' >> ~/.zprofile
    export PYENV_ROOT="$HOME/.pyenv"
    export PATH="$PYENV_ROOT/bin:$PATH"
    eval "$(pyenv init --path)"
    2 changes: 2 additions & 0 deletions setup_aliases.md
    Original file line number Diff line number Diff line change
    @@ -86,6 +86,8 @@ function project() {

    # Git Tools

    alias gs='git status'

    # git remote rename
    function git_remote_rename() {
    local remote="$1"
  18. bendog revised this gist Mar 6, 2025. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions python.md
    Original file line number Diff line number Diff line change
    @@ -27,6 +27,10 @@ export PATH="$PYENV_ROOT/bin:$PATH"
    eval "$(pyenv init --path)"
    EOF
    ```

    then run source on that file

    source ~/.zprofile

    edit `~/.zshrc` and add **pyenv** and **pipenv** to the plugins

  19. bendog revised this gist Mar 6, 2025. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions python.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,22 @@
    commands for installing python

    brew install python
    brew install pyenv
    brew install uv poetry

    confirm uv and poetry

    $ uv --version
    uv 0.6.4 (Homebrew 2025-03-03)

    $ which uv
    /opt/homebrew/bin/uv

    $ poetry --version
    Poetry (version 2.1.1)

    $ which poetry
    /opt/homebrew/bin/poetry

    add pyenv settings to ~/.zprofile

  20. bendog revised this gist Mar 6, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install_zsh.md
    Original file line number Diff line number Diff line change
    @@ -44,7 +44,7 @@ Examples can be found here https://www.nerdfonts.com/font-downloads

    **Note: You may need to restart your mac for these fonts to show up**

    **$${\color(red)WARNING}$$: In your Mac Terminal app, make sure you use a nerd font as your font of choice before you continue**
    **WARNING: In your Mac Terminal app, make sure you use a nerd font as your font of choice before you continue**


    ## install PowerLevel10k
  21. bendog revised this gist Mar 6, 2025. 1 changed file with 6 additions and 42 deletions.
    48 changes: 6 additions & 42 deletions install_zsh.md
    Original file line number Diff line number Diff line change
    @@ -31,57 +31,21 @@ close and reopen the terminal
    ## install and setup oh-my-zsh

    sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

    <!-- ## install powerline fonts (skip this if you plan to use powerlevel9k)
    mkdir ~/fonts
    cd ~/fonts
    git clone https://github.com/powerline/fonts.git
    cd fonts
    ./install.sh
    cd ..
    git clone https://github.com/abertsch/Menlo-for-Powerline.git
    cd Menlo-for-Powerline
    cp *.ttf ~/Library/Fonts -->

    <!-- ## set zsh theme
    with `code ~/.zshrc`
    ```shell
    ZSH_THEME="agnoster"
    ``` -->

    ## install nerd fonts

    **Note: these have moved**

    brew tap homebrew/cask-fonts
    brew install --force $( brew search font | grep nerd | tr '\n' ' ' )
    I use the example of Meslo Nerd Font, feel free to install one you prefer.

    *Try using just the nerd fonts you actually want*
    Examples can be found here https://www.nerdfonts.com/font-downloads

    brew install font-meslo-lg-nerd-font
    brew search nerd-font
    # select your fond from that list and install
    brew install --cask font-meslo-lg-nerd-font

    **Note: You may need to restart your mac for these fonts to show up**

    <!-- ## install powerlevel9k - OBSOLETE use powerlevel10k
    **$${\color(red)WARNING}$$: In your Mac Terminal app, make sure you use a nerd font as your font of choice before you continue**

    git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
    update the config `code ~/.zshrc` and change the theme
    ```
    POWERLEVEL9K_MODE="nerdfont-complete"
    ZSH_THEME="powerlevel9k/powerlevel9k"
    POWERLEVEL9K_COLOR_SCHEME='dark'
    POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(virtualenv context dir_writable dir vcs)
    POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs aws time)
    POWERLEVEL9K_VIRTUALENV_FOREGROUND="lightgoldenrod1"
    POWERLEVEL9K_VIRTUALENV_BACKGROUND="deepskyblue4"
    POWERLEVEL9K_NVM_FOREGROUND="white"
    POWERLEVEL9K_NVM_BACKGROUND="darkgreen"
    P9K_VCS_HIDE_STASHES=true
    ```
    -->

    ## install PowerLevel10k

  22. bendog revised this gist Mar 4, 2025. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions python.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    commands for installing python

    brew install pyenv
    brew install pipenv
    brew install uv poetry

    add pyenv settings to ~/.zprofile

    @@ -20,8 +20,8 @@ plugins=(
    # autoswitch_virtualenv
    aws
    git
    pipenv
    pyenv
    uv
    zsh-autosuggestions
    zsh-syntax-highlighting
    )
  23. bendog revised this gist Mar 4, 2025. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions install_zsh.md
    Original file line number Diff line number Diff line change
    @@ -14,9 +14,11 @@ if this is zsh go to the next stage, if not check zsh is installed

    which zsh

    if this **is found** go to install oh-my-zsh
    ### if zsh **is found**

    if this is **not found**, install with brew following the steps below
    go to install oh-my-zsh

    ### if zsh is **not found**, install with brew following the steps below

    brew install zsh

  24. bendog revised this gist Nov 7, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install_zsh.md
    Original file line number Diff line number Diff line change
    @@ -95,7 +95,7 @@ ZSH_THEME="powerlevel10k/powerlevel10k"

    then run

    source ~/zshrc
    source ~/.zshrc

    if for some reason you need to re-run your config, you can use this command.

  25. bendog revised this gist Nov 5, 2024. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions setup_git.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,9 @@
    ## install new git tools

    ```shell
    brew install difftastic
    ```

    ## ignore all .DS_Store files

    ```shell
    @@ -18,5 +24,7 @@ cat <<EOF >> ~/.gitconfig
    lg1-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
    lg2-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(auto)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
    lg3-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'
    [diff]
    external = difft
    EOF
    ```
  26. bendog revised this gist Nov 5, 2024. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions setup_aliases.md
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    #### install fancy helper tools for aliases

    ```shell
    brew install lsd exa
    brew install lsd eza
    ```

    #### enable .aliases file
    @@ -40,7 +40,7 @@ alias ls="lsd"
    alias ll='ls -alF'
    alias la='ls -A'
    alias l='ls -CF'
    alias tree='exa --tree --long'
    alias tree='eza --tree --long'

    # mac DNS flush
    alias flushdnscache='sudo killall -HUP mDNSResponder; sleep 1; echo "macOS DNS Cache Reset"'
  27. bendog revised this gist Oct 4, 2024. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions install_zsh.md
    Original file line number Diff line number Diff line change
    @@ -51,9 +51,15 @@ ZSH_THEME="agnoster"

    ## install nerd fonts

    **Note: these have moved**

    brew tap homebrew/cask-fonts
    brew install --force $( brew search font | grep nerd | tr '\n' ' ' )

    *Try using just the nerd fonts you actually want*

    brew install font-meslo-lg-nerd-font

    **Note: You may need to restart your mac for these fonts to show up**

    <!-- ## install powerlevel9k - OBSOLETE use powerlevel10k
  28. bendog revised this gist Nov 30, 2023. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion install_zsh.md
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,8 @@

    go to <https://brew.sh>

    **Note: Be sure to run the commands which brew tells you to run at the end of your brew install!**

    ## install and setup zsh

    echo $SHELL
    @@ -52,6 +54,8 @@ ZSH_THEME="agnoster"
    brew tap homebrew/cask-fonts
    brew install --force $( brew search font | grep nerd | tr '\n' ' ' )

    **Note: You may need to restart your mac for these fonts to show up**

    <!-- ## install powerlevel9k - OBSOLETE use powerlevel10k
    git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
    @@ -83,7 +87,11 @@ Now, edit the ZSH_THEME in ~/.zshrc file into :
    ZSH_THEME="powerlevel10k/powerlevel10k"
    ```

    then run p10 configure
    then run

    source ~/zshrc

    if for some reason you need to re-run your config, you can use this command.

    p10k configure

  29. bendog revised this gist Oct 16, 2023. 2 changed files with 0 additions and 0 deletions.
    File renamed without changes.
    File renamed without changes.
  30. bendog revised this gist Oct 16, 2023. 3 changed files with 144 additions and 136 deletions.
    136 changes: 0 additions & 136 deletions install_zsh.md
    Original file line number Diff line number Diff line change
    @@ -110,139 +110,3 @@ plugins=(
    ```

    Reopen your terminal, now you should be able to use the auto suggestions and syntax highlighting.

    ## Aliases

    #### install fancy helper tools for aliases

    ```shell
    brew install lsd exa
    ```

    #### enable .aliases file

    add this line to `~/.zshrc` under the aliases section

    ```shell
    if [ -f ~/.aliases ]; then
    source $HOME/.aliases
    fi
    ```

    #### add the aliases to the .aliases file

    edit the ~/.aliases file with `code ~/.aliases` and add these lines

    ```shell

    # enable color support of ls and also add handy aliases
    if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
    fi
    # some more ls aliases
    alias ls="lsd"
    alias ll='ls -alF'
    alias la='ls -A'
    alias l='ls -CF'
    alias tree='exa --tree --long'

    # mac DNS flush
    alias flushdnscache='sudo killall -HUP mDNSResponder; sleep 1; echo "macOS DNS Cache Reset"'

    alias randompw='openssl rand -base64 8 |md5 |head -c32;echo'

    alias tf='terraform'


    function ports() {
    netstat -Watnlv | grep LISTEN | awk '{"ps -o comm= -p " $9 | getline procname;colred="\033[01;31m";colclr="\033[0m"; print colred "proto: " colclr $1 colred " | addr.port: " colclr $4 colred " | pid: " colclr $9 colred " | name: " colclr procname; }' | column -t -s "|"
    }

    whoseport() {
    lsof -i ":$1" | grep LISTEN
    }

    function docker_rm_images() {
    docker rmi $2 $(docker image ls | grep $1 | awk '{print $3}' )
    }


    function project() {
    local sub_dir="$1"
    local dir="$HOME/projects/${sub_dir}"
    echo "$dir"
    if [[ ! -e "$dir" ]]
    then
    # if dir doesn't exist prompt to create one
    echo "Doesn't exist, create a new one? [y/N] "
    read confirm
    if [[ ! "$confirm" =~ ^[Yy] ]]
    then
    echo "exit"
    [[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 # handle exits from shell or function but don't exit interactive shell
    else
    echo "creating ${dir}"
    mkdir -p "$dir";
    fi
    fi
    cd "$dir"
    }

    # Git Tools

    # git remote rename
    function git_remote_rename() {
    local remote="$1"
    local oldname="$2"
    local newname="$3"
    echo "$remote:$oldname -> $remote:$newname"
    if git ls-remote --heads "$remote" \
    | cut -f2 \
    | sed 's:refs/heads/::' \
    | grep -q ^"$newname"$; then
    echo "Error: $newname already exists"
    exit 1
    fi
    git push "${remote}" "${remote}/${oldname}:refs/heads/${newname}" ":${oldname}"
    }

    function git_remote_bulk_rename() {
    # usage: git_remote_bulk_rename origin CR feature/
    # result: origin:CR-2135 -> origin:feature/CR-2135
    local remote="$1"
    local prefix = "$2"
    local newprefix = "$3"
    echo "${remote}:${prefix}... -> ${remote}:${newprefix}${prefix}..."
    git ls-remote --heads origin \
    | cut -f2 | sed 's:refs/heads/::' \
    | grep ^"${prefix}.*"$ \
    | while read line ; do \
    git_remote_rename "${remote}" "${line}" "${newprefix}${line}" ; \
    done
    }

    alias git-prune='git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d'

    ```

    ## add git lg alias for better git log
    ```shell
    cat <<EOF >> ~/.gitconfig
    [alias]
    lg = lg1
    lg1 = lg1-specific --all
    lg2 = lg2-specific --all
    lg3 = lg3-specific --all
    lg1-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
    lg2-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(auto)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
    lg3-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'
    EOF
    ```
    122 changes: 122 additions & 0 deletions setup .aliases
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,122 @@
    # Aliases

    **Do these in a new terminal window**

    #### install fancy helper tools for aliases

    ```shell
    brew install lsd exa
    ```

    #### enable .aliases file

    add this line to `~/.zshrc` under the aliases section

    ```shell
    if [ -f ~/.aliases ]; then
    source $HOME/.aliases
    fi
    ```

    #### add the aliases to the .aliases file

    edit the ~/.aliases file with `code ~/.aliases` and add these lines

    ```shell

    # enable color support of ls and also add handy aliases
    if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
    fi
    # some more ls aliases
    alias ls="lsd"
    alias ll='ls -alF'
    alias la='ls -A'
    alias l='ls -CF'
    alias tree='exa --tree --long'

    # mac DNS flush
    alias flushdnscache='sudo killall -HUP mDNSResponder; sleep 1; echo "macOS DNS Cache Reset"'

    alias randompw='openssl rand -base64 8 |md5 |head -c32;echo'

    alias tf='terraform'


    function ports() {
    netstat -Watnlv | grep LISTEN | awk '{"ps -o comm= -p " $9 | getline procname;colred="\033[01;31m";colclr="\033[0m"; print colred "proto: " colclr $1 colred " | addr.port: " colclr $4 colred " | pid: " colclr $9 colred " | name: " colclr procname; }' | column -t -s "|"
    }

    whoseport() {
    lsof -i ":$1" | grep LISTEN
    }

    function docker_rm_images() {
    docker rmi $2 $(docker image ls | grep $1 | awk '{print $3}' )
    }


    function project() {
    local sub_dir="$1"
    local dir="$HOME/projects/${sub_dir}"
    echo "$dir"
    if [[ ! -e "$dir" ]]
    then
    # if dir doesn't exist prompt to create one
    echo "Doesn't exist, create a new one? [y/N] "
    read confirm
    if [[ ! "$confirm" =~ ^[Yy] ]]
    then
    echo "exit"
    [[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 # handle exits from shell or function but don't exit interactive shell
    else
    echo "creating ${dir}"
    mkdir -p "$dir";
    fi
    fi
    cd "$dir"
    }

    # Git Tools

    # git remote rename
    function git_remote_rename() {
    local remote="$1"
    local oldname="$2"
    local newname="$3"
    echo "$remote:$oldname -> $remote:$newname"
    if git ls-remote --heads "$remote" \
    | cut -f2 \
    | sed 's:refs/heads/::' \
    | grep -q ^"$newname"$; then
    echo "Error: $newname already exists"
    exit 1
    fi
    git push "${remote}" "${remote}/${oldname}:refs/heads/${newname}" ":${oldname}"
    }

    function git_remote_bulk_rename() {
    # usage: git_remote_bulk_rename origin CR feature/
    # result: origin:CR-2135 -> origin:feature/CR-2135
    local remote="$1"
    local prefix = "$2"
    local newprefix = "$3"
    echo "${remote}:${prefix}... -> ${remote}:${newprefix}${prefix}..."
    git ls-remote --heads origin \
    | cut -f2 | sed 's:refs/heads/::' \
    | grep ^"${prefix}.*"$ \
    | while read line ; do \
    git_remote_rename "${remote}" "${line}" "${newprefix}${line}" ; \
    done
    }

    alias git-prune='git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d'

    ```
    22 changes: 22 additions & 0 deletions setup git
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    ## ignore all .DS_Store files

    ```shell
    echo ".DS_Store" >> ~/.gitignore
    git config --global core.excludesFile ~/.gitignore
    ```

    ## add git lg alias for better git log

    ```shell
    cat <<EOF >> ~/.gitconfig
    [alias]
    lg = lg1
    lg1 = lg1-specific --all
    lg2 = lg2-specific --all
    lg3 = lg3-specific --all

    lg1-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(auto)%d%C(reset)'
    lg2-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(auto)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
    lg3-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'
    EOF
    ```