magicant / yash

Yet another shell
http://magicant.github.io/yash/
GNU General Public License v2.0
346 stars 30 forks source link

Specify any OS command instead of the edit command with `bindkey`. #61

Open kwatch opened 2 months ago

kwatch commented 2 months ago

Background

Bash can bind any command to an edit key such as Ctrl-L or Ctrl-O by bind -x. For example:

[bash]$ bind -x '"\C-l":"ls --color"'

The above binding allows user to run ls --color command by Ctrl-L. This is more convenient than typing ls + Enter.

Zsh also supports the similar functionality by bindkey.

Question (or feature request)

Does yash support the similar functionality as bind -x in Bash? Or is there any plan to support it?

(Yash doesn't support this feature, does it?)

[yash]$ bindkey -e '\^L' "ls"
bindkey: no such editing command `ls'
[yash]$ yash --version | head -1
Yet another shell, version 2.56.1
magicant commented 2 months ago

This feature hasn't been implemented yet. If it were to be implemented, do you think it would be better to set it up with shell commands like in bash, or with key sequences like in zsh?

kwatch commented 2 months ago

I prefer Bash style rather than Zsh style, because the former is intuitive but the latter is not.

Zsh example to bind ls --color to Ctrl-L:

ctrl_l() {
  print ""
  ls --color
  zle reset-prompt
}
zle -N ctrl_l
bindkey '^L' ctrl_l

It works very well on my environment, but it is not intuitive compared to Bash approach.

However, the important point is to allow Yash user to bind any command to the Ctrl key sequence, even the approach is not intuitive. You should follow your own ideas about which approach is the better.