mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-26 02:12:33 +01:00
New tmux plugin. Cleaner and general. Read the header to see how to configure it to launch applications. If you want the old irc behaviour, add an alias: alias irc="t irc".
This commit is contained in:
parent
1d573fc920
commit
110465a320
1 changed files with 19 additions and 24 deletions
|
|
@ -1,37 +1,32 @@
|
|||
# Enable autostarting of tmux with:
|
||||
#
|
||||
# zstyle :omz:plugins:tmux autostart on
|
||||
#
|
||||
# Configure t command to autostart a command like
|
||||
# this (example for "t irc"):
|
||||
# zstyle :omz:plugins:cmd irc weechat-curses
|
||||
#
|
||||
|
||||
if (( $+commands[tmux] )); then
|
||||
local state
|
||||
|
||||
# autoload tmux on start
|
||||
zstyle -a :omz:plugins:tmux autostart state
|
||||
[[ $state == "on" && -z $TMUX ]] && exec tmux
|
||||
|
||||
# start an irc client in a tmux session
|
||||
if [[ -n $IRC ]]; then
|
||||
irc() {
|
||||
if tmux has -t irc >/dev/null; then
|
||||
[[ -n $TMUX ]] && tmux switch -t irc || tmux attach -t irc
|
||||
else
|
||||
TMUX="" tmux new -ds irc $IRC[1]
|
||||
[[ -n $TMUX ]] && tmux switch -t irc || tmux attach -t irc
|
||||
fi
|
||||
}
|
||||
fi
|
||||
t() {
|
||||
#load the command from config
|
||||
zstyle -a :omz:plugins:tmux:cmd $1 cmd
|
||||
(( $+commands[$cmd] )) || return 127
|
||||
|
||||
# start rtorrent in a tmux session
|
||||
if [[ -n $RTORRENT ]]; then
|
||||
torrents() {
|
||||
if tmux has -t torrents >/dev/null; then
|
||||
[[ -n $TMUX ]] && tmux switch -t torrents || tmux attach -t torrents
|
||||
else
|
||||
TMUX="" tmux new -ds torrents $RTORRENT[1]
|
||||
[[ -n $TMUX ]] && tmux switch -t torrents || tmux attach -t torrents
|
||||
fi
|
||||
}
|
||||
fi
|
||||
# start the command
|
||||
if ! tmux has -t $1 2>/dev/null; then
|
||||
TMUX= tmux new -ds $1 ${cmd-$2}
|
||||
fi
|
||||
|
||||
# switch or attach depending on if we're inside tmux
|
||||
[[ -n $TMUX ]] && tmux switch -t $1 \
|
||||
|| tmux attach -t $1
|
||||
}
|
||||
else
|
||||
omz_log_mgs "notfound: plugin requires tmux"
|
||||
omz_log_mgs "tmux: plugin requires tmux"
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue