feat: add fish variables and fish key bindings
parent
6ac80fd1c1
commit
f7f71f5fe4
|
@ -0,0 +1,144 @@
|
||||||
|
set -l init_mode insert
|
||||||
|
|
||||||
|
if contains -- $argv[1] insert default visual
|
||||||
|
set init_mode $argv[1]
|
||||||
|
else if set -q argv[1]
|
||||||
|
# We should still go on so the bindings still get set.
|
||||||
|
echo "Unknown argument $argv" >&2
|
||||||
|
end
|
||||||
|
|
||||||
|
# Inherit shared key bindings.
|
||||||
|
# Do this first so vi-bindings win over default.
|
||||||
|
for mode in insert default visual
|
||||||
|
__fish_shared_key_bindings -s -M $mode
|
||||||
|
end
|
||||||
|
|
||||||
|
# Add a way to switch from insert to normal (command) mode.
|
||||||
|
# Note if we are paging, we want to stay in insert mode
|
||||||
|
# See #2871
|
||||||
|
bind -s --preset -M insert \e "if commandline -P; commandline -f cancel; else; set fish_bind_mode default; commandline -f backward-char repaint-mode; end"
|
||||||
|
|
||||||
|
# Default (command) mode
|
||||||
|
bind -s --preset :q exit
|
||||||
|
bind -s --preset -m insert \cc cancel-commandline repaint-mode
|
||||||
|
bind -s --preset -M default h backward-char
|
||||||
|
bind -s --preset -M default l forward-char
|
||||||
|
bind -s --preset -M visual h begin-selection backward-char
|
||||||
|
bind -s --preset -M visual l begin-selection forward-char
|
||||||
|
bind -s --preset -m insert \n execute
|
||||||
|
bind -s --preset -m insert \r execute
|
||||||
|
bind -s --preset -m insert o insert-line-under repaint-mode
|
||||||
|
bind -s --preset -m insert O insert-line-over repaint-mode
|
||||||
|
bind -s --preset -m insert i repaint-mode
|
||||||
|
bind -s --preset -m insert I beginning-of-line repaint-mode
|
||||||
|
bind -s --preset -m insert a forward-single-char repaint-mode
|
||||||
|
bind -s --preset -m insert A end-of-line repaint-mode
|
||||||
|
|
||||||
|
# Selection keys (if in default mode)
|
||||||
|
bind -s --preset -M default -m visual H begin-selection backward-char
|
||||||
|
bind -s --preset -M default -m visual L begin-selection forward-char
|
||||||
|
bind -s --preset -M default -m visual J begin-selection down-or-search
|
||||||
|
bind -s --preset -M default -m visual K begin-selection up-or-search
|
||||||
|
bind -s --preset -M default -m visual x beginning-of-line begin-selection end-of-line
|
||||||
|
# TODO: Implement x when already in visual mode
|
||||||
|
# (if already in visual mode)
|
||||||
|
bind -s --preset -M visual H backward-char
|
||||||
|
bind -s --preset -M visual L forward-char
|
||||||
|
bind -s --preset -M visual J backward-char
|
||||||
|
bind -s --preset -M visual K backward-char
|
||||||
|
|
||||||
|
# Goto keys
|
||||||
|
bind -s --preset gh end-selection beginning-of-line
|
||||||
|
bind -s --preset gj end-selection end-of-buffer
|
||||||
|
bind -s --preset gk end-selection beginning-of-buffer
|
||||||
|
bind -s --preset gl end-selection end-of-line
|
||||||
|
bind -s --preset gg end-selection beginning-of-buffer
|
||||||
|
|
||||||
|
# (Goto+Selection) keys
|
||||||
|
bind -s --preset -M default -m visual gH begin-selection beginning-of-line
|
||||||
|
bind -s --preset -M default -m visual gJ begin-selection end-of-buffer
|
||||||
|
bind -s --preset -M default -m visual gK begin-selection beginning-of-buffer
|
||||||
|
bind -s --preset -M default -m visual gL begin-selection end-of-line
|
||||||
|
bind -s --preset -M visual gH beginning-of-line
|
||||||
|
bind -s --preset -M visual gJ end-of-buffer
|
||||||
|
bind -s --preset -M visual gK beginning-of-buffer
|
||||||
|
bind -s --preset -M visual gL end-of-line
|
||||||
|
|
||||||
|
# Undo keys
|
||||||
|
bind -s --preset u undo
|
||||||
|
bind -s --preset U redo
|
||||||
|
|
||||||
|
# History navigation
|
||||||
|
bind -s --preset / history-pager --sets-mode insert repaint
|
||||||
|
|
||||||
|
bind -s --preset k up-or-search
|
||||||
|
bind -s --preset j down-or-search
|
||||||
|
bind -s --preset b -m visual backward-word
|
||||||
|
bind -s --preset B -m visual backward-bigword
|
||||||
|
bind -s --preset w -m visual forward-word forward-single-char
|
||||||
|
bind -s --preset W -m visual forward-bigword forward-single-char
|
||||||
|
|
||||||
|
# Backspace deletes a char in insert mode
|
||||||
|
bind -s --preset -M insert -k backspace backward-delete-char
|
||||||
|
bind -s --preset -M insert \ch backward-delete-char
|
||||||
|
bind -s --preset -M insert \x7f backward-delete-char
|
||||||
|
|
||||||
|
bind -s --preset -M visual d kill-selection
|
||||||
|
|
||||||
|
bind -s --preset '~' togglecase-char forward-single-char
|
||||||
|
bind -s --preset gu downcase-word
|
||||||
|
bind -s --preset gU upcase-word
|
||||||
|
|
||||||
|
bind -s --preset J end-of-line delete-char
|
||||||
|
bind -s --preset K 'man (commandline -t) 2>/dev/null; or echo -n \a'
|
||||||
|
|
||||||
|
bind -s --preset y yank-selection
|
||||||
|
|
||||||
|
bind -s --preset -m normal -M visual f forward-jump
|
||||||
|
bind -s --preset -m normal -M visual t forward-jump-till
|
||||||
|
bind -s --preset -m normal -M visual F backward-jump
|
||||||
|
bind -s --preset -m normal -M visual T backward-jump-till
|
||||||
|
|
||||||
|
bind -s --preset p forward-char yank
|
||||||
|
bind -s --preset P yank
|
||||||
|
bind -s --preset gp yank-pop
|
||||||
|
|
||||||
|
# same vim 'pasting' note as upper
|
||||||
|
bind -s --preset '"*p' forward-char "commandline -i ( xsel -p; echo )[1]"
|
||||||
|
bind -s --preset '"*P' "commandline -i ( xsel -p; echo )[1]"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Lowercase r, enters replace_one mode
|
||||||
|
#
|
||||||
|
bind -s --preset -m replace_one r repaint-mode
|
||||||
|
bind -s --preset -M replace_one -m default '' delete-char self-insert backward-char repaint-mode
|
||||||
|
bind -s --preset -M replace_one -m default \r 'commandline -f delete-char; commandline -i \n; commandline -f backward-char; commandline -f repaint-mode'
|
||||||
|
bind -s --preset -M replace_one -m default \e cancel repaint-mode
|
||||||
|
|
||||||
|
#
|
||||||
|
# Uppercase R, enters replace mode
|
||||||
|
#
|
||||||
|
bind -s --preset -m replace R repaint-mode
|
||||||
|
bind -s --preset -M replace '' delete-char self-insert
|
||||||
|
bind -s --preset -M replace -m insert \r execute repaint-mode
|
||||||
|
bind -s --preset -M replace -m default \e cancel repaint-mode
|
||||||
|
|
||||||
|
bind -s --preset -M visual -m insert c kill-selection end-selection repaint-mode
|
||||||
|
bind -s --preset -M visual -m default '~' togglecase-selection end-selection repaint-mode
|
||||||
|
|
||||||
|
bind -s --preset -M visual -m default \cc end-selection repaint-mode
|
||||||
|
bind -s --preset -M visual -m default \e end-selection repaint-mode
|
||||||
|
|
||||||
|
# Make it easy to turn an unexecuted command into a comment in the shell history. Also, remove
|
||||||
|
# the commenting chars so the command can be further edited then executed.
|
||||||
|
bind -s --preset -M default \# __fish_toggle_comment_commandline
|
||||||
|
bind -s --preset -M visual \# __fish_toggle_comment_commandline
|
||||||
|
bind -s --preset -M replace \# __fish_toggle_comment_commandline
|
||||||
|
|
||||||
|
# Set the cursor shape
|
||||||
|
# After executing once, this will have defined functions listening for the variable.
|
||||||
|
# Therefore it needs to be before setting fish_bind_mode.
|
||||||
|
set -g fish_vi_cursor inclusive
|
||||||
|
set -g fish_cursor_selection_mode inclusive
|
||||||
|
|
||||||
|
set fish_bind_mode $init_mode
|
|
@ -0,0 +1,31 @@
|
||||||
|
# This file contains fish universal variable definitions.
|
||||||
|
# VERSION: 3.0
|
||||||
|
SETUVAR __fish_initialized:3400
|
||||||
|
SETUVAR fish_color_autosuggestion:555\x1ebrblack
|
||||||
|
SETUVAR fish_color_cancel:\x2dr
|
||||||
|
SETUVAR fish_color_command:blue
|
||||||
|
SETUVAR fish_color_comment:red
|
||||||
|
SETUVAR fish_color_cwd:green
|
||||||
|
SETUVAR fish_color_cwd_root:red
|
||||||
|
SETUVAR fish_color_end:green
|
||||||
|
SETUVAR fish_color_error:brred
|
||||||
|
SETUVAR fish_color_escape:brcyan
|
||||||
|
SETUVAR fish_color_history_current:\x2d\x2dbold
|
||||||
|
SETUVAR fish_color_host:normal
|
||||||
|
SETUVAR fish_color_host_remote:yellow
|
||||||
|
SETUVAR fish_color_normal:normal
|
||||||
|
SETUVAR fish_color_operator:brcyan
|
||||||
|
SETUVAR fish_color_param:cyan
|
||||||
|
SETUVAR fish_color_quote:yellow
|
||||||
|
SETUVAR fish_color_redirection:cyan\x1e\x2d\x2dbold
|
||||||
|
SETUVAR fish_color_search_match:bryellow\x1e\x2d\x2dbackground\x3dbrblack
|
||||||
|
SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack
|
||||||
|
SETUVAR fish_color_status:red
|
||||||
|
SETUVAR fish_color_user:brgreen
|
||||||
|
SETUVAR fish_color_valid_path:\x2d\x2dunderline
|
||||||
|
SETUVAR fish_key_bindings:fish_default_key_bindings
|
||||||
|
SETUVAR fish_pager_color_completion:normal
|
||||||
|
SETUVAR fish_pager_color_description:B3A06D\x1eyellow\x1e\x2di
|
||||||
|
SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
|
||||||
|
SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan
|
||||||
|
SETUVAR fish_pager_color_selected_background:\x2dr
|
Loading…
Reference in New Issue