4 ms·
I use this zsh function and define my git alias in my git config. # No arguments: `git status` # With arguments: acts like `git` function g() {
by psophis 3y ago
I use this zsh function and define my git alias in my git config.
# No arguments: `git status`
# With arguments: acts like `git`
function g() {
if [[ $# > 0 ]]; then
git $@
else
git st
fi
}
# Complete g like git
compdef g=git
- frfl 3y ago# Complete g like git compdef g=git That's brilliant.
- tacone 3y agoI have my zsh set up so that if I just press Enter without writing anything it will run ls -l or git status if it's a git directory.
- psophis 3y agoHow do you do that? Is it part of your PROMPT?
- tacone 3y agoSorry for the lag, I'll just drop the answer anyway in case it still can be helpful to you or anybody else. It's actually a oh-my-zsh plugin, called "magic-enter". I defined MAGIC_ENTER_GIT_COMMAND="git status" and then included the plugin. You can find a different but similar plugin here: https://github.com/zshzoo/magic-enter/blob/main/magic-enter.plugin.zsh https://github.com/zshzoo/magic-enter/blob/main/magic-enter....
- psophis 3y agoNeat, thanks!