Shell script for byobu commands

You must write a shell script that opens a terminal byobuwith separate tabs. The first line opens a new session byobuand the subsequent lines connect to this session and open new tabs. This is a kind of terminal for opening automation.

Ex -

byobu new-session -s "Server" "redis-server"

byobu new-window "redis-cli"

byobu new-window "sudo mongod --port 27017 --dbpath /data/db/rs0 --replSet rs0"

byobu new-window "mongo"

The problem here is when I run this shell script, it only runs the first command and then stops. If I run it again, it will execute the remaining lines with the message:

repeating session: server

What am I doing wrong here?

+4
source share
1 answer

I think you are missing the first line from your shell script. See if it works

#!/bin/sh
# byobu_launcher.sh ver 20170915122301 Copyright 2017 alexx, MIT Licence ver 1.0

byobu new-session -d -s $USER

# redis window
byobu rename-window -t $USER:0 'redis-cli'
byoby send-keys "redis-cli" C-m
byobu split-window -v

# mongod
byobu new-window -t $USER:1 -n 'mongod'
byobu send-keys "sudo mongod --port 27017 --dbpath /data/db/rs0 --replSet rs0" C-m

# mongo
byobu new-window -t $USER:1 -n 'mongo'
byobu send-keys "mong" C-m

# Set default window as the dev split plane
byobu select-window -t $USER:1

# Attach to the session you just created
# (flip between windows with alt -left and right)
byobu attach-session -t $USER

, ~/.screenrc

screen -t redis-cli 0
stuff "redis-cli\n"
screen -t mongod 1
stuff "sudo mongod --port 27017 --dbpath /data/db/rs0 --replSet rs0\n"
screen -t mongo 2
stuff "mongo\n"
select 1

tmux. byoby.

+1

Source: https://habr.com/ru/post/1675811/


All Articles