ambevar-dotfiles/.shell.d/alias_rc

124 lines
4.0 KiB
Bash

## -*- mode:sh -*- #
################################################################################
## Shell Config -- Alias Definitions.
## Warning: if this does not work if you change shell without relogging, use
## 'source .<shell>rc' instead.
if [ "zsh" = "$SHELL_CURRENT" ]; then
alias ssrc='source ~/.zshrc'
fi
##==============================================================================
## General
## 'ls' redefinition
alias ls='ls -F'
## GNU extras.
if [ "$OSTYPE" = "linux-gnu" ]; then
alias ls='ls --color=auto -v --group-directories-first'
else
alias ls='ls -G'
fi
## Listing aliases.
alias l='ls -1'
alias la='ls -lAh' # Hidden files
alias lc='ls -ltcrh' # Sort by change time
alias lk='ls -lSrh' # Sort by size
alias ll='ls -lh' # Detailed view with human readable values.
alias lx='ls -lXh' # Sort by extension
## Misc
alias grep='grep --color=auto'
# List desktop applications.
[ -d /usr/share/applications ] && XDG_APPS=($XDG_APPS /usr/share/applications)
[ -d /usr/local/share/applications ] && XDG_APPS=($XDG_APPS /usr/local/share/applications)
[ ${#XDG_APPS} -ne 0 ] && alias applist='grep -R "^Name=" $XDG_APPS | cut -d'=' -f2 | sort'
## Get your external IP.
command -v curl >/dev/null 2>&1 && alias myip='curl ifconfig.me'
## Prevents accidentally clobbering files.
alias mkdir='mkdir -p'
## Reset terminal -- Faster alternative of 'reset'.
alias cls='printf "\ec"'
## Start X and lock current terminal (press ENTER when back in terminal to
## prompt for password). Useless if X is running on the same TTY.
command -v vlock >/dev/null 2>&1 && alias sx='startx & vlock'
## Xrandr
alias xmorphnone='xrandr --output $(xrandr | grep "\<connected\>" | cut -f1 -d" ") --transform none'
alias xmorphsw='xrandr --output $(xrandr | grep "\<connected\>" | cut -f1 -d" ") --transform 1.24,0.16,-124,0,1.24,0,0,0.000316,1'
alias xmorphzo='xrandr --output $(xrandr | grep "\<connected\>" | cut -f1 -d" ") --scale 1.2x1.2'
alias xmorphzi='xrandr --output $(xrandr | grep "\<connected\>" | cut -f1 -d" ") --scale 0.8x0.8'
alias xres='xrandr --output $(xrandr | awk '"'"'NR==2 {print $1;exit}'"'"') --auto && xrandr -s $(xrandr | awk '"'"'/^ / {print $1;exit}'"'"')'
## Udiskie
command -v udiskie-umount >/dev/null 2>&1 && alias uua='udiskie-umount -a'
## Emacs
command -v emacsclient >/dev/null 2>&1 && alias emacs-kill="emacsclient -e '(kill-emacs)' >/dev/null 2>&1"
##==============================================================================
## Pacman aliases
if command -v "pacman" >/dev/null 2>&1; then
# alias pc='sudo pacman -Sc'
alias pi='sudo pacman -S --needed'
alias pqi='pacman -Qi'
alias pqo='pacman -Qo'
alias pqs='pacman -Qs'
alias pr='sudo pacman -Rs'
alias psi='pacman -Si'
alias pss='pacman -Ss'
alias pu='yes | sudo pacman -Sc && sudo pacman -Syu'
fi
##==============================================================================
## FreeBSD aliases
if [ "$(uname)" = "FreeBSD" ]; then
alias pa='sudo pkg_add -r'
# alias pd='sudo pkg_delete'
alias pd='sudo pkg_deinstall -cd'
alias pi='pkg_info -RrcdsD -l "::"'
alias pil='pkg_info -L'
## Origin of file
alias piw='pkg_info -W'
## Search
alias pis='pkg_info -Qox'
# alias pvs='pkg_version -Is'
alias psr='pkg_search -r'
## Out-of-date packages.
alias pv='pkg_version -Il "<"'
## Port tree
alias mi='sudo make install'
alias mid='sudo make install distclean'
alias mc='sudo make config'
fi
##==============================================================================
## TeXlive aliases
## TeXlive
if [ -d "/usr/local/texlive" ]; then
alias tlu="sudo sh -c 'umask 022 && tlmgr update --self'"
alias tls="tlmgr search --global"
alias tlsf="tlmgr search --global --file"
# alias tll="tlmgr info --only-installed"
alias tll="comm -3 <(tlmgr info --only-installed | grep -v 'x86_64\|amd64' | cut -d' ' -f2 | cut -f1 -d':' | sort) \
<(tlmgr info collection-basic --list | sed -n '/^ /{s/ //g;p;}' | sort) \
| sed 's/ //g' | grep -vi 'collection-basic\|scheme-minimal\|texlive-common\|texlive-docindex\|texlive-en'"
alias tlf="tlmgr info --list"
fi