ambevar-dotfiles/.shell.d/alias_rc

141 lines
4.6 KiB
Bash

## -*- mode:sh -*- #
################################################################################
## Shell Config -- Alias Definitions.
## Date 2012-10-29
################################################################################
##==============================================================================
## General
##==============================================================================
## 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
##==============================================================================
##==============================================================================
## '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"
## Emacs
type emacs > /dev/null
if [ $? ]; then
alias em='emacsclient -a "" -t'
alias emacs-reload="emacsclient -e '(kill-emacs)' >/dev/null 2>&1; emacs --daemon"
fi
# 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.
type curl > /dev/null
[ $? ] && alias myip='curl ifconfig.me'
## Network discovery.
type nmap > /dev/null
[ $? ] && alias network-discover='nmap -sP "192.168.1.*"'
## 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 [ "$OSTYPE" = "linux-gnu" ]; 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).
type vlock > /dev/null
[ $? ] && alias sx='startx & vlock'
## Zathura -- Fork to background.
type zathura > /dev/null
[ $? ] && 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'
##==============================================================================
## 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 irfanview
#alias -s jpg='/usr/bin/gpicview'
# fi
##==============================================================================
## Pacman aliases
##==============================================================================
[ -e "/usr/bin/pacman" ] && . ~/.shell.d/alias_pacman
##==============================================================================
## FreeBSD aliases
##==============================================================================
[ "$(uname)" = "FreeBSD" ] && . ~/.shell.d/alias_freebsd
##==============================================================================
## TeXlive aliases
##==============================================================================
## TeXlive
if [ -d "/usr/local/texlive" ]; then
alias tlu="sudo bash -c 'umask 022 && tlmgr update --self'"
alias tls="tlmgr search --global"
alias tll="tlmgr show --list"
fi