.zshrc 9.07 KB
Newer Older
destroyer449's avatar
destroyer449 committed
1
#  ____ _____
Derek Taylor's avatar
Derek Taylor committed
2 3
# |  _ \_   _|  Derek Taylor (DistroTube)
# | | | || |    http://www.youtube.com/c/DistroTube
destroyer449's avatar
destroyer449 committed
4 5
# | |_| || |    http://www.gitlab.com/dwt1/
# |____/ |_|
Derek Taylor's avatar
Derek Taylor committed
6
# My zsh config. Not much to see here; just some pretty standard stuff.
Derek Taylor's avatar
Derek Taylor committed
7

Derek Taylor's avatar
Derek Taylor committed
8
### EXPORT
9
export TERM="xterm-256color"                      # getting proper colors
Derek Taylor's avatar
Derek Taylor committed
10
export HISTORY_IGNORE="(ls|cd|pwd|exit|sudo reboot|history|cd -|cd ..)"
11 12 13 14 15 16 17 18 19 20 21 22 23 24
export EDITOR="emacsclient -t -a ''"              # $EDITOR use Emacs in terminal
export VISUAL="emacsclient -c -a emacs"           # $VISUAL use Emacs in GUI mode

### SET MANPAGER
### Uncomment only one of these!

### "bat" as manpager
export MANPAGER="sh -c 'col -bx | bat -l man -p'"

### "vim" as manpager
# export MANPAGER='/bin/bash -c "vim -MRn -c \"set buftype=nofile showtabline=0 ft=man ts=8 nomod nolist norelativenumber nonu noma\" -c \"normal L\" -c \"nmap q :qa<CR>\"</dev/tty <(col -b)"'

### "nvim" as manpager
# export MANPAGER="nvim -c 'set ft=man' -"
25

Derek Taylor's avatar
Derek Taylor committed
26 27 28
### SET VI MODE ###
# Comment this line out to enable default emacs-like bindings
bindkey -v
29

Derek Taylor's avatar
Derek Taylor committed
30 31
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
32

Derek Taylor's avatar
Derek Taylor committed
33 34 35
### PATH
if [ -d "$HOME/.bin" ] ;
  then PATH="$HOME/.bin:$PATH"
Derek Taylor's avatar
Derek Taylor committed
36
fi
37

Derek Taylor's avatar
Derek Taylor committed
38 39 40
if [ -d "$HOME/.local/bin" ] ;
  then PATH="$HOME/.local/bin:$PATH"
fi
41

Derek Taylor's avatar
Derek Taylor committed
42 43 44 45
if [ -d "$HOME/Applications" ] ;
  then PATH="$HOME/Applications:$PATH"
fi

Derek Taylor's avatar
Derek Taylor committed
46 47 48 49 50 51 52 53 54 55
### CHANGE TITLE OF TERMINALS
case ${TERM} in
  xterm*|rxvt*|Eterm*|aterm|kterm|gnome*|alacritty|st|konsole*)
    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\007"'
        ;;
  screen*)
    PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\033\\"'
    ;;
esac

InvisibleRasta's avatar
InvisibleRasta committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
### Function extract for common file formats ###
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")

function extract {
 if [ -z "$1" ]; then
    # display usage if no parameters given
    echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
    echo "       extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
 else
    for n in "$@"
    do
      if [ -f "$n" ] ; then
          case "${n%,}" in
            *.cbt|*.tar.bz2|*.tar.gz|*.tar.xz|*.tbz2|*.tgz|*.txz|*.tar)
                         tar xvf "$n"       ;;
            *.lzma)      unlzma ./"$n"      ;;
            *.bz2)       bunzip2 ./"$n"     ;;
            *.cbr|*.rar)       unrar x -ad ./"$n" ;;
            *.gz)        gunzip ./"$n"      ;;
            *.cbz|*.epub|*.zip)       unzip ./"$n"       ;;
            *.z)         uncompress ./"$n"  ;;
            *.7z|*.arj|*.cab|*.cb7|*.chm|*.deb|*.dmg|*.iso|*.lzh|*.msi|*.pkg|*.rpm|*.udf|*.wim|*.xar)
                         7z x ./"$n"        ;;
            *.xz)        unxz ./"$n"        ;;
            *.exe)       cabextract ./"$n"  ;;
            *.cpio)      cpio -id < ./"$n"  ;;
            *.cba|*.ace)      unace x ./"$n"      ;;
            *)
                         echo "extract: '$n' - unknown archive method"
                         return 1
                         ;;
          esac
      else
          echo "'$n' - file does not exist"
          return 1
      fi
    done
fi
Derek Taylor's avatar
Derek Taylor committed
95 96
}

InvisibleRasta's avatar
InvisibleRasta committed
97 98
IFS=$SAVEIFS

