zsh:alias: Refactor
Reorder categories. Remove unused aliases and PATH modification. Refactor to keep lines under the maximum of 80 columns. Use brace expansion where an alias has different names. Simplify method for finding the wise and sose hash.
This commit is contained in:
@@ -1,111 +1,96 @@
|
|||||||
## Author: druckdev
|
## Author: druckdev
|
||||||
## Created: 2019-01-16
|
## Created: 2019-01-16
|
||||||
|
|
||||||
## Add fslint-directory to PATH
|
# Default flags
|
||||||
PATH="${PATH:+${PATH}:}/usr/share/fslint/fslint"
|
alias ls='ls --color=auto --group-directories-first -p -v'
|
||||||
|
alias grep='grep --color'
|
||||||
|
alias cp='cp -i'
|
||||||
|
alias mv='mv -i'
|
||||||
|
alias rm='rm -I'
|
||||||
|
alias less='less -N'
|
||||||
|
alias lsblk='lsblk -f'
|
||||||
|
alias feh='feh -.'
|
||||||
|
|
||||||
## Add flags or shorten commands that I cannot remember
|
# XDG Base Directory Specification
|
||||||
alias getclip="xclip -selection c -o"
|
alias wget='
|
||||||
alias setclip="perl -pe 'chomp if eof' | xclip -selection c"
|
wget --config="${XDG_CONFIG_HOME:-$HOME/.config}/wget/wgetrc" \
|
||||||
alias pdfviewer='evince'
|
--hsts-file="${XDG_DATA_HOME:-$HOME/.local/share}/wget/wget-hsts"
|
||||||
alias pdf='launch evince'
|
'
|
||||||
alias darkpdf='launch zathura'
|
alias tmux='tmux -f "$HOME/.config/tmux/tmux.conf"'
|
||||||
alias geeqie='launch qeeqie'
|
alias tmsu='tmsu -D "${XDG_DATA_HOME:-$HOME/.local/share}/tmsu/db"'
|
||||||
alias grep='grep --color'
|
|
||||||
alias igrep='grep -i'
|
|
||||||
alias emacs-game='emacs -batch -l dunnet'
|
|
||||||
alias trash-restore='restore-trash'
|
|
||||||
alias cp='cp -i'
|
|
||||||
alias mv='mv -i' # --backup=t ??
|
|
||||||
alias rm='rm -I'
|
|
||||||
alias less='less -N'
|
|
||||||
alias lsblk='lsblk -f'
|
|
||||||
alias rd='rmdir'
|
|
||||||
alias md='mkdir -p'
|
|
||||||
alias o='xdg-open'
|
|
||||||
alias p='pwd'
|
|
||||||
alias :q='exit'
|
|
||||||
alias :Q=:q
|
|
||||||
alias update='sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y; [ ! -e /var/run/reboot-required ] || printf "\n\nSystem restart required.\n"'
|
|
||||||
alias pdf2text='pdftotext'
|
|
||||||
alias pdf2txt='pdftotext'
|
|
||||||
alias rm='printf "\033[1;031mUse trash!\n\033[0m"; false'
|
|
||||||
alias battery='upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -E "to full|percentage" | tr -d " " | sed "s/:/: /"'
|
|
||||||
alias qrdecode='zbarimg'
|
|
||||||
alias pdfmerge='pdfunite'
|
|
||||||
alias loadhist='fc -RI'
|
|
||||||
alias wget='wget --config=${XDG_CONFIG_HOME:-$HOME/.config}/wget/wgetrc --hsts-file="${XDG_DATA_HOME:-$HOME/.local/share}/wget/wget-hsts"'
|
|
||||||
alias -g G='| grep '
|
|
||||||
alias -g no2='2>/dev/null'
|
|
||||||
alias hex=xxd
|
|
||||||
alias bin='xxd -b -c4 | cut -d" " -f2-5'
|
|
||||||
if command -v nvim >/dev/null 2>&1; then
|
|
||||||
alias vim=nvim
|
|
||||||
alias vi=nvim
|
|
||||||
fi
|
|
||||||
alias tmux='tmux -f "$HOME/.config/tmux/tmux.conf"'
|
|
||||||
alias resetCursor='echo -ne "\e[5 q"'
|
|
||||||
alias makeThisScratchpad='echo -ne "\033]0;scratchpad-terminal\007"'
|
|
||||||
alias tmsu='tmsu -D "${XDG_DATA_HOME:-$HOME/.local/share}/tmsu/db"'
|
|
||||||
alias grepdate='grep -E "(={8})|([0-9]{4}([: -_][0-9]{2}){5})|([0-9]{8}[ -_][0-9]{6})"'
|
|
||||||
alias feh='feh -.'
|
|
||||||
# 'Temporary' shell in alternate mode that does not mess with the scrollback history
|
|
||||||
alias tmpshell='tput smcup && zsh && tput rmcup'
|
|
||||||
|
|
||||||
## git
|
# Global
|
||||||
alias gs='git status --short' # overrides ghostscript
|
alias -g G='| grep'
|
||||||
alias gits='gs'
|
alias -g no2='2>/dev/null'
|
||||||
alias gstat='gs'
|
|
||||||
alias gitstat='gs'
|
|
||||||
alias ga='git add'
|
|
||||||
alias gaa='git add -A'
|
|
||||||
alias gc="git commit"
|
|
||||||
alias gpsh='git push'
|
|
||||||
alias gpush='git push'
|
|
||||||
alias gpll='git pull'
|
|
||||||
alias gpull='git pull'
|
|
||||||
alias gdiff='git diff'
|
|
||||||
alias gd='git diff'
|
|
||||||
# git-commit, but put the last written commit message into the editor buffer
|
|
||||||
# for editing.
|
|
||||||
# Useful for example when the commit-msg hook fails but only slight
|
|
||||||
# modifications are needed.
|
|
||||||
alias git-commit-last-msg='() {
|
|
||||||
local gitdir="$(git rev-parse --git-dir)" || return
|
|
||||||
git commit -eF <(grep -v "^#" "$gitdir/COMMIT_EDITMSG")
|
|
||||||
}'
|
|
||||||
|
|
||||||
## Navigation
|
# Git
|
||||||
alias ls='ls --color=auto --group-directories-first -p -v'
|
alias gs='git status --short'
|
||||||
alias sl='ls'
|
alias ga='git add'
|
||||||
alias la='ls -A'
|
alias gc="git commit"
|
||||||
alias l='ls -lh --time-style=long-iso'
|
alias gpush='git push'
|
||||||
alias ll='l -A'
|
alias gpull='git pull'
|
||||||
alias cd..='cd ..'
|
alias gd='git diff'
|
||||||
alias cd~='cd ~'
|
# Commit, but put the last written commit message into the editor buffer.
|
||||||
|
# Useful for example when the commit-msg hook fails but only slight
|
||||||
|
# modifications are needed.
|
||||||
|
alias git-commit-last-msg='() {
|
||||||
|
local gitdir="$(git rev-parse --git-dir)" || return
|
||||||
|
git commit -eF <(grep -v "^#" "$gitdir/COMMIT_EDITMSG")
|
||||||
|
}'
|
||||||
|
|
||||||
## Hashes for often visited folders
|
# Save keystrokes and my memory
|
||||||
hash -d Desktop=$HOME/Desktop/
|
alias la="${aliases[ls]:-ls} -A"
|
||||||
hash -d Documents=$HOME/Documents/
|
alias l="${aliases[ls]:-ls} -lh --time-style=long-iso"
|
||||||
hash -d Pictures=$HOME/Pictures/
|
alias ll="${aliases[l]} -A"
|
||||||
hash -d Downloads=$HOME/Downloads/
|
alias cd..='cd ..'
|
||||||
hash -d Projects=$HOME/Projects/
|
alias getclip="xclip -selection c -o"
|
||||||
hash -d dot=~Projects/github/dotfiles-github/
|
alias setclip="perl -pe 'chomp if eof' | xclip -selection c"
|
||||||
hash -d dots=~dot
|
alias pdf='launch evince'
|
||||||
|
alias darkpdf='launch zathura'
|
||||||
|
alias geeqie='launch qeeqie'
|
||||||
|
alias trash-restore='restore-trash'
|
||||||
|
alias rd='rmdir'
|
||||||
|
alias md='mkdir -p'
|
||||||
|
alias o='xdg-open'
|
||||||
|
alias :{q,Q}='exit'
|
||||||
|
alias update='
|
||||||
|
sudo apt update \
|
||||||
|
&& sudo apt upgrade -y \
|
||||||
|
&& sudo apt autoremove -y
|
||||||
|
|
||||||
local UNI="$HOME/Documents/uni"
|
[ ! -e /var/run/reboot-required ] \
|
||||||
hash -d cheat=$HOME/Documents/Cheat\ Sheet/
|
|| printf "\n\nSystem restart required.\n"
|
||||||
hash -d uni=$UNI/
|
'
|
||||||
# hash for current/last wise
|
alias pdf2t{e,}xt='pdftotext'
|
||||||
local YEAR=$(date +"%y")
|
alias rm='printf "\033[1;031mUse trash!\n\033[0m"; false'
|
||||||
if [ -d "$UNI/$YEAR-WiSe" ]; then
|
alias battery='
|
||||||
hash -d wise="$UNI/$YEAR-WiSe/"
|
upower -i /org/freedesktop/UPower/devices/battery_BAT0
|
||||||
elif [ -d "$UNI/$(($YEAR - 1))-WiSe" ]; then
|
| grep -E "to full|percentage"
|
||||||
hash -d wise="$UNI/$(($YEAR - 1))-WiSe/"
|
| tr -d " "
|
||||||
fi
|
| sed "s/:/: /"
|
||||||
# hash for current/last sose
|
'
|
||||||
if [ -d "$UNI/$YEAR-SoSe" ]; then
|
alias qrdecode='zbarimg'
|
||||||
hash -d sose="$UNI/$YEAR-SoSe"/
|
alias loadhist='fc -RI'
|
||||||
elif [ -d "$UNI/$(($YEAR - 1))-SoSe" ]; then
|
alias hex=xxd
|
||||||
hash -d sose="$UNI/$(($YEAR - 1))-SoSe/"
|
alias bin='xxd -b -c4 | cut -d" " -f2-5'
|
||||||
fi
|
! command -v nvim &>/dev/null || alias vim=nvim
|
||||||
|
alias vi="${aliases[vim]:-vim}"
|
||||||
|
alias resetCursor='echo -ne "\e[5 q"'
|
||||||
|
alias makeThisScratchpad='echo -ne "\033]0;scratchpad-terminal\007"'
|
||||||
|
# grep filenames and date entries in exiftool
|
||||||
|
alias grepdate='grep -E "(={8})|([:0-9]{10} [:0-9]{8})"'
|
||||||
|
# 'Temporary' shell in alternate mode for hiding commands in scrollback.
|
||||||
|
alias tmpshell='tput smcup && zsh && tput rmcup'
|
||||||
|
|
||||||
|
# Named directories
|
||||||
|
hash -d docs="$HOME"/Documents/
|
||||||
|
hash -d cheat="${nameddirs[docs]}"/cheat_sheets
|
||||||
|
hash -d proj="$HOME"/Projects/
|
||||||
|
hash -d dot{,s}="${nameddirs[proj]}"/github/dotfiles-github/
|
||||||
|
hash -d pics="$HOME"/Pictures/
|
||||||
|
hash -d down="$HOME"/Downloads/
|
||||||
|
|
||||||
|
hash -d uni="${nameddirs[docs]}"/uni
|
||||||
|
local UNI="${nameddirs[uni]}"
|
||||||
|
hash -d wise="$(printf "%s\n" "$UNI"/[0-9][0-9]-WiSe | tail -1)"
|
||||||
|
hash -d sose="$(printf "%s\n" "$UNI"/[0-9][0-9]-SoSe | tail -1)"
|
||||||
|
|||||||
Reference in New Issue
Block a user