|
11 | 11 | end |
12 | 12 |
|
13 | 13 | # aliases |
14 | | -function _build_tmux_alias |
15 | | - set alias_name $argv[1] |
16 | | - set tmux_cmd $argv[2] |
17 | | - set ts_flag $argv[3] |
18 | | - set full_cmd "command tmux $tmux_cmd $ts_flag" |
19 | | - |
20 | | - eval " |
21 | | - function $alias_name --wraps='$full_cmd' --description 'alias $alias_name=$full_cmd' |
22 | | - # check if the first argument for this function is empty or starts with '-' |
23 | | - if test (count \$argv) -eq 0 || test (string sub -l 1 \$argv[1]) = '-' |
24 | | - command tmux $tmux_cmd \$argv |
25 | | - else |
26 | | - $full_cmd \$argv |
| 14 | +alias tmux=_fish_tmux_plugin_run |
| 15 | +function _fish_tmux_create_aliases --on-variable fish_tmux_no_alias |
| 16 | + if test "$fish_tmux_no_alias" != true |
| 17 | + function _build_tmux_alias |
| 18 | + set alias_name $argv[1] |
| 19 | + set tmux_cmd $argv[2] |
| 20 | + set ts_flag $argv[3] |
| 21 | + set full_cmd "command tmux $tmux_cmd $ts_flag" |
| 22 | + |
| 23 | + eval " |
| 24 | + function $alias_name --wraps='$full_cmd' --description 'alias $alias_name=$full_cmd' |
| 25 | + # check if the first argument for this function is empty or starts with '-' |
| 26 | + if test (count \$argv) -eq 0 || test (string sub -l 1 \$argv[1]) = '-' |
| 27 | + command tmux $tmux_cmd \$argv |
| 28 | + else |
| 29 | + $full_cmd \$argv |
| 30 | + end |
| 31 | + end |
| 32 | + " |
27 | 33 | end |
| 34 | + |
| 35 | + alias tds=_fish_tmux_directory_session |
| 36 | + alias tksv="command tmux kill-server" |
| 37 | + alias tl="command tmux list-sessions" |
| 38 | + alias tmuxconf="$EDITOR $fish_tmux_config" |
| 39 | + # `-t` and `-s` flag for tmux commands require argument |
| 40 | + # so we remove the flag when called without argument and run normally when called with argument |
| 41 | + # see: https://github.com/ohmyzsh/ohmyzsh/issues/12230 |
| 42 | + _build_tmux_alias "ta" "attach" "-t" |
| 43 | + _build_tmux_alias "tad" "attach -d" "-t" |
| 44 | + _build_tmux_alias "ts" "new-session" "-s" |
| 45 | + _build_tmux_alias "tkss" "kill-session" "-t" |
| 46 | + |
| 47 | + functions -e _build_tmux_alias # remove this function after use |
| 48 | + else |
| 49 | + functions -e tds tksv tl tmuxconf ta tad ts tkss |
28 | 50 | end |
29 | | - " |
30 | 51 | end |
31 | | - |
32 | | -alias tmux=_fish_tmux_plugin_run |
33 | | -alias tds=_fish_tmux_directory_session |
34 | | -alias tksv="command tmux kill-server" |
35 | | -alias tl="command tmux list-sessions" |
36 | | -alias tmuxconf="$EDITOR $fish_tmux_config" |
37 | | -# `-t` and `-s` flag for tmux commands require argument |
38 | | -# so we remove the flag when called without argument and run normally when called with argument |
39 | | -# see: https://github.com/ohmyzsh/ohmyzsh/issues/12230 |
40 | | -_build_tmux_alias "ta" "attach" "-t" |
41 | | -_build_tmux_alias "tad" "attach -d" "-t" |
42 | | -_build_tmux_alias "ts" "new-session" "-s" |
43 | | -_build_tmux_alias "tkss" "kill-session" "-t" |
44 | | - |
45 | | -functions -e _build_tmux_alias # remove this function after use |
| 52 | +_fish_tmux_create_aliases |
46 | 53 |
|
47 | 54 | # wrapper function for tmux |
48 | 55 | function _fish_tmux_plugin_run |
|
0 commit comments