Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

g as function or alias #3

Open
aaronjensen opened this issue Apr 20, 2015 · 2 comments
Open

g as function or alias #3

aaronjensen opened this issue Apr 20, 2015 · 2 comments

Comments

@aaronjensen
Copy link

I use g as a function that calls git and I'd like this to apply to that. It wasn't clear what I would need to tweak to make it work. Could you allow for an optional set of commands that this enables for? Thanks!

@knu
Copy link
Owner

knu commented Apr 21, 2015

Thanks for the suggestion. I'll think about it.

@Konfekt
Copy link

Konfekt commented Apr 13, 2016

If you happen to use zsh, you can work around it by adding

magic-abbrev-expand() {
    local MATCH
    # alias is at beginning of prompt (and possibly preceded by spaces)
    if [[ "$LBUFFER" =~ "^\s*g$" ]]; then
        LBUFFER+="it"
    fi
}
_space_magic-abbrev-expand() {
    magic-abbrev-expand
    zle self-insert
}
zle -N _space_magic-abbrev-expand
bindkey -e ' ' _space_magic-abbrev-expand
# bindkey -v ' ' _space_magic-abbrev-expand
bindkey -M isearch ' ' self-insert

_enter_magic-abbrev-expand() {
    magic-abbrev-expand
    zle accept-line
}
zle -N _enter_magic-abbrev-expand
bindkey -e "^M" _enter_magic-abbrev-expand
# bindkey -v "^M" _enter_magic-abbrev-expand
bindkey -a "^M" _enter_magic-abbrev-expand
bindkey -M isearch "^M" accept-line

to your ~/.zshrc. This assumes emacs keybindings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants