supercrabtree / k

k is the new l, yo
1.78k stars 124 forks source link

best way to make an alias for 'k'? #72

Closed nikitavoloboev closed 6 years ago

nikitavoloboev commented 8 years ago

I want to change 'k' to be 'l'.

I would think that alias l='k' would work and it does but I want to also assign k to 'ack' and there are conflicts there. What is the best way to set up an alias for k or change key mapping for k?

Thank you for any help.

Mange commented 8 years ago

I think this would work:

alias l="command k" alias k="ack"

The command command runs the first argument only from your PATH, disregarding any aliases.

Den mån 8 aug. 2016 08:40Nikita Voloboev notifications@github.com skrev:

I want to change 'k' to be 'l'.

I would think that alias l='k' would work and it does but I want to also assign k to 'ack' and there are conflicts there. What is the best way to set up an alias for k or change key mapping for k?

Thank you for any help.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/supercrabtree/k/issues/72, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAGP6qx7Qrx_S4e-eodwGoKVUt0AkDgks5qds9SgaJpZM4JevwM .

00dani commented 8 years ago

Using an alias to command k won't work because k isn't a command - it's a shell function.

$ alias l='command k'
$ l
zsh: command not found: k

There's no function modifier, so you can't do alias l='function k'. Instead, you can escape the reference to k like this, which will prevent it from being re-expanded as an alias.

$ alias k='ag' # I don't have ack installed ;)
$ alias l='\k'
$ k --version | head -n1
ag version 0.33.0
$ l --help | head -n1
Usage: k [options] DIR