Move fish keybinds to nix file
This commit is contained in:
parent
424a1db3a7
commit
4eae09ee71
|
@ -20,37 +20,10 @@ set fish_greeting
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ Keybinds
|
# {{{ Keybinds
|
||||||
function fish_user_key_bindings
|
function fish_user_key_bindings
|
||||||
# {{{ Use vim-style keybinds
|
|
||||||
# Use the vim keybinds
|
|
||||||
fish_vi_key_bindings
|
fish_vi_key_bindings
|
||||||
|
fish_nix_key_bindings
|
||||||
|
|
||||||
bind -e -M insert -k f10 # unbinds f10
|
|
||||||
bind -M insert -m default -k f10 'commandline -f repaint' # Exit insert mode with <f10>
|
bind -M insert -m default -k f10 'commandline -f repaint' # Exit insert mode with <f10>
|
||||||
# }}}
|
|
||||||
# {{{ C-x to clear screen
|
|
||||||
bind -M default \cx "clear && commandline -f repaint"
|
|
||||||
bind -M insert \cx "clear && commandline -f repaint"
|
|
||||||
# }}}
|
|
||||||
# {{{ C-z to run `fg`
|
|
||||||
bind -M default \cz "fg && commandline -f repaint"
|
|
||||||
bind -M insert \cz "fg && commandline -f repaint"
|
|
||||||
# }}}
|
|
||||||
# {{{ C-enter to run command through less
|
|
||||||
bind -M default \e\[13\;2u "commandline -a ' | less' && commandline -f execute"
|
|
||||||
bind -M insert \e\[13\;2u "commandline -a ' | less' && commandline -f execute"
|
|
||||||
# }}}
|
|
||||||
# {{{ C-g to open neogit
|
|
||||||
bind -M default \cg "nvim +Neogit"
|
|
||||||
bind -M insert \cg "nvim +Neogit"
|
|
||||||
# }}}
|
|
||||||
# {{{ C-e to open $EDITOR
|
|
||||||
bind -M default \ce "$EDITOR"
|
|
||||||
bind -M insert \ce "$EDITOR"
|
|
||||||
# }}}
|
|
||||||
# {{{ C-S-e to open commandline in $EDITOR
|
|
||||||
bind -M default \e\[69\;5u "commandline -f edit_command_buffer"
|
|
||||||
bind -M insert \e\[69\;5u "commandline -f edit_command_buffer"
|
|
||||||
# }}}
|
|
||||||
end
|
end
|
||||||
# }}}
|
# }}}
|
||||||
# {{{ Helpers
|
# {{{ Helpers
|
||||||
|
|
|
@ -1,4 +1,32 @@
|
||||||
{ pkgs, config, lib, ... }:
|
{ pkgs, config, lib, ... }:
|
||||||
|
let
|
||||||
|
repaint = "commandline -f repaint";
|
||||||
|
fishKeybinds = {
|
||||||
|
# C-x to clear screen
|
||||||
|
"\\cx" = "clear && ${repaint}";
|
||||||
|
# C-z to return to background process
|
||||||
|
"\\cz" = "fg && ${repaint}";
|
||||||
|
# C-y to yank current command
|
||||||
|
# TODO: make this work in xorg as well
|
||||||
|
"\\cy" = "wl-copy \$(commandline)";
|
||||||
|
# C-e to launch $EDITOR
|
||||||
|
"\\ce" = "$EDITOR";
|
||||||
|
# C-S-e to edit commandline using $EDITOR
|
||||||
|
"\\e\\[69\\;5u" = "edit_command_buffer";
|
||||||
|
# C-enter to run command through a pager
|
||||||
|
"\\e\\[13\\;2u" = "commandline -a ' | $PAGER' && commandline -f execute";
|
||||||
|
# C-g to open neogit
|
||||||
|
"\\cg" = "nvim +Neogit";
|
||||||
|
};
|
||||||
|
|
||||||
|
mkKeybind = key: value:
|
||||||
|
let escaped = lib.escapeShellArg value;
|
||||||
|
in
|
||||||
|
''
|
||||||
|
bind -M default ${key} ${escaped}
|
||||||
|
bind -M insert ${key} ${escaped}
|
||||||
|
'';
|
||||||
|
in
|
||||||
{
|
{
|
||||||
# {{{ Fzf
|
# {{{ Fzf
|
||||||
programs.fzf = {
|
programs.fzf = {
|
||||||
|
@ -21,6 +49,11 @@
|
||||||
programs.fish = {
|
programs.fish = {
|
||||||
enable = true;
|
enable = true;
|
||||||
interactiveShellInit = ''
|
interactiveShellInit = ''
|
||||||
|
# ❄️ Fish keybinds generated using nix ^~^
|
||||||
|
function fish_nix_key_bindings
|
||||||
|
${lib.concatStringsSep "\n" (lib.mapAttrsToList mkKeybind fishKeybinds)}
|
||||||
|
end
|
||||||
|
|
||||||
${builtins.readFile ./config.fish}
|
${builtins.readFile ./config.fish}
|
||||||
|
|
||||||
# Modify nix-shell to use `fish` as it's default shell
|
# Modify nix-shell to use `fish` as it's default shell
|
||||||
|
|
Loading…
Reference in a new issue