123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- #
- # Editor
- #
- if -exe emacs; then
- export EDITOR='emacs -nw'
- fi
- if -exe vim; then
- export EDITOR='vim'
- fi
- alias e=$EDITOR
- if [ -n "$EDITOR" -a -n "$SUDO_USER" -a "$UID" = 0 -a "$EDITOR[1,5]" = 'emacs' ]; then
- e="$EDITOR -u $SUDO_USER"
- fi
- #
- # Pager
- #
- if -exe vim; then
- export PAGER=~/.vim/bin/vimpager
- alias less="$PAGER"
- alias more="$PAGER"
- elif -exe less; then
- export PAGER=less
- alias more="$PAGER"
- elif -exe more; then
- export PAGER=more
- fi
- export GIT_PAGER="$PAGER"
- #
- # Common aliases / functions
- #
- alias rm='rm -i'
- alias mv='mv -i'
- alias cp='cp -i'
- alias vlock='clear;vlock'
- alias q='clear;exit'
- export GREP_OPTIONS="--color=auto"
- alias mgrep="grep -rnisH"
- alias rsu="sudo -E zsh"
- alias reloadsh="exec zsh"
- alias tmux="tmux -2"
- alias md="mkdir -p"
- mcd() { mkdir -p "$@" && cd "$@" }
- # show tar archive content
- ltar() { gunzip -c $1 | tar -tf - -- | $PAGER }
- # show zip archive content
- lzip() { unzip -l $1 | $PAGER }
- # show rar archive content
- lrar() { rar l $1 | $PAGER }
- ffi() {
- find -iname "$@"
- }
- #
- # Log viewers aliases
- #
- if -exe ccze; then
- alias alog="tail -n 300 -F /var/log/auth.log | ccze"
- alias mlog="tail -n 300 -F /var/log/mail.log | ccze"
- alias slog="tail -n 300 -F /var/log/syslog | ccze"
- alias xlog="tail -n 300 -F /var/log/Xorg.0.log | ccze"
- else
- alias alog="tail -n 300 -F /var/log/auth.log"
- alias mlog="tail -n 300 -F /var/log/mail.log"
- alias slog="tail -n 300 -F /var/log/syslog"
- alias xlog="tail -n 300 -F /var/log/Xorg.0.log"
- fi
- # using colortail if available (freebsd)
- if -exe colortail; then
- alias slog="colortail -n 60 -k /usr/local/share/examples/colortail/conf.messages -f /var/log/syslog"
- fi
- #
- # System tools aliases
- #
- alias df='df -h'
- if -exe pydf; then
- alias df="pydf -h"
- fi
- if -exe python; then
- alias httpserver="python -m SimpleHTTPServer"
- fi
- function mount() {
- if [ $# = 0 ]; then
- command mount -lv | column -t
- else
- command mount $@
- fi
- }
- #
- # Sysadmin stuff
- #
- if -exe dig ; then
- alias mx="dig +short MX"
- alias ns="dig +short NS"
- elif -exe host ; then
- alias mx="host -t MX"
- alias ns="host -t NS"
- fi
- alias scp_nosec="scp -o 'StrictHostKeyChecking=no' -o 'UserKnownHostsFile=/dev/null'"
- alias ssh_nosec="ssh -o 'StrictHostKeyChecking=no' -o 'UserKnownHostsFile=/dev/null'"
- # OpenSSL
- for i in sha512 sha256 sha1 md5 ; do
- ssl-cert-$i() {
- openssl x509 -noout -fingerprint -$i -in $1
- }
- done
- ssl-cert-fingerprints() {
- for i in sha512 sha256 sha1 md5; do
- ssl-cert-$i $1
- done
- }
- ssl-cert-info() {
- openssl x509 -noout -text -in $1
- ssl-cert-fingerprints $1
- }
- #
- # Devel tools aliases
- #
- DIFFTOOL=
- if -exe colordiff; then
- DIFFTOOL='colordiff'
- if -exe tput; then
- alias DIFFTOOL='colordiff -yW$(tput cols)'
- fi
- fi
- if [ -n "$DIFFTOOL" ]; then
- alias diff="$DIFFTOOL"
- fi
- udiff() {
- $DIFFTOOL -Naur $*
- }
- if -exe colormake; then
- alias make="colormake"
- fi
- #
- # Mssh stuff
- #
- if [ -f ~/.ssh/config ]; then
- hosts=($(grep '^Host [^*]' ~/.ssh/config | sed 's/Host //'))
- compctl -k hosts mssh
- fi
- #
- # Misc stuff
- #
- # Save and restore directory, based on
- # http://chris-lamb.co.uk/2011/07/30/optimising-directory-navigation-multiple-terminals/
- rcd() {
- cd "$(cat ~/.zsh.d/history/saved_dir)"
- }
- scd() {
- echo "$(pwd)" > ~/.zsh.d/history/saved_dir
- }
|