我在这里有这个脚本:
tmux send-keys "${@:1}" Enter
sleep 2.5; tmux capture-pane -p -S -32767
Run Code Online (Sandbox Code Playgroud)
该脚本捕获tmux窗格并打印输出。我注意到,如果tmux未打开窗格,输出将如下所示:
L 05/15/2018 - 16:07:43
: "thebravelittleMercen
ary<348><[U:1:313493299
]><Blue>" say "!resizem
ytorso"
BOI: !resizemyhands
L 05/15/2018 - 16:07:44
: "BOI<377><[U:1:453920
082]><Red>" say "!resiz
emyhands"
Run Code Online (Sandbox Code Playgroud)
实际上,它应如下所示:
L 05/15/2018 - 16:07:43: "thebravelittleMercenary<348><[U:1:313493299]><Blue>" say "!resizemytorso"
BOI: !resizemyhands
L 05/15/2018 - 16:07:44: "BOI<377><[U:1:453920082]><Red>" say "!resizemyhands"
Run Code Online (Sandbox Code Playgroud)
值得一提的是,当我执行tmux attach并捕获窗格时,输出行的长度与控制台宽度相同:http : //i.cubeupload.com/Rp1BEU.png
Titel几乎拥有它。我正在尝试做这--options args件事,但没有运行./command --option1 args --option2 args而是在做./command '--option1 args --option2 args。
array=( $1 )
POSITIONAL=()
while [[ ${#array[@]} -gt 0 ]]; do
key="${array[0]}"
case $key in
--title)
title="${array[1]}"
echo 1
shift
shift
;;
--artist)
artist="${array[1]}"
echo 2
shift
shift
;;
*) # unknown option
POSITIONAL+=("${array[0]}") # save it in an array for later
shift
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
Run Code Online (Sandbox Code Playgroud)
在此代码shift中不起作用。shift除了数组,有没有一种使用方法?