Skip to content

Commit dec3177

Browse files
committed
Added a couple simple example shell scripts demonstrating how to use tmux or byobu to launch a cmd2 application in a terminal multiplexer along with another application such as a shell.
One example uses windows/tabs and the other uses a split screen mode.
1 parent 9d3f227 commit dec3177

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

examples/tmux_launch.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env zsh
2+
3+
# This script launches two applications using tmux in different windows/tabs.
4+
# The user is required to enter the name of at least the first application.
5+
# If the second isn't provided, then the user's default shell is launched for this.
6+
# You must have tmux installed and that can be done using your operating system's package manager.
7+
#
8+
# See the tmux Wiki for info on how to use it: https://github.com/tmux/tmux/wiki.
9+
# To shift focus between different windows in tmux use Ctrl-b followed by l (lowercase "L").
10+
#
11+
# NOTE: IF you have byobu installed, it is a wrapper around tmux and will likely run instead of tmux.
12+
# For info on how to use Byobu, see: https://www.byobu.org/
13+
# To shift focus between windows/tabs in byobu, simply hit F3.
14+
15+
# Function to print in red
16+
print_red() {
17+
echo -e "\e[31m$*\e[0m"
18+
}
19+
20+
if [ $# -eq 0 ];
21+
then
22+
print_red "No arguments supplied and this script requires at least one"
23+
exit 1
24+
fi
25+
26+
FIRST_COMMAND=$1
27+
28+
if [ $# -eq 1 ]
29+
then
30+
SECOND_COMMAND=$SHELL
31+
else
32+
SECOND_COMMAND=$2
33+
fi
34+
35+
tmux new-session -s "tmux window demo" -n "$FIRST_COMMAND" "$FIRST_COMMAND ;read" \; \
36+
new-window -n "$SECOND_COMMAND" "$SECOND_COMMAND ; read" \; previous-window

examples/tmux_split.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env zsh
2+
3+
# This script launches two applications using byobu in different tabs.
4+
# The user is required to enter the name of at least the first application.
5+
# If the second isn't provided, then the user's default shell is launched for this.
6+
#
7+
# byobu must be installed for this script to work and you can install it using your
8+
# operating system package manager. or info on how to use Byobu, see: https://www.byobu.org/
9+
#
10+
# To shift focus between tabs in byobu, just hit F3.
11+
12+
# Function to print in red
13+
print_red() {
14+
echo -e "\e[31m$*\e[0m"
15+
}
16+
17+
if [ $# -eq 0 ];
18+
then
19+
print_red "No arguments supplied and this script requires at least one"
20+
exit 1
21+
fi
22+
23+
FIRST_COMMAND=$1
24+
25+
if [ $# -eq 1 ]
26+
then
27+
SECOND_COMMAND=$SHELL
28+
else
29+
SECOND_COMMAND=$2
30+
fi
31+
32+
tmux new-session "$FIRST_COMMAND ; read" \; \
33+
split-window "$SECOND_COMMAND ; read" \; \
34+
select-layout even-vertical

0 commit comments

Comments
 (0)