What aliases do you use ?

  about 581 words   3 min

SHELL - TIPS

Here is a list of aliases I use more or less frequently. Aliases and shell functions is a thing that I couldn't live without. It helps you type less to do more. I've been using zsh for a while now and I've never been a real fan about bash. Prior to that shell I used to work with diferrent ksh variants.

I do use a lot of aliases, here are some of them :

  # listing directories
  alias l='ls -la' # detailed list, show hidden
  alias lh='ls -lah' # detailed list, show hidden, human filesizes
  alias ll='ls -lrth' # detailed list, no hidden
  alias ls.='ls -d .[^.]*' # regular list, only hidden
  alias ll.='ls -ld .[^.]*' # detailed list, only hidden
  alias lsd='ls -d *(-/DN)' # regular list, only directories
  alias lld='ls -ld *(-/DN)' # detailed list, only directories
  alias sl=ls # accidental misspelling

  # misspelling
  alias xs='cd'       
  alias rat='cat'    
  alias cd..='cd ..'
  alias grpe='grep' 
  
  # navigation
  alias d='dirs -v'   # list directory stack
  alias -- -='cd -'   # flip to last dir with just '-'
  alias pu='pushd'
  alias po='popd'
  alias -g ...='../..'
  alias -g ....='../../..'
  alias -g .....='../../../..'
  alias 1='cd -' # jump to 'n' in directory stack...
  alias 2='cd +2'
  alias 3='cd +3'
  alias 4='cd +4'
  alias 5='cd +5'
  alias 6='cd +6'
  alias 7='cd +7'
  alias 8='cd +8'
  alias 9='cd +9'

  # gnupg alias
  alias encrypt='gpg -e -r me'
  alias decrypt='gpg --decrypt'
  
  # apt 
  alias apt='sudo apt'
  
  # directories
  alias md='mkdir -p'
  alias rd='rmdir'
  alias mounted="mount |column -t"
  
  # size
  alias du='du -shc'
  alias df='df -h'

  # sound cards not using the same id @home/work
  # hades is my laptop littre name 

  if [ $HOST = "hades" ];then
     alias alsamixer='alsamixer -c0'
  else
     alias alsamixer='alsamixer -c1'
  fi

  # browsers
  alias chrome='chromium --disable-extensions --incognito'

  # screenshots
  alias sc="scrot 'screenshot-%d%m%Y_%H%M%S.png' -s -e 'mv screenshot* ~/tmp'"

  # battery status
  alias battery='acpi -V | sed -n -e 1p -e 4p'

  # calculator 
  alias calc="gcalccmd"

I have also some aliases for taskwarrior, my TODO CLI tool :


  # taskwarrior aliases
  alias t='task'
  alias ta='task add'
  alias tm='task modify'
  alias tb='task burndown.daily'
  alias tl='task long'
  alias tt='task timesheet'
  alias ideas='task context ideas'
  alias tnone='task context none'
  alias tmod="task modify"
  alias tcal="task calendar"

My git aliases :


  # git
  alias g='git'
  alias gl='git log --graph --full-history --all --date=relative --color --pretty=format:"%C(yellow)%h  %C(cyan)%ad %Cgreen[ %aN ] %Creset%s %C(bold yellow)%d"'
  alias gwc='git whatchanged'
  
  alias gst='git status'
  alias gd='git diff'
  alias gds='git diff --staged'
  alias gb='git branch -a -v' # verbosely list local and remote branches
  alias ga='git add'
  alias gap='git add -p' # interactively add files to index
  alias gu='git unstage' # unstage file from index, defined in ~/.gitconfig
  alias gci='git commit'
  alias gco='git checkout'
  alias gf='git fetch'
  alias gm='git merge'
  alias gr='git rebase'

I use also tomb and especially pass-tomb and have some aliases for that too :

 
  # tomb
  alias sesame="pass open -f" 
  alias slam="pass close -f"
  alias insert="pass insert"
  alias passf="pass find"

Zsh has a nice feature that let you open a default app depending of the suffix of your file :

  
  # suffix aliases
  alias -s pdf='mupdf'
  alias -s svg='inkscape'
  alias -s avi='mplayer'
  alias -s mpg='mplayer'
  alias -s mov='mplayer'
  alias -s mkv='mplayer'
  alias -s doc='libreoffice'
  alias -s docx='libreoffice'
  alias -s odt='libreoffice'
  alias -s xls='libreoffice'
  alias -s ods='libreoffice'
  alias -s xlsx='libreoffice'
  alias -s ppt='libreoffice'
  alias -s jpg='imvr'
  alias -s jpeg='imvr'
  alias -s png='imvr'

That way if you want to watch a short movie, usually you type :


  % mplayer shortmovie.mkv 

now you can type directly:


  % shortmovie.mkv
  

CLI shell zsh
STORIES BASED ON SAME TAGS

Using Timewarrior With Taskwarrior

Terminals have always been a thing that I loved to use. I spend a lot of times using and tweaking them. i My daily use include a lot of this little programs that help you to improve your productivity. Keybindings and customizations is also one thing that I love about terminals compared to GUI. That's also why I awesomewm. For those who don't know what it is, it's a lightweight tiling window manager like Ion.

Read more

Imagemagick - a swiss army knife for manipulating images

There is a CLI tool I use often to manipulate images, its name is Imagemagick. You can install it with any package management system you have depending of your OS. Imagemagick is also used in a lot of libraries to render images for various purposes. Here is a list of commands I use quite often when I need to edit some images.

Read more