mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-12-01 09:13:55 +00:00
[fzf-tmux] Allow -w / -h without size argument
This commit is contained in:
parent
5f62d224b0
commit
23dba99eda
@ -152,7 +152,7 @@ installer-generated source code: `~/.fzf.bash`, `~/.fzf.zsh`, and
|
|||||||
[fzf-tmux](bin/fzf-tmux) is a bash script that opens fzf in a tmux pane.
|
[fzf-tmux](bin/fzf-tmux) is a bash script that opens fzf in a tmux pane.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# usage: fzf-tmux [-h HEIGHT[%]] [-w WIDTH[%]] [--] [FZF OPTIONS]
|
# usage: fzf-tmux [-h [HEIGHT[%]]] [-w [WIDTH[%]]] [--] [FZF OPTIONS]
|
||||||
|
|
||||||
# select git branches in horizontal split (15 lines)
|
# select git branches in horizontal split (15 lines)
|
||||||
git branch | fzf-tmux -h 15
|
git branch | fzf-tmux -h 15
|
||||||
|
15
bin/fzf-tmux
15
bin/fzf-tmux
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# fzf-tmux: starts fzf in a tmux pane
|
# 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=()
|
args=()
|
||||||
opt=""
|
opt=""
|
||||||
@ -8,15 +8,20 @@ while [ $# -gt 0 ]; do
|
|||||||
arg="$1"
|
arg="$1"
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
-w*|-h*)
|
-w*|-h*)
|
||||||
|
[[ "$arg" =~ ^-w ]] && opt="-h" || opt=""
|
||||||
if [ ${#arg} -gt 2 ]; then
|
if [ ${#arg} -gt 2 ]; then
|
||||||
size="${arg:2}"
|
size="${arg:2}"
|
||||||
else
|
else
|
||||||
shift
|
shift
|
||||||
size="$1"
|
if [[ "$1" =~ ^[0-9]+%?$ ]]; then
|
||||||
|
size="$1"
|
||||||
|
else
|
||||||
|
[ -n "$1" ] && args+=("$1")
|
||||||
|
continue
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
[[ "$arg" =~ ^-w ]] && opt="-h"
|
[[ "$size" =~ %$ ]] && opt="$opt -p ${size:0:((${#size}-1))}" ||
|
||||||
[[ "$size" =~ %$ ]] && opt="$opt -p ${size:0:((${#size}-1))}" ||
|
opt="$opt -l $size"
|
||||||
opt="$opt -l $size"
|
|
||||||
;;
|
;;
|
||||||
--)
|
--)
|
||||||
# "--" can be used to separate fzf-tmux options from fzf options to
|
# "--" can be used to separate fzf-tmux options from fzf options to
|
||||||
|
Loading…
Reference in New Issue
Block a user