Compare commits
2 Commits
50979acc1f
...
7acd099b3e
| Author | SHA1 | Date | |
|---|---|---|---|
|
7acd099b3e
|
|||
|
e502cff8cb
|
+2
-1
@@ -9,7 +9,8 @@ end
|
|||||||
# This variable is global so that it can be referenced by fzf_configure_bindings and in tests
|
# This variable is global so that it can be referenced by fzf_configure_bindings and in tests
|
||||||
set --global _fzf_search_vars_command '_fzf_search_variables (set --show | psub) (set --names | psub)'
|
set --global _fzf_search_vars_command '_fzf_search_variables (set --show | psub) (set --names | psub)'
|
||||||
|
|
||||||
# Install the default bindings, which are mnemonic and minimally conflict with fish's preset bindings
|
# Install the default bindings only if fzf is available
|
||||||
|
type -q fzf || exit
|
||||||
fzf_configure_bindings
|
fzf_configure_bindings
|
||||||
|
|
||||||
# Doesn't erase autoloaded _fzf_* functions because they are not easily accessible once key bindings are erased
|
# Doesn't erase autoloaded _fzf_* functions because they are not easily accessible once key bindings are erased
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ function fish_user_key_bindings
|
|||||||
bind ctrl-g __insert_previous_path_head
|
bind ctrl-g __insert_previous_path_head
|
||||||
bind ctrl-f __interactive_history_sub
|
bind ctrl-f __interactive_history_sub
|
||||||
bind ctrl-alt-u _replace_command_token
|
bind ctrl-alt-u _replace_command_token
|
||||||
bind ctrl-alt-= _qalc_eval
|
type -q qalc && bind ctrl-alt-= _qalc_eval
|
||||||
bind ctrl-enter _smart_execute
|
bind ctrl-enter _smart_execute
|
||||||
|
|
||||||
# Set bindings for all Vi modes:
|
# Set bindings for all Vi modes:
|
||||||
@@ -61,7 +61,7 @@ function fish_user_key_bindings
|
|||||||
bind --mode $mode ctrl-g __insert_previous_path_head
|
bind --mode $mode ctrl-g __insert_previous_path_head
|
||||||
bind --mode $mode ctrl-f __interactive_history_sub
|
bind --mode $mode ctrl-f __interactive_history_sub
|
||||||
bind --mode $mode ctrl-alt-u _replace_command_token
|
bind --mode $mode ctrl-alt-u _replace_command_token
|
||||||
bind --mode $mode ctrl-alt-= _qalc_eval
|
type -q qalc && bind --mode $mode ctrl-alt-= _qalc_eval
|
||||||
bind --mode $mode ctrl-enter _smart_execute
|
bind --mode $mode ctrl-enter _smart_execute
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
# Returns the result of a qalc calculation
|
# Returns the result of a qalc calculation
|
||||||
function _qalc_eval
|
function _qalc_eval
|
||||||
|
type -q qalc || return 1
|
||||||
|
|
||||||
# Get the current command line buffer
|
# Get the current command line buffer
|
||||||
set -l cmd (commandline)
|
set -l cmd (commandline)
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ function _smart_execute --description 'Execute different functions based on the
|
|||||||
# 2. Dispatch based on buffer content
|
# 2. Dispatch based on buffer content
|
||||||
switch "$cmd"
|
switch "$cmd"
|
||||||
case '*='
|
case '*='
|
||||||
# If it ends in =, run qalc
|
# If it ends in =, run qalc; fall back to normal execute if qalc is absent
|
||||||
_qalc_eval
|
_qalc_eval; or commandline -f execute
|
||||||
|
|
||||||
# case 'g *'
|
# case 'g *'
|
||||||
# # EXAMPLE FUTURE EXTENSION
|
# # EXAMPLE FUTURE EXTENSION
|
||||||
|
|||||||
+10
-2
@@ -31,6 +31,14 @@ function fzf_key_bindings
|
|||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# bg-transform runs the preview toggle in a background thread (non-blocking).
|
||||||
|
# It was added after fzf 0.60; fall back to the synchronous transform on older builds.
|
||||||
|
set -l _fzf_ver (fzf --version | string match -r '^(\d+)\.(\d+)')
|
||||||
|
set -l _fzf_transform_action transform
|
||||||
|
if test -n "$_fzf_ver[3]"; and test "$_fzf_ver[3]" -ge 62
|
||||||
|
set _fzf_transform_action bg-transform
|
||||||
|
end
|
||||||
|
|
||||||
#----BEGIN INCLUDE common.fish
|
#----BEGIN INCLUDE common.fish
|
||||||
# NOTE: Do not directly edit this section, which is copied from "common.fish".
|
# NOTE: Do not directly edit this section, which is copied from "common.fish".
|
||||||
# To modify it, one can edit "common.fish" and run "./update.sh" to apply
|
# To modify it, one can edit "common.fish" and run "./update.sh" to apply
|
||||||
@@ -177,7 +185,7 @@ function fzf_key_bindings
|
|||||||
commandline -f repaint
|
commandline -f repaint
|
||||||
end
|
end
|
||||||
|
|
||||||
function fzf-history-widget -d "Show command history"
|
function fzf-history-widget --inherit-variable _fzf_transform_action -d "Show command history"
|
||||||
set -l -- command_line (commandline)
|
set -l -- command_line (commandline)
|
||||||
set -l -- current_line (commandline -L)
|
set -l -- current_line (commandline -L)
|
||||||
set -l -- total_lines (count $command_line)
|
set -l -- total_lines (count $command_line)
|
||||||
@@ -206,7 +214,7 @@ function fzf_key_bindings
|
|||||||
|
|
||||||
# Prepend the options to allow user customizations
|
# Prepend the options to allow user customizations
|
||||||
set -p -- FZF_DEFAULT_OPTS \
|
set -p -- FZF_DEFAULT_OPTS \
|
||||||
'--bind="focus,resize:bg-transform:if test \\"$FZF_COLUMNS\\" -gt 100 -a \\\\( \\"$FZF_SELECT_COUNT\\" -gt 0 -o \\\\( -z \\"$FZF_WRAP\\" -a (string length -- {}) -gt (math $FZF_COLUMNS - 4) \\\\) -o (string collect -- {2..} | fish_indent | count) -gt 1 \\\\); echo show-preview; else echo hide-preview; end"' \
|
'--bind="focus,resize:'$_fzf_transform_action':if test \\"$FZF_COLUMNS\\" -gt 100 -a \\\\( \\"$FZF_SELECT_COUNT\\" -gt 0 -o \\\\( -z \\"$FZF_WRAP\\" -a (string length -- {}) -gt (math $FZF_COLUMNS - 4) \\\\) -o (string collect -- {2..} | fish_indent | count) -gt 1 \\\\); echo show-preview; else echo hide-preview; end"' \
|
||||||
'--preview="string collect -- (test \\"$FZF_SELECT_COUNT\\" -gt 0; and string collect -- {+2..}) \\"\\n# \\"'$date_cmd' {2..} | fish_indent --ansi"' \
|
'--preview="string collect -- (test \\"$FZF_SELECT_COUNT\\" -gt 0; and string collect -- {+2..}) \\"\\n# \\"'$date_cmd' {2..} | fish_indent --ansi"' \
|
||||||
'--preview-window="right,50%,wrap-word,follow,info,hidden"'
|
'--preview-window="right,50%,wrap-word,follow,info,hidden"'
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user