useful aliases

  1. Show today’s date in the ISO 8601 format.
    alias today="date +%F"
  2. When using mv, do not override files but create a backup per default.
    alias mv="mv --backup=numbered"
  3. Always use p and v flags when using mkdir.
    alias mkdir="mkdir -pv"
  4. Create a new command mkt, which appends today’s date to directories created.
    alias mkt='function _mkt(){ mkdir -pv $(sed -E "s|([^/]+)(/*.*)|\1-$(today)\2|" <<< $1);}; _mkt'
    $ mkt test/test2
    mkdir: created directory ‘test-2015-12-17’
    mkdir: created directory ‘test-2015-12-17/test2’
    $ tree
    └── test-2015-12-17
        └── test2
    Note: today alias needs to be defined. When using the p flag, today's date is only appended to the folder highest in the directory tree.
  5. When using wget, always try to resume a partially-downloaded file.
    alias wget="wget -c"
  6. To grep the history is a quite frequent use case.
    alias histg="history | grep"
    $ histg mkt
    179  alias mkt='function _mkt(){ mkdir -pv $(sed -E "s|([^/]+)(/*.*)|\1-$(today)\2|" <<< $1);}; _mkt'
    180  mkt test/test2
    183  mkt test/test2
    190  histg mkt
Share itShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *