Zsh Utilities Aliases

This is part of the Zsh Utilities.

Zsh Utilities - Aliases

This file defines some basic but nevertheless fundamental aliases.

Basic

alias cl='clear'
alias h='history'
alias open='xdg-open $@ > /dev/null 2>&1'

List Segments aka ls command

alias l='k'
alias ll='ls -ltrh'
alias la='ls -rtha'
alias lla='ls -rthal'
alias lsd='ls -l | grep "^d"'

Alias cp to gcp

gcp is a python script to provide a user friendly frontend to cp unix command.

if (( $+commands[gcp] )); then
    alias cp='/usr/bin/gcp -f'
    compdef _files gcp
fi

Greping stuff

alias grep='grep --color=auto'
if pkgtools__has_binary ack-grep; then
    alias ack='ack-grep'
elif pkgtools__has_binary /usr/bin/vendor_perl/ack; then
    alias ack='/usr/bin/vendor_perl/ack'
fi

Emacs shortcuts

function --check-emacs ()
{
    local pid=$(ps -edf | grep ${USER} | grep emacs | grep daemon | awk '{print $2}')
    if [[ "${pid}" == "" ]]; then
        notify -i emacs "Emacs" "New emacs daemon"
        emacs --daemon  > /dev/null 2>&1
    fi
    emacsclient "$@"
}
alias emacs='--check-emacs -n -c $@'
alias iemacs='--check-emacs -n $@'
alias ve='--check-emacs -nw $@'
alias relaunch_emacs='killall emacs; sleep 1; emacs'

Cask function to use it everywhere

function cask ()
{
    if pkgtools__has_binary cask; then
         (
             cd ~/.emacs.d
             $(pkgtools__get_binary_path cask) $@
         )
    fi
}

top alias

In case glances is installed (see https://github.com/nicolargo/glances), use it as replacement for top command

if (( $+commands[glances] )); then
    alias top='glances'
fi

Terminal pager program

Options for less program are the following

  • -M : shows more detailed prompt, including file position
  • -N : shows line number
  • -X : supresses the terminal clearing at exit
export PAGER='less -M -N -X'
alias more='less -M -N -X'
if pkgtools__has_binary /usr/local/bin/src-hilite-lesspipe.sh; then
    pkgtools__set_variable LESSOPEN "| src-hilite-lesspipe.sh %s"
    pkgtools__set_variable LESS " -R "
else
    pkgtools__unset_variable LESSOPEN
    pkgtools__unset_variable LESS
fi

Python server

alias start_server='python -m http.server 8888'
File under version control - commit b7f7874 - 2014-11-07