man fzf)There's no env vars exposed to change the keyboard shortcuts for the methods in /usr/share/fzf/fzf-keybinds.sh
well I can give you an answer for bash
in file makred key-bindings.bash (found mine in /usr/share/fzf/) at the bottom you will see your alt c bindings (\ec)
# ALT-C - cd into the selected directory
bind -m emacs-standard '"\ec": " \C-b\C-k \C-u`__fzf_cd__`\e\C-e\er\C-m\C-y\C-h\e \C-y\ey\C-x\C-x\C-d"'
bind -m vi-command '"\ec": "\C-z\ec\C-z"'
bind -m vi-insert '"\ec": "\C-z\ec\C-z"'
in order to change to ctrl d you just replace the \ec with \C-d
# CTRL-D - cd into the selected directory
bind -m emacs-standard '"\C-d": " \C-b\C-k \C-u`__fzf_cd__`\e\C-e\er\C-m\C-y\C-h\e \C-y\ey\C-x\C-x\C-d"'
bind -m vi-command '"\C-d": "\C-z\ec\C-z"'
bind -m vi-insert '"\C-d": "\C-z\ec\C-z"'
in zsh its pretty easy too same folder key-bindings.zsh
# ALT-C - cd into the selected directory
fzf-cd-widget() {
local cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
-o -type d -print 2> /dev/null | cut -b3-"}"
setopt localoptions pipefail no_aliases 2> /dev/null
local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m)"
if [[ -z "$dir" ]]; then
zle redisplay
return 0
fi
cd "$dir"
unset dir # ensure this doesn't end up appearing in prompt expansion
local ret=$?
zle fzf-redraw-prompt
return $ret
}
zle -N fzf-cd-widget
bindkey '^D' fzf-cd-widget
right here ^ you will find a \ec instead of a '^D' this one has already been swapped out and seems to be working fine, id recommend copying the file to somewhere and sourcing it from your initiaion file.
It would be cool to expose an env var, but I can live with that thanks.
i dont really use zsh but you can use variable substitution in bash for bindings
${BIND=-bind -m vi-insert -x '"\en":"\C-a" sudo "\C-\ee"'}
bind -m vi-insert -x '"${KEY:=\\en}":"\C-a" sudo "\C-\ee"'
im sure zsh has something similar
whats your goal? if you don't mind my asking what are you searching for and why? Might help me see if i can come up with a solution (practice for me as im newish to scripting/programming in general)
Being able to change the keybinds without having to edit sudo files. I mean, personally I already fixed it but I think it would be good for the project.
Template applied to the issue.
Also you shouldn’t need to edit Sudo files as far as I’m aware you should have a local .zshrc file that’s sourced on login that you can add your bindings to or even creat your own file and source it with your bindings but the command the file I showed you can copy to your home dir and change then source however if you’ve found a solution could you please post it so others looking for a similar answer can see what you’ve done
Thank you I'll look for it during this week hopefully.
no worries for the file for fzf is called key-bindings.zsh mine was in usr/share/fzf but you can always download from here and then source it in your rc file if the ~/.zshrc doesnt exist you can create it and it should automatically source as a startup file i keep my custom fzf files in ~/fzf/config
#!bin/bash
source /home/rayiik/fzf/completion.bash
source /home/rayiik/fzf/fzf-extra.bash
source /home/rayiik/fzf/fzf.bind.bash
source /home/rayiik/fzf/conf/.fzfrc
this lets me source all my non-executable scripts for fzf and keep them all in one place and im sure you could do something similar for zsh that way you can modify them as you need and you'll have backups in the original folder incase you deck your script (which I've done a couple of times)
Rayiik solution works elegantly. Steps to reproduce:
mv /usr/share/fzf/key-bindings.zsh ~/.fzf-keybinds
Now on ~/.vimrc add the next line
source ~/.fzf-keybinds
Of course, you can name the file as you preffer.
Excellent glad you got that going :)