rtviii
rtviii

Reputation: 897

Why `bindkey` in `.zshrc` does not apply unless i source the editor?

So i want to be able to cargo run with Ctrl + o.

I figured out that in zsh that is spelled something like this: bindkey -s '^o' 'cargo run ^M'. I put this in my .zshrc, but when i start a shell this command does not exist, so i have to source ~/.zshrc from inside the open shell. Then it works.

Why not on start?

Upvotes: 1

Views: 2620

Answers (2)

rtviii
rtviii

Reputation: 897

In my case the problem appears to have been that i've been putting my command definitions before the following:

export ZSH=~/.oh-my-zsh
source $ZSH/oh-my-zsh.sh

Put your code after.

Upvotes: 1

Ming
Ming

Reputation: 31

I have a similar problem. It is very likely that other plugin settings in your .zshrc override the new key binding. You can try to backup your .zshrc and only keep the key binding to see if it works. If it works, then gradually add other settings back to see which one causes the problem. In my case, it is the zsh-vi-mode.

Upvotes: 3

Related Questions