Skip to content

Comment on Shell Gamification (how I learn to use my shell aliases)parent

Comments

Tab completion and aliases need not be mutually exclusive. For instance, in zsh you can use:

    alias gs='git status'
    compdef _git gs=git-status
FYI: I also mapped g without parameters to `git status -sb` but g with parameters will simply execute everything as normal
    g () {
      if [ $# -eq 0 ]
      then
        git status -sb
      else
        git $*
      fi
    }
    compdef g=git

Neat! I'll try that using the g() function. I would replace your $* with "$@" (in double quotes), though, so it doesn't try to re-split your arguments by the IFS. (Yes, $@ is a gigantic hack, but a necessary one.) See http://stackoverflow.com/questions/3008695/what-the-differen...

It only looks like a hack until you understand Bash arrays.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.