4 ms·
For aliases, convenience functions, and fancy widgets, my philosophy is one word: wait. I make myself go through the trouble of doing it the usual way for a li
by jayferd 14y ago
For aliases, convenience functions, and fancy widgets, my philosophy is one word: wait. I make myself go through the trouble of doing it the usual way for a little while. This way, I usually end up with much more domain knowledge and a much more elegant solution than if I'd rushed in to make things easier right of the bat.
For example, I don't have `alias gs='git status'`. Just `alias g=git` works great, and git has its own awesome alias system with tab completion that gets me the rest of it. So instead of `gs` I type `g s`, and I get tab completion on all the flags.
- robert-boehnke 14y agoTab 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
- jayferd 14y agoNeat! 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-difference-between-and-in-bash#3008734 http://stackoverflow.com/questions/3008695/what-the-differen...
- LukeShu 14y agoIt only looks like a hack until you understand Bash arrays.
- pydave 14y agoI was about to ask how you got your alias working with completion, and then I found this: http://stackoverflow.com/questions/342969/how-do-i-get-bash-completion-to-work-with-aliases http://stackoverflow.com/questions/342969/how-do-i-get-bash-... I've never messed with bash completion before, but it was as simple as adding this to my bash_aliases: complete -o default -o nospace -F _git g