ZSH Configuration - anil-dewani/dotfiles GitHub Wiki

zsh is a shell designed for interactive use, it also has a powerful scripting language and a plugin eco-system. Many of the useful features of bash, ksh, and tcsh were incorporated into zsh along with many other extra features.

I use zsh as my shell and starship as my shell prompt. They've always worked well together for me.

My ZSH is configured to include following plugins and aliases:

Plugins

Alias shortcuts

# replacement to file-listing commands
alias ls='eza --icons --git -l --all'
alias ld='eza --icons -lD'
alias lf='eza --icons -lF --color=always | grep -v /'
alias lh='eza --icons -dl .* --group-directories-first'
alias ll='eza --icons -al --group-directories-first'
alias lt='eza --icons -al --sort=modified'

# replace cd command with zoxide
alias cd='z'

# neovim it all
alias nano='nvim'
alias vim='nvim'
alias vi='nvim'

# basic utilities
alias home="cd ~"
alias ..="cd .."
alias x="exit"
alias fzf="fzf --ansi"
alias du='ncdu -x'
alias top='btop'
alias htop='btop'
alias ping='gping'
alias cheat='navi'

# custom fzf selectors
alias open="fd --type f --hidden --exclude .git | fzf-tmux -p | xargs nvim"
alias cs='tldr --list | fzf --preview "tldr {1} --color=always" --preview-window=right,70% | xargs tldr'
alias history='history 1 -1 | awk '\''{$1=""; print $0}'\'' | sort | uniq | fzf | xargs -I {} zsh -c '\''read -q "REPLY?Run command: {}? (y/n) " && [[ $REPLY == "y" ]] && {}'\'''

# git alias
alias add="git add"
alias commit="git commit"
alias pull="git pull"
alias stat="git status"
alias gdiff="git diff HEAD"
alias vdiff="git difftool HEAD"
alias log="git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias cfg="git --git-dir=$HOME/dotfiles/ --work-tree=$HOME"
alias push="git push"
alias g="lazygit"
alias gitinfo='onefetch'

# networking 
alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
alias localip="ipconfig getifaddr en0"
alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"

# Show active network interfaces
alias ifactive="ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'"

# Flush Directory Service cache
alias flush="dscacheutil -flushcache && killall -HUP mDNSResponder"

# Lock the screen when going afk
alias afk="pmset displaysleepnow"

# Print each PATH entry on a separate line
alias path='echo -e ${PATH//:/\\n}'

# Put public key on clipboard
alias copyssh="pbcopy < $HOME/.ssh/id_ed25519.pub"

# we all need it sometimes.... 
alias shrug="echo '¯\_(ツ)_/¯' | pbcopy | echo '=> Copied to pasteboard.'"

# perform upgrade system-wide
alias upgrade='topgrade'

# nice colors on your ssh connection
alias ssh="TERM=xterm-256color ssh"
⚠️ **GitHub.com Fallback** ⚠️