Rename commands would broke if the title contained '/'
liangkarl opened this issue · 2 comments
liangkarl commented
Hi,
I found out that the rename command would break if the window title contain /
.
My test steps are as below:
tmux new-session -s test
tmux rename-window -t "test:1" "foo/foo"
bash -x ~/.config/tmux/plugins/tmux-fzf/scripts/window.sh
and the log is like this
...
+ target_origin='[current]'
++ echo '[current]'
++ sed -E 's/\[current\]/test:1: foo/foo/'
sed: -e expression #1, char 27: unknown option to `s'
+ target_origin=
+ [[ '' == \[\c\a\n\c\e\l\] ]]
+ [[ -z '' ]]
+ exit
liangkarl commented
Hi,
I've made the simple changes to avoid the problem
commit a0816eb0915f55954eee97944065219115ed8f45
Refs: [tmux-fzf.#75], [master]
Author: Karl Liang <liang.karl@outlook.com>
AuthorDate: Mon Jan 15 16:13:56 2024 -0700
Commit: Karl Liang <liang.karl@outlook.com>
CommitDate: Mon Jan 15 16:22:35 2024 -0700
Fix the error for string replacement
---
scripts/pane.sh | 2 +-
scripts/window.sh | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/pane.sh b/scripts/pane.sh
index 215ab0b..50340fa 100755
--- a/scripts/pane.sh
+++ b/scripts/pane.sh
@@ -59,7 +59,7 @@ else
target_origin=$(printf "%s\n[cancel]" "$panes" | eval "$TMUX_FZF_BIN $TMUX_FZF_OPTIONS $TMUX_FZF_PREVIEW_OPTIONS")
else
target_origin=$(printf "[current]\n%s\n[cancel]" "$panes" | eval "$TMUX_FZF_BIN $TMUX_FZF_OPTIONS $TMUX_FZF_PREVIEW_OPTIONS")
- target_origin=$(echo "$target_origin" | sed -E "s/\[current\]/$current_pane_origin/")
+ target_origin=${target_origin/\[current\]/$current_pane_origin}
fi
[[ "$target_origin" == "[cancel]" || -z "$target_origin" ]] && exit
target=$(echo "$target_origin" | sed 's/: .*//')
diff --git a/scripts/window.sh b/scripts/window.sh
index 9ab7a8b..ab8bf06 100755
--- a/scripts/window.sh
+++ b/scripts/window.sh
@@ -53,7 +53,7 @@ else
fi
if [[ "$action" != "switch" ]]; then
target_origin=$(printf "[current]\n%s\n[cancel]" "$windows" | eval "$TMUX_FZF_BIN $TMUX_FZF_OPTIONS $TMUX_FZF_PREVIEW_OPTIONS")
- target_origin=$(echo "$target_origin" | sed -E "s/\[current\]/$current_window_origin/")
+ target_origin=${target_origin/\[current\]/$current_window_origin}
else
windows=$(echo "$windows" | grep -v "^$current_window")
target_origin=$(printf "%s\n[cancel]" "$windows" | eval "$TMUX_FZF_BIN $TMUX_FZF_OPTIONS $TMUX_FZF_PREVIEW_OPTIONS")
sainnhe commented
Sorry for late reply. Thanks for your fix!