Derek Taylor's avatar
Derek Taylor committed
99
### OH MY ZSH ###
100

Derek Taylor's avatar
Derek Taylor committed
101 102
# Path to your oh-my-zsh installation.
ZSH=$HOME/.oh-my-zsh
103

Derek Taylor's avatar
Derek Taylor committed
104 105
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
106

Derek Taylor's avatar
Derek Taylor committed
107 108 109 110 111
# Which plugins would you like to load?
# Add wisely, as too many plugins slow down shell startup.
# Defning the plugins needs to happen before sourcing oh-my-zsh.
plugins=(command-not-found
         emacs
destroyer449's avatar
destroyer449 committed
112
         git
Derek Taylor's avatar
Derek Taylor committed
113 114 115 116 117
         history
         zsh-interactive-cd)

# Sourcing oh-my-zsh
# Your plugins will not work without this source.
118
source $ZSH/oh-my-zsh.sh
Derek Taylor's avatar
Derek Taylor committed
119

destroyer449's avatar
destroyer449 committed
120
### ALIASES ###
121 122 123 124 125

# root privileges
alias doas="doas --"

# navigation
Derek Taylor's avatar
Derek Taylor committed
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
up () {
  local d=""
  local limit="$1"

  # Default to limit of 1
  if [ -z "$limit" ] || [ "$limit" -le 0 ]; then
    limit=1
  fi

  for ((i=1;i<=limit;i++)); do
    d="../$d"
  done

  # perform cd. Show error if cd fails
  if ! cd "$d"; then
    echo "Couldn't go up $limit dirs.";
  fi
}
Derek Taylor's avatar
Derek Taylor committed
144 145 146 147 148 149 150 151 152

# vim and emacs
alias vim="nvim"
alias em="/usr/bin/emacs -nw"
alias emacs="emacsclient -c -a 'emacs'"
alias doomsync="~/.emacs.d/bin/doom sync"
alias doomdoctor="~/.emacs.d/bin/doom doctor"
alias doomupgrade="~/.emacs.d/bin/doom upgrade"
alias doompurge="~/.emacs.d/bin/doom purge"
153 154
# bat
# alias cat='bat'
Derek Taylor's avatar
Derek Taylor committed
155

156 157 158
# broot
alias br='broot -dhp'
alias bs='broot --sizes'
159

Derek Taylor's avatar
Derek Taylor committed
160 161 162 163 164
# Changing "ls" to "exa"
alias ls='exa -al --color=always --group-directories-first' # my preferred listing
alias la='exa -a --color=always --group-directories-first'  # all files and dirs
alias ll='exa -l --color=always --group-directories-first'  # long format
alias lt='exa -aT --color=always --group-directories-first' # tree listing
Derek Taylor's avatar
Derek Taylor committed
165 166
alias l.='exa -a | egrep "^\."'

167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
# pacman and yay
alias pacsyu='sudo pacman -Syyu'                 # update only standard pkgs
alias yaysua='yay -Sua --noconfirm'              # update only AUR pkgs (yay)
alias yaysyu='yay -Syu --noconfirm'              # update standard pkgs and AUR pkgs (yay)
alias parsua='paru -Sua --noconfirm'             # update only AUR pkgs (paru)
alias parsyu='paru -Syu --noconfirm'             # update standard pkgs and AUR pkgs (paru)
alias unlock='sudo rm /var/lib/pacman/db.lck'    # remove pacman lock
alias cleanup='sudo pacman -Rns (pacman -Qtdq)'  # remove orphaned packages

# get fastest mirrors
alias mirror="sudo reflector -f 30 -l 30 --number 10 --verbose --save /etc/pacman.d/mirrorlist"
alias mirrord="sudo reflector --latest 50 --number 20 --sort delay --save /etc/pacman.d/mirrorlist"
alias mirrors="sudo reflector --latest 50 --number 20 --sort score --save /etc/pacman.d/mirrorlist"
alias mirrora="sudo reflector --latest 50 --number 20 --sort age --save /etc/pacman.d/mirrorlist"

Derek Taylor's avatar
Derek Taylor committed
182 183 184 185 186 187 188 189 190
# Colorize grep output (good for log files)
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'

# confirm before overwriting something
alias cp="cp -i"
alias mv='mv -i'
alias rm='rm -i'
Derek Taylor's avatar
Derek Taylor committed
191

