Skip to content

Commit d76f3ea

Browse files
josephschmittopencode
andcommitted
Make alphabetical sorting the default for backward compatibility
- Changed default from 'recency' to 'alphabetical' to preserve existing behavior - Users can opt-in to recency sorting by setting @fzf-url-sort-by 'recency' - Updated documentation to reflect alphabetical as default - Maintains full backward compatibility with existing configurations 🤖 Generated with [opencode](https://opencode.ai) Co-Authored-By: opencode <[email protected]>
1 parent 95a78ff commit d76f3ea

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ set -g @fzf-url-fzf-options '-w 50% -h 50% --multi -0 --no-preview --no-border'
5959
You can control how URLs are sorted by setting `@fzf-url-sort-by`:
6060

6161
```tmux
62-
# Sort URLs by recency (default) - most recent URLs closest to search bar
63-
set -g @fzf-url-sort-by 'recency'
64-
65-
# Sort URLs alphabetically - original behavior
62+
# Sort URLs alphabetically (default) - original behavior
6663
set -g @fzf-url-sort-by 'alphabetical'
64+
65+
# Sort URLs by recency - most recent URLs closest to search bar
66+
set -g @fzf-url-sort-by 'recency'
6767
```
6868

6969
**Smart Layout Detection**: When using recency sorting, the plugin automatically detects your fzf layout and adjusts the sort order to keep the most recent URLs closest to the search bar:

fzf-url.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,8 @@ fi
5353
all_urls=$(printf '%s\n' "${urls[@]}" "${wwws[@]}" "${gh[@]}" "${ips[@]}" "${gits[@]}" "${extras[@]}" | grep -v '^$')
5454

5555
# Sort and deduplicate based on sort_by option
56-
if [[ "$sort_by" == "alphabetical" ]]; then
57-
# Original behavior: sort alphabetically and remove duplicates
58-
items=$(echo "$all_urls" | cut -d: -f2- | sort -u | nl -w3 -s ' ')
59-
else
60-
# Default recency behavior: adjust sort order based on fzf layout
56+
if [[ "$sort_by" == "recency" ]]; then
57+
# Recency behavior: adjust sort order based on fzf layout
6158
fzf_options="$(get_fzf_options)"
6259
if [[ "$fzf_options" == *"--reverse"* ]]; then
6360
# Reverse layout (search at top): oldest URLs first so recent ones are closest to search
@@ -75,6 +72,9 @@ else
7572
print $1 ":" url
7673
}
7774
}' | sort $sort_order | cut -d: -f2- | nl -w3 -s ' ')
75+
else
76+
# Default alphabetical behavior: sort alphabetically and remove duplicates
77+
items=$(echo "$all_urls" | cut -d: -f2- | sort -u | nl -w3 -s ' ')
7878
fi
7979
[ -z "$items" ] && tmux display 'tmux-fzf-url: no URLs found' && exit
8080

fzf-url.tmux

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ key="$(tmux_get '@fzf-url-bind' 'u')"
1818
history_limit="$(tmux_get '@fzf-url-history-limit' 'screen')"
1919
extra_filter="$(tmux_get '@fzf-url-extra-filter' '')"
2020
custom_open="$(tmux_get '@fzf-url-open' '')"
21-
sort_by="$(tmux_get '@fzf-url-sort-by' 'recency')"
21+
sort_by="$(tmux_get '@fzf-url-sort-by' 'alphabetical')"
2222
echo "$extra_filter" > /tmp/filter
2323

2424
tmux bind-key "$key" run -b "$SCRIPT_DIR/fzf-url.sh '$extra_filter' $history_limit '$custom_open' '$sort_by'";

0 commit comments

Comments
 (0)