180 lines
6.1 KiB
Bash
180 lines
6.1 KiB
Bash
## -*- mode:sh -*- #
|
|
################################################################################
|
|
## Shell Config -- Alias Definitions.
|
|
## Date 2013-01-04
|
|
################################################################################
|
|
|
|
## Warning: if this does not work if you change shell without relogging, use
|
|
## 'source .<shell>rc' instead.
|
|
|
|
if [ "bash" = "$SHELL_CURRENT" ]; then
|
|
alias ..='cd ..'
|
|
alias ssrc='source ~/.bashrc'
|
|
fi
|
|
|
|
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 xlx='xrdb -load ~/.Xresources'
|
|
alias grep='grep --color=auto'
|
|
|
|
## Bad idea because you cannot toggle '-f' option anymore.
|
|
# alias cp="cp -i"
|
|
|
|
# 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'
|
|
|
|
## Remove executable attribute.
|
|
alias nox='find . -type f -exec chmod a-x {} \;'
|
|
|
|
## Get your external IP.
|
|
[ -n "$(command -v curl)" ] && alias myip='curl ifconfig.me'
|
|
|
|
## Network discovery.
|
|
[ -n "$(command -v nmap)" ] && alias network-discover='nmap -sP "192.168.0.*"'
|
|
|
|
## Prevents accidentally clobbering files.
|
|
alias mkdir='mkdir -p'
|
|
|
|
## Reset terminal -- Faster alternative of 'reset'.
|
|
alias cls='printf "\ec"'
|
|
|
|
## Display PATH and LD_LIBRARY_PATH in a more readable way.
|
|
alias echopath='echo -e ${PATH//:/\\n}'
|
|
alias echolibpath='echo -e ${LD_LIBRARY_PATH//:/\\n}'
|
|
|
|
## Shutdown / Reboot.
|
|
## If you do not want to get prompted for your password, configure sudo properly.
|
|
if [ -n "$(command -v systemctl)" ]; then
|
|
alias halt='systemctl poweroff'
|
|
else
|
|
alias halt='sudo halt -p'
|
|
fi
|
|
|
|
## Start X and lock current terminal (press ENTER when back in terminal to prompt for password).
|
|
[ -n "$(command -v vlock)" ] && alias sx='startx & vlock'
|
|
|
|
## Zathura -- Fork to background.
|
|
[ -n "$(command -v zathura)" ] && alias zat='zathura --fork'
|
|
|
|
## 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
|
|
alias uua='udiskie-umount -a'
|
|
|
|
##==============================================================================
|
|
## Zsh power aliases
|
|
##==============================================================================
|
|
|
|
#if [ "zsh" = "$SHELL_CURRENT" ]; then
|
|
## Inline aliases, zsh -g aliases can be anywhere in command line
|
|
#alias -g G='| grep -'
|
|
#alias -g L='| less'
|
|
|
|
## Now just type the image name to launch your image preview
|
|
#alias -s jpg='/usr/bin/sxiv'
|
|
|
|
# fi
|
|
|
|
##==============================================================================
|
|
## Emacs
|
|
##==============================================================================
|
|
if [ -n "$(command -v em)" ]; then
|
|
alias emacs-reload="emacsclient -e '(kill-emacs)' >/dev/null 2>&1; emacs --daemon"
|
|
fi
|
|
|
|
##==============================================================================
|
|
## Pacman aliases
|
|
##==============================================================================
|
|
if [ -e "/usr/bin/pacman" ]; then
|
|
PACMAN_FRONTEND='pacman'
|
|
|
|
## The eval trick lets us define the alias after the variable has been expanded.
|
|
eval 'alias pc="sudo $PACMAN_FRONTEND -Sc"'
|
|
eval 'alias pi="sudo $PACMAN_FRONTEND -S --needed"'
|
|
eval 'alias pqi="$PACMAN_FRONTEND -Qi"'
|
|
eval 'alias pqo="$PACMAN_FRONTEND -Qo"'
|
|
eval 'alias pqs="$PACMAN_FRONTEND -Qs"'
|
|
eval 'alias pr="sudo $PACMAN_FRONTEND -Rs"'
|
|
eval 'alias psi="$PACMAN_FRONTEND -Si"'
|
|
eval 'alias pss="$PACMAN_FRONTEND -Ss"'
|
|
eval 'alias pu="sudo $PACMAN_FRONTEND -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
|