forked from sainnhe/tmux-fzf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.sh
More file actions
executable file
·27 lines (23 loc) · 1003 Bytes
/
Copy pathmain.sh
File metadata and controls
executable file
·27 lines (23 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env bash
# Shell-agnostic directory detection
if [ -n "$FISH_VERSION" ]; then
# Fish shell - use fish-specific syntax
CURRENT_DIR="$(fish -c 'cd (dirname (status --current-filename)); and pwd')"
else
# Bash or other POSIX shell
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
fi
[ -z "$TMUX_FZF_ORDER" ] && TMUX_FZF_ORDER="copy-mode|session|window|pane|command|keybinding|clipboard|process"
source "$CURRENT_DIR/scripts/.envs"
items_origin="$(echo $TMUX_FZF_ORDER | tr '|' '\n')"
# remove copy-mode from options if we aren't in copy-mode
if [ "$(tmux display-message -p '#{pane_in_mode}')" -eq 0 ]; then
items_origin="$(echo "${items_origin}" | sed '/copy-mode/d')"
fi
if [ -n "$TMUX_FZF_MENU" ]; then
items_origin="${items_origin}\nmenu"
fi
items_origin="${items_origin}\n[cancel]"
item=$(echo "${items_origin}" | $TMUX_FZF_BIN $TMUX_FZF_OPTIONS )
[ "$item" = "[cancel]" ] || [ -z "$item" ] && exit
tmux run-shell -b "$CURRENT_DIR/scripts/${item}.sh"