dotfiles/.bash_aliases

101 lines
2.4 KiB
Bash

###############################################################################
# File .bash_aliases
# jul.io
###############################################################################
# ls aliases
alias ll='ls -la'
alias lla='ls -htlr -A'
alias l='ls -l'
# change directory
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias p='cd -'
# if cd gets a path to a file, it should change to the directory of this very file
cd() {
local target="$1"
# If no argument, go to home directory (default cd behavior)
if [ -z "$target" ]; then
builtin cd
return $?
fi
# If target is a file, cd to its directory
if [ -f "$target" ]; then
builtin cd "$(dirname "$target")"
else
# Otherwise, use normal cd behavior
builtin cd "$target"
fi
}
# cdl=move to directory and instantly list its contents
# everyone needs this ;-)
cdl(){
cd $@
ls -l
}
# directly cd into the latest modified directory
cdla(){
cd "$(\ls -1dt ./*/ | head -n 1)"
}
# making git-life easier
gitc(){
git commit -a -m "$1"
#TODO: switch back to vim via fg command if we paused vim by pressing <C-z> to commit our changes
}
alias gitp='git push origin'
alias gitch='git checkout'
alias gitchd='git checkout develop' #directly switch to develop branch (ManageNow development)
# misc
alias px="ps auxf"
alias o="xdg-open"
# pretty print json
alias ppjson='python -c "import sys, json; print json.dumps(json.load(sys.stdin), sort_keys=True, indent=4)"'
# my favorite typos
alias gerp=grep
alias gpre=grep
alias gre=grep
alias grpe=grep
alias gep=grep
alias wcgrp=wcgrep
alias wcgerp=wcgrep
alias wcgrpe=wcgrep
alias wcgre=wcgrep
alias tial=tail
alias snv=svn
alias iv=vi
alias vo=vi
alias vu=vi
alias chmkd=chmod
alias pign=ping
# other stuff
alias eierabend='xflock4 ; systemctl suspend --no-wall'
alias updgrade='sudo aptitude update && sudo aptitude upgrade -y'
# better passwords!
alias apg='apg -M sncl -n 15 -m 10 -x 20'
# pssh! when not using ansible, puppet, whatever, parallel-ssh enables you to do the same stuff on several servers with one command
alias pssh='parallel-ssh'
# sudo aliases
# switch to root with sudo but preserve your user-settings
alias sudei='sudo -Ei'
alias svim='sudo -E vim'
alias telnet='echo use the curl method: curl telnet:\/\/<ip>:<port>'
# hopefully, there's ack-grep installed on the system...
alias ag='ack'