Skip to content

Instantly share code, notes, and snippets.

@unrooted
Created February 28, 2022 20:29
Show Gist options
  • Save unrooted/d72a96aa83d1ee3431d28bb42013627f to your computer and use it in GitHub Desktop.
Save unrooted/d72a96aa83d1ee3431d28bb42013627f to your computer and use it in GitHub Desktop.
zsh config
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:$HOME.local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/home/viper/.oh-my-zsh"
# export Nix
. /home/viper/.nix-profile/etc/profile.d/nix.sh
export NIX_PATH=$HOME/.nix-defexpr/channels${NIX_PATH:+:}$NIX_PATH
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="lambda"
# Uncomment the following line to use case-sensitive completion.
CASE_SENSITIVE="true"
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# Caution: this setting can cause issues with multiline prompts (zsh 5.7.1 and newer seem to work)
# See https://github.com/ohmyzsh/ohmyzsh/issues/5765
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)
source $ZSH/oh-my-zsh.sh
# User configuration
setopt autocd # change directory just by typing its name
#setopt correct # auto correct mistakes
setopt interactivecomments # allow comments in interactive mode
setopt magicequalsubst # enable filename expansion for arguments of the form ‘anything=expression’
setopt nonomatch # hide error message if there is no match for the pattern
setopt notify # report the status of background jobs immediately
setopt numericglobsort # sort filenames numerically when it makes sense
setopt promptsubst # enable command substitution in prompt
WORDCHARS=${WORDCHARS//\/} # Don't consider certain characters part of the word
# hide EOL sign ('%')
PROMPT_EOL_MARK=""
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_GB.UTF-8
# Preferred editor for local and remote sessions
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# enable completion features
autoload -Uz compinit
compinit -d ~/.cache/zcompdump
zstyle ':completion:*:*:*:*:*' menu select
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # case insensitive tab completion
# History configurations
HISTFILE=~/.zsh_history
HISTSIZE=1000
SAVEHIST=2000
setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
setopt hist_ignore_dups # ignore duplicated commands history list
setopt hist_ignore_space # ignore commands that start with space
setopt hist_verify # show command with history expansion to user before running it
#setopt share_history # share command history data
# force zsh to show the complete history
alias history="history 0"
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# enable color support of ls, less and man, and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
# utils
alias c='clear'
alias bc='bc -l'
alias free='free -mt'
alias df='df -H'
alias du='du -ch'
alias sha='shasum -a 256'
alias meminfo='free -m -l -t'
alias psmem='ps auxf | sort -nr -k 4'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'
alias pscpu='ps auxf | sort -nr -k 3'
alias pscpu10='ps auxf | sort -nr -k 3 | head -10'
alias hw='hwinfo --short'
alias cpuinfo='lscpu'
alias update-grub='sudo grub-mkconfig -o /boot/grub/grub.cfg'
alias update-fc='sudo fc-cache -fv'
alias microcode='cat /proc/cpuinfo | grep bugs'
alias microcode-big='grep . /sys/devices/system/cpu/vulnerabilities/*'
alias big='expac -H M '%m\t%n' | sort -h | nl'
alias probe='sudo -E hw-probe -all -upload'
# git
alias gac='git add .; git commit -m'
alias gpo='git push origin'
# docker
# Start the docker-compose stack in the current directory
alias dcu="docker-compose up -d"
# Start the docker-compose stack in the current directory and rebuild the images
alias dcub="docker-compose up -d --build"
# Stop, delete (down) or restart the docker-compose stack in the current directory
alias dcs="docker-compose stop"
alias dcd="docker-compose down"
alias dcr="docker-compose restart"
# Show the logs for the docker-compose stack in the current directory
# May be extended with the service name to get service-specific logs, like
# 'dcl php' to get the logs of the php container
alias dcl="docker-compose logs"
# Quickly run the docker exec command like this: 'dex container-name bash'
alias dex="docker exec -it"
# 'docker ps' displays the currently running containers
alias dps="docker ps"
# This command is a neat shell pipeline to stop all running containers no matter
# where you are and without knowing any container names
alias dsa="docker ps -q | awk '{print $1}' | xargs -o docker stop"
# networking
alias ports='netstat -tulanp'
alias header='curl -I'
alias headerc='curl -I --compress'
alias ping='ping -c 5'
alias wget='wget -c'
# gpg
alias gibson="gpg --encrypt --sign --armor"
alias ungibson="gpg --decrypt"
# file operations
alias mv='mv -i'
alias cp='cp -i'
alias ln='ln -i'
alias chown='chown --preserve-root'
alias chmod='chmod --preserve-root'
alias chgrp='chgrp --preserve-root'
#give the list of all installed desktops - xsessions desktops
alias xd="ls /usr/share/xsessions"
# power
alias ssn="sudo shutdown now"
alias sr="sudo reboot"
# colors & cosmetics
alias pacman='pacman --color=auto'
alias fd='fd --color auto'
alias rg='rg --color auto'
alias mount='mount | column -t'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias diff='diff --color=auto'
alias ip='ip --color=auto'
alias ls='ls --color=auto'
alias ll='ls -l --color=auto'
alias la='ls -A --color=auto'
alias lah='ls -lah --color=auto'
alias lrah='ls -Rlah --color=auto'
alias l='ls -CF --color=auto'
alias diff='colordiff'
alias pactree='pactree -c'
# Youtube-dl
alias yta-aac="youtube-dl -i --extract-audio --audio-format aac "
alias yta-best="youtube-dl -i --extract-audio --audio-format best "
alias yta-flac="youtube-dl -i --extract-audio --audio-format flac "
alias yta-m4a="youtube-dl -i --extract-audio --audio-format m4a "
alias yta-mp3="youtube-dl -i --extract-audio --audio-format mp3 "
alias yta-opus="youtube-dl -i --extract-audio --audio-format opus "
alias yta-vorbis="youtube-dl -i --extract-audio --audio-format vorbis "
alias yta-wav="youtube-dl -i --extract-audio --audio-format wav "
# extractor for all kinds of archives
# usage: extr <file>
extr ()
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1;;
*.7z) 7z x $1 ;;
*.deb) ar x $1 ;;
*.tar.xz) tar xf $1 ;;
*.tar.zst) tar xf $1 ;;
*) echo "'$1' cannot be extracted via extr()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
export LESS_TERMCAP_mb=$'\E[1;31m' # begin blink
export LESS_TERMCAP_md=$'\E[1;36m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink
export LESS_TERMCAP_so=$'\E[01;33m' # begin reverse video
export LESS_TERMCAP_se=$'\E[0m' # reset reverse video
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
export LESS_TERMCAP_ue=$'\E[0m' # reset underline
# Take advantage of $LS_COLORS for completion as well
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
fi
# enable auto-suggestions based on the history
if [ -f /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh ]; then
. /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
# change suggestion color
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#999'
fi
if [ -e /home/viper/.nix-profile/etc/profile.d/nix.sh ]; then . /home/viper/.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment