Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A killer feature not listed here is global aliases. These are aliases that can be anywhere in a line. The most use I get out of this is from having

   alias -g L=' | less '
which allows me to simply append "L" to a line to pipe the output to less.

    ls L
The pattern of short all-caps global aliases for ' | command 's make building/editing pipelines really easy/fast.

    alias -g C=' | wc -l '
    alias -g A=' | ack-grep '
    alias -g S=' | sort '
    alias -g JQL=' | jq -C  | less'

    ls **/*png L
    ls **/*png A -v regex C
    curl $site JQL
putting

bindkey '^g' _expand_alias

in your zshrc allows you to expand aliases with <C-g>

You can find more global aliases and tips at: http://grml.org/zsh/zsh-lovers.html



So what do you do when you want to ls a file called "L"?


I put L in 'single quotes' or I \escape it

  touch 'L'
  ls 'L'
  ls \L


Do not use global aliases. They are dangerous. It's too easy to accidentally use them without realizing it, with unpredictable consequences.

Much better is to use abbreviations which expand to the full command they abbreviate after you hit the space bar.[1]

This way you can see exactly what's going to be done before you hit ENTER. It does cost one extra keystroke, but the safety is worth it.

[1] - http://zshwiki.org/home/examples/zleiab


./L




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: