Need to write a shell script that opens byobu
terminal with separate tabs. First line opens new byobu
session and subsequent lines connect to that session and open new tabs. Its kind of automate opening terminal.
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"
Problem here is when I run once this shell script it runs only first command and then stops. If I run it again then it executes the remaining lines with the message:
duplicate session: Server
What am I doing wrong here ?
I think you are missing the first line from your shell script. See if this 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
with screen you can do this bu adding to the end of ~/.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
I mostly use screen and sometimes use tmux. I haven't used byoby.
来源:https://stackoverflow.com/questions/43662209/shell-script-for-byobu-commands