Skip to content

Commit 286eeca

Browse files
Added @fzf-url-open (#36)
* feature: added the setting 'custom_open' to specify a program to open the url/file. Can be used when xdg-open/open are installed but the user does not want to use them. * refactor: moved $custom_open inside of open_url function * docs: added fzf-url-open to the README. * bugfix: added quotes around custom_open --------- Co-authored-by: barts <[email protected]> Co-authored-by: barts <[email protected]>
1 parent 93ca6fc commit 286eeca

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ You can use custom fzf options by defining `@fzf-url-fzf-options`.
5656
set -g @fzf-url-fzf-options '-w 50% -h 50% --multi -0 --no-preview --no-border'
5757
```
5858

59+
By default, `tmux-fzf-url` will use `xdg-open`, `open`, or the `BROWSER`
60+
environment variable to open the url, respectively. If you want to use a
61+
different command, you can set `@fzf-url-open` to the command you want to use.
62+
63+
```tmux
64+
set -g @fzf-url-open "firefox"
65+
```
66+
5967
### 💡 Tips
6068

6169
- You can mark multiple urls and open them at once.

fzf-url.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ fzf_filter() {
1515
eval "fzf-tmux $(get_fzf_options)"
1616
}
1717

18+
custom_open=$3
1819
open_url() {
19-
if hash xdg-open &>/dev/null; then
20+
if [[ -n $custom_open ]]; then
21+
$custom_open "$@"
22+
elif hash xdg-open &>/dev/null; then
2023
nohup xdg-open "$@"
2124
elif hash open &>/dev/null; then
2225
nohup open "$@"
@@ -25,7 +28,6 @@ open_url() {
2528
fi
2629
}
2730

28-
2931
limit='screen'
3032
[[ $# -ge 2 ]] && limit=$2
3133

fzf-url.tmux

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ tmux_get() {
1717
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' '')"
20+
custom_open="$(tmux_get '@fzf-url-open' '')"
2021
echo "$extra_filter" > /tmp/filter
2122

22-
tmux bind-key "$key" run -b "$SCRIPT_DIR/fzf-url.sh '$extra_filter' $history_limit";
23+
tmux bind-key "$key" run -b "$SCRIPT_DIR/fzf-url.sh '$extra_filter' $history_limit '$custom_open'";

0 commit comments

Comments
 (0)