summaryrefslogtreecommitdiff
path: root/shell/completion.bash
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2025-01-27 01:10:08 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2025-01-27 01:10:08 +0900
commite91f10ab167f10328816fab65fc38370059986f3 (patch)
treef8e7d059843f3a7a81835a888fe29d7588ee4038 /shell/completion.bash
parent2c15cd792306119ead573c473c982b6996e11952 (diff)
downloadfzf-e91f10ab167f10328816fab65fc38370059986f3.tar.gz
Enhance click-header event
* Expose the name of the mouse action as $FZF_KEY * Trigger click-header on mouse up * Enhanced clickable header for `kill` completion
Diffstat (limited to 'shell/completion.bash')
-rw-r--r--shell/completion.bash26
1 files changed, 25 insertions, 1 deletions
diff --git a/shell/completion.bash b/shell/completion.bash
index aa15b8ca..0c53e8e6 100644
--- a/shell/completion.bash
+++ b/shell/completion.bash
@@ -409,8 +409,32 @@ _fzf_complete_kill() {
}
_fzf_proc_completion() {
+ local transformer
+ transformer='
+ if [[ $FZF_KEY =~ ctrl|alt|shift ]] && [[ -n $FZF_NTH ]]; then
+ nths=( $(tr , " " <<< "$FZF_NTH") )
+ new_nths=()
+ found=0
+ for nth in ${nths[@]}; do
+ if [[ $nth = $FZF_CLICK_HEADER_NTH ]]; then
+ found=1
+ else
+ new_nths+=($nth)
+ fi
+ done
+ [[ $found = 0 ]] && new_nths+=($FZF_CLICK_HEADER_NTH)
+ new_nths=$(echo ${new_nths[@]} | tr " " ,)
+ echo "change-nth($new_nths)+change-prompt($new_nths> )"
+ else
+ if [[ $FZF_NTH = $FZF_CLICK_HEADER_NTH ]]; then
+ echo "change-nth()+change-prompt(> )"
+ else
+ echo "change-nth($FZF_CLICK_HEADER_NTH)+change-prompt($FZF_CLICK_HEADER_WORD> )"
+ fi
+ fi
+ '
_fzf_complete -m --header-lines=1 --no-preview --wrap --color fg:dim,nth:regular \
- --bind 'click-header:transform:echo "change-nth($FZF_CLICK_HEADER_NTH)+change-prompt($FZF_CLICK_HEADER_WORD> )"' -- "$@" < <(
+ --bind "click-header:transform:$transformer" -- "$@" < <(
command ps -eo user,pid,ppid,start,time,command 2> /dev/null ||
command ps -eo user,pid,ppid,time,args 2> /dev/null || # For BusyBox
command ps --everyone --full --windows # For cygwin