Skip to content

Latest commit

 

History

History
118 lines (105 loc) · 2.99 KB

zsh-utilities-alias.org

File metadata and controls

118 lines (105 loc) · 2.99 KB

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 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'
alias stop_emacs='pkill -SIGUSR2 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 --percpu --process-short-name --fs-free-space'
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'
if pkgtools::has_binary bat; then
    alias more='bat'
else
    alias more='less -M -N -X'
fi
if pkgtools::has_binary pygmentize; then
    pkgtools::reset_variable LESSOPEN "| pygmentize %s"
else
    pkgtools::unset_variable LESSOPEN
fi

Python server

alias start_server='python -m http.server 8888'

Raspeberry pi transmission

alias transmission-rpi="transmission-remote-gtk"

youtube-dl audio

alias youtube-dl-audio='youtube-dl --ignore-errors --output "%(title)s.%(ext)s" --extract-audio --audio-format mp3'