diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2015-03-08 15:08:27 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2015-03-08 15:08:27 +0900 |
commit | 23dba99eda58ddae147a2e907513fd0471c2014d (patch) | |
tree | e3c33f56f88a3c5d134285db35ef9fd52b6ea459 /bin | |
parent | 5f62d224b0cef3e39667d218cd74be34b2c8219c (diff) |
[fzf-tmux] Allow -w / -h without size argument
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/fzf-tmux | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/bin/fzf-tmux b/bin/fzf-tmux index b4e041d9..166c8111 100755 --- a/bin/fzf-tmux +++ b/bin/fzf-tmux @@ -1,6 +1,6 @@ #!/usr/bin/env bash # fzf-tmux: starts fzf in a tmux pane -# usage: fzf-tmux [-h HEIGHT[%]] [-w WIDTH[%]] [--] [FZF OPTIONS] +# usage: fzf-tmux [-h [HEIGHT[%]]] [-w [WIDTH[%]]] [--] [FZF OPTIONS] args=() opt="" @@ -8,15 +8,20 @@ while [ $# -gt 0 ]; do arg="$1" case "$arg" in -w*|-h*) + [[ "$arg" =~ ^-w ]] && opt="-h" || opt="" if [ ${#arg} -gt 2 ]; then size="${arg:2}" else shift - size="$1" + if [[ "$1" =~ ^[0-9]+%?$ ]]; then + size="$1" + else + [ -n "$1" ] && args+=("$1") + continue + fi fi - [[ "$arg" =~ ^-w ]] && opt="-h" - [[ "$size" =~ %$ ]] && opt="$opt -p ${size:0:((${#size}-1))}" || - opt="$opt -l $size" + [[ "$size" =~ %$ ]] && opt="$opt -p ${size:0:((${#size}-1))}" || + opt="$opt -l $size" ;; --) # "--" can be used to separate fzf-tmux options from fzf options to |