我想打开一个新的tmux会话和窗口,其中包含cmus,或者,如果已经在运行,则附加到它。在Ubuntuusers,我找到了这个脚本,它应该可以做到这一点。
1. #!/bin/bash
2. SESSION=main
3. tmux="tmux -2 -f tmux.conf"
4.
5. # if the session is already running, just attach to it.
5. $tmux has-session -t $SESSION
7. if [ $? -eq 0 ]; then
8. echo "Session $SESSION already exists. Attaching."
9. sleep 1
10. $tmux attach -t $SESSION
11. exit 0;
12. fi我已经知道我可以用手工来做
tmux new -n music cmus但是当我在脚本中使用它时,我只能得到这样的消息
usage: new-session [-d] [-n window-name] [-s session-name] [-t target-session] [-x width] [-y height] [command]我也尝试了使用new-session,但没有变化。我完全不知道命令和/或脚本有什么问题
发布于 2012-12-07 02:55:13
我解决这个问题的方法是有一个主要的tmux会话,像mutt或cmus这样的程序可以启动或连接。例如,对于cmus,我有一个别名:
alias cmus='monkeys -n music cmus'猴子是下面的脚本:
#! /bin/sh
name=monkeys
# make sure tmux server is running:
tmux start-server
# determine if monkeys session is running:
tmux has-session -t ${name}
# no monkeys running, create monkeys,
# if more than one argument, take it as a command to run
# on monkeys, else just attach to monkeys
if [ "$?" != "0" ]; then
tmux new-session -s ${name} $*
elif [ $# -gt 0 ]; then
tmux new-window -t ${name} $*
else
tmux a -t ${name}
fihttps://stackoverflow.com/questions/13749886
复制相似问题