Add a new option or parameter to enable "--no-sort"
Closed this issue · 8 comments
Hi,
I've used this plugin for a period of time and I met a problem on the history search. In my case, I'd like to jump to the earliest keyword appeared. For example, when there are some compilation errors appeared, I'd like to jump to the earliest one. However, without --no-sort
, fzf
would mess up the result.
I've tried to modify $FZF_DEFAULT_OPT
that does not work as there is no preserved position for appending --no-sort
in the fuzzback.sh
. I think this feature would be helpful if it could be added. Thanks.
Ok, yeah, the no-sort
was previously enabled by default, but due this issue, it was removed.
Would you like to have a keybinding to toggle it, or would you prefer an option and set it there permanently like you mentioned?
Thank you.
Yep, I saw the issue and realized that my suggesion is for another different usage.
If it's possible I'd suggest to keep both usages, instead of choosing one of them. The original configuration is limited to one keybinding making it hard to switch between these two kind of searching. So, I think maybe it's closed to "having a keybinding to toggle it" that you mentioned...?
Does adding something like this
set -g @fuzzback-finder-bind 'ctrl-s:toggle-sort'
# or whichever shortcut you prefer
to your tmux config work? that way you can toggle it on and off. That's what I meant with a keybinding.
Does adding something like this
set -g @fuzzback-finder-bind 'ctrl-s:toggle-sort' # or whichever shortcut you preferto your tmux config work? that way you can toggle it on and off. That's what I meant with a keybinding.
Yes, something like that.
Take your setting and my setting for example. Considering there are only two kinds of search methods (if we support this function,) if it could press the keys for different searches directly instead of pressing C-s
then <leader>j
, I think it would be better.
I'd prefer using the option I showed an example of. Creating a new launcher script is a lot more work than simply toggling sorting on and off with an existing option.
Got it. Thanks for your working~
I just tried some experiement such as deliver the arguments with the keybinding setting.
The idea is to extend @fuzzback-bind
format to <key>:<append-args>
So, we could get any different arguments according to the triggered <key>
.
And if we want to add more keybinding, the trick for scanning the variables, for example @fuzzback-bindX
, is still available.
However, I'm not sure if it would conflict your design of fuzzback
or not.
Please let me know if I got anything wrong. ^ ^"
Here is my draft diff
diff --git a/scripts/fuzzback.sh b/scripts/fuzzback.sh
index 9f415c2..1ed3ad5 100755
--- a/scripts/fuzzback.sh
+++ b/scripts/fuzzback.sh
@@ -59,7 +59,8 @@ fzf_popup_cmd() {
--with-nth="3.." \
--color="$4" \
--preview="$CURRENT_DIR/preview.sh $CAPTURE_FILENAME {}" \
- --preview-window="$preview_window"
+ --preview-window="$preview_window" \
+ $6
}
rev_cmd() {
@@ -285,6 +286,10 @@ fuzzback() {
fzf_colors="$(tmux_get '@fuzzback-fzf-colors' 'dark')"
fzf_hide_preview="$(tmux_get '@fuzzback-hide-preview' 0)"
+ # set -g @fuzzback-bind '<key>:<append-args>'
+ finder_args="$(tmux_get '@fuzzback-bind' '')"
+ finder_args="${finder_args##*:}"
+
pos=$(get_pos)
pane_height="$(tmux display-message -p '#{pane_height}')"
pos_rev=$(( pane_height - pos ))
@@ -302,7 +307,7 @@ fuzzback() {
# Combine head and tail when searching with fzf
if [ "$enable_popup" -eq 1 ];then
- match=$(cat "$tail_file" "$head_file" | fzf_popup_cmd "$popup_size" "$finder_bind" "$finder_layout" "$fzf_colors" "$fzf_hide_preview")
+ match=$(cat "$tail_file" "$head_file" | fzf_popup_cmd "$popup_size" "$finder_bind" "$finder_layout" "$fzf_colors" "$fzf_hide_preview" "$finder_args")
else
match=$(cat "$tail_file" "$head_file" | finder_split_cmd "$finder_bind" "$finder_layout" "$fuzzback_finder" "$fzf_colors" "$fzf_hide_preview")
fi
And my test config and log are as below
set -g @fuzzback-bind 'j:--no-sort'
Log
...
+ rm -f /tmp/tmux-1001-fuzzback/tmp-0-2-1
+ '[' 1 -eq 1 ']'
++ cat /tmp/tmux-1001-fuzzback/tail-0-2-1 /tmp/tmux-1001-fuzzback/head-0-2-1
++ fzf_popup_cmd 90% ctrl-s:toggle-sort default dark 0 --no-sort
++ local hide_preview=0
++ local preview_window=nowrap
++ '[' 0 -eq 1 ']'
++ fzf-tmux -p 90% --ansi --bind=ctrl-s:toggle-sort --delimiter=: --layout=default --no-multi --print-query --with-nth=3.. --color=dark '--preview=/home/karl/.config/tmux/plugins/tmux-
fuzzback/scripts/preview.sh /tmp/tmux-1001-fuzzback/capture-0-2-1 {}' --preview-window=nowrap --no-sort
...
Sorry, I saw the code you mentioned. No problem now. Thanks!