Skip to content

Commit 231c835

Browse files
isidroassainnhe
authored andcommitted
Use simple commands (cut, head and tail)
Instead of the powerful sed
1 parent 608356a commit 231c835

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

scripts/command.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
55
source "$CURRENT_DIR/.envs"
66

77
target_origin=$(tmux list-commands)
8-
target=$(printf "[cancel]\n%s" "$target_origin" | eval "$TMUX_FZF_BIN $TMUX_FZF_OPTIONS" | grep -o '^[^[:blank:]]*')
8+
target=$(printf "[cancel]\n%s" "$target_origin" | eval "$TMUX_FZF_BIN $TMUX_FZF_OPTIONS" | cut -d ' ' -f 1)
99

1010
[[ "$target" == "[cancel]" || -z "$target" ]] && exit
1111
tmux command-prompt -I "$target"

scripts/keybinding.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,5 @@ target=$(tmux list-keys | sed '1s/^/[cancel]\n/' | eval "$TMUX_FZF_BIN $TMUX_FZF
99
[[ "$target" == "[cancel]" || -z "$target" ]] && exit
1010
if [[ -n $(echo "$target" | grep -o "copy-mode") && -z $(echo "$target" | grep -o "prefix") ]]; then
1111
tmux copy-mode
12-
echo "$target" | sed -E 's/^.{46}//g' | xargs tmux
13-
else
14-
echo "$target" | sed -E 's/^.{46}//g' | xargs tmux
1512
fi
13+
echo "$target" | awk '{ $1=$2=$3=$4=""; print $0 }' | sed 's/^ *//' | xargs tmux

scripts/menu.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ source "$CURRENT_DIR/.envs"
55

66
# get front end list
77
tmux_fzf_menu_origin=$TMUX_FZF_MENU
8-
front_end_list=$(echo -e "$tmux_fzf_menu_origin" | sed -n '1p')
9-
tmux_fzf_menu_origin=$(echo -e "$tmux_fzf_menu_origin" | sed '1,2d')
10-
while [[ $(echo -e "$tmux_fzf_menu_origin" | wc -l | xargs) != "0" && $(echo -e "$tmux_fzf_menu_origin" | wc -l | xargs) != "1" ]]; do
11-
front_end_list="$front_end_list\n"$(echo -e "$tmux_fzf_menu_origin" | sed -n '1p')
12-
tmux_fzf_menu_origin=$(echo -e "$tmux_fzf_menu_origin" | sed '1,2d')
8+
front_end_list=$(echo -e "$tmux_fzf_menu_origin" | head -1 )$'\n'
9+
tmux_fzf_menu_origin=$(echo -e "$tmux_fzf_menu_origin" | tail -n +3 )
10+
while [ $(echo -ne "$tmux_fzf_menu_origin" | wc -l ) -ge 2 ]; do
11+
front_end_list+=$(echo "$tmux_fzf_menu_origin" | head -1)$'\n'
12+
tmux_fzf_menu_origin=$(echo "$tmux_fzf_menu_origin" | tail -n +3)$'\n'
1313
done
14-
front_end_list=$(echo -e "$front_end_list" | sed '/^[[:space:]]*$/d')
1514

16-
target=$(printf "%s\n[cancel]" "$front_end_list" | eval "$TMUX_FZF_BIN $TMUX_FZF_OPTIONS")
15+
target=$(printf "%s[cancel]" "$front_end_list" | eval "$TMUX_FZF_BIN $TMUX_FZF_OPTIONS")
1716

1817
[[ "$target" == "[cancel]" || -z "$target" ]] && exit
1918
# get the next line in $TMUX_FZF_MENU and execute

0 commit comments

Comments
 (0)