192
# adding flags
Derek Taylor's avatar
Derek Taylor committed
193
alias df='df -h'                          # human-readable sizes
194 195 196
alias free='free -m'                      # show sizes in MB
alias lynx='lynx -cfg=~/.lynx/lynx.cfg -lss=~/.lynx/lynx.lss -vikeys'
alias vifm='./.config/vifm/scripts/vifmrun'
destroyer449's avatar
destroyer449 committed
197
alias ncmpcpp='ncmpcpp ncmpcpp_directory=$HOME/.config/ncmpcpp/'
destroyer449's avatar
destroyer449 committed
198
alias mocp='mocp -M "$XDG_CONFIG_HOME"/moc -O MOCDir="$XDG_CONFIG_HOME"/moc'
Derek Taylor's avatar
Derek Taylor committed
199 200 201 202 203 204 205 206
## get top process eating memory
alias psmem='ps auxf | sort -nr -k 4'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'

## get top process eating cpu ##
alias pscpu='ps auxf | sort -nr -k 3'
alias pscpu10='ps auxf | sort -nr -k 3 | head -10'

207 208 209
# Merge Xresources
alias merge='xrdb -merge ~/.Xresources'

Derek Taylor's avatar
Derek Taylor committed
210 211 212 213 214 215 216 217 218 219
# git
alias addup='git add -u'
alias addall='git add .'
alias branch='git branch'
alias checkout='git checkout'
alias clone='git clone'
alias commit='git commit -m'
alias fetch='git fetch'
alias pull='git pull origin'
alias push='git push origin'
220
alias stat='git status'  # 'status' is protected name so using 'stat' instead
Derek Taylor's avatar
Derek Taylor committed
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
alias tag='git tag'
alias newtag='git tag -a'

# get error messages from journalctl
alias jctl="journalctl -p 3 -xb"

# gpg encryption
# verify signature for isos
alias gpg-check="gpg2 --keyserver-options auto-key-retrieve --verify"
# receive the key of a developer
alias gpg-retrieve="gpg2 --keyserver-options auto-key-retrieve --receive-keys"

# youtube-dl
alias yta-aac="youtube-dl --extract-audio --audio-format aac "
alias yta-best="youtube-dl --extract-audio --audio-format best "
alias yta-flac="youtube-dl --extract-audio --audio-format flac "
alias yta-m4a="youtube-dl --extract-audio --audio-format m4a "
alias yta-mp3="youtube-dl --extract-audio --audio-format mp3 "
alias yta-opus="youtube-dl --extract-audio --audio-format opus "
alias yta-vorbis="youtube-dl --extract-audio --audio-format vorbis "
alias yta-wav="youtube-dl --extract-audio --audio-format wav "
alias ytv-best="youtube-dl -f bestvideo+bestaudio "

# switch between shells
245
# I do not recommend switching default SHELL from bash.
Derek Taylor's avatar
Derek Taylor committed
246 247 248
alias tobash="sudo chsh $USER -s /bin/bash && echo 'Now log out.'"
alias tozsh="sudo chsh $USER -s /bin/zsh && echo 'Now log out.'"
alias tofish="sudo chsh $USER -s /bin/fish && echo 'Now log out.'"
Derek Taylor's avatar
Derek Taylor committed
249

250 251
# bare git repo alias for dotfiles
alias config="/usr/bin/git --git-dir=$HOME/dotfiles --work-tree=$HOME"
Derek Taylor's avatar
Derek Taylor committed
252

253
# termbin
Derek Taylor's avatar
Derek Taylor committed
254
alias tb="nc termbin.com 9999"
Derek Taylor's avatar
Derek Taylor committed
255

Derek Taylor's avatar
Derek Taylor committed
256 257
# the terminal rickroll
alias rr='curl -s -L https://raw.githubusercontent.com/keroserene/rickrollrc/master/roll.sh | bash'
Derek Taylor's avatar
Derek Taylor committed
258

Derek Taylor's avatar
Derek Taylor committed
259 260 261
# Unlock LBRY tips
alias tips='lbrynet txo spend --type=support --is_not_my_input --blocking'

262
# Thinkorswim
263
alias tos="~/thinkorswim/thinkorswim"
264 265 266 267 268 269

# force all kakoune windows into one session
alias kak="/usr/bin/kak -c mysession"
alias kaks="/usr/bin/kak -s mysession"
alias kakd="/usr/bin/kak -d -s mysession &"

Derek Taylor's avatar
Derek Taylor committed
270 271 272 273
### RANDOM COLOR SCRIPT ###
# Get this script from my GitLab: gitlab.com/dwt1/shell-color-scripts
# Or install it from the Arch User Repository: shell-color-scripts
colorscript random
274

Derek Taylor's avatar
Derek Taylor committed
275
### SOURCING BROOT ###
276
source ~/.config/broot/launcher/bash/br
Derek Taylor's avatar
Derek Taylor committed
277

278 279 280 281 282
### BASH INSULTER ###
if [ -f /etc/bash.command-not-found ]; then
    . /etc/bash.command-not-found
fi

Derek Taylor's avatar
Derek Taylor committed
283 284 285 286
### SETTING THE STARSHIP PROMPT ###
eval "$(starship init zsh)"


287