You are not logged in.

#1 2013-12-11 20:39:08

wolfdogg
Member
From: Portland, OR, USA
Registered: 2011-05-21
Posts: 545

gnu screen - would like a title line before running a command

I have a screen session im configuring which opens a screen, then vertically splits, then opens 4 more on the right.    some of these screens are running commands right off the bat, for example mysql -p.   

Im trying to figure out how to echo out a title before this command is run, so that instead of in the mysql screen saying

Enter password:

I want it to say

Logging into Mysql:
Enter password:

i tried various version of echo, but cant get a line to print on the top of each screen which i need a line of text.

heres my .screenrc

$ cat .screenrc
startup_message off
activity "%c activity -> %n%f %t"
caption always "%{= Wk}%-w%{= Bw}%n %t%{-}%+w %-="
vbell off
#term screen-256color
escape ``

#hardstatus alwayslastline
#hardstatus string "%-w%{= BW}%50>%n %t%{-}%+w%<"

#archlinux
hardstatus off
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W} %c %{g}]'
backtick 1 5 5 true
termcapinfo rxvt* 'hs:ts=\E]2;:fs=\007:ds=\E]2;\007'
#hardstatus string "screen (%n: %t)"
caption string "%{= kw}%Y-%m-%d;%c %{= kw}%-Lw%{= kG}%{+b}[%n %t]%{-b}%{= kw}%+Lw%1`"
caption always

# Enable 256-color mode when screen is started with TERM=xterm-256color
# Taken from: [url]http://frexx.de/xterm-256-notes/[/url]
#
# Note that TERM != "xterm-256color" within a screen window. Rather it is
# "screen" or "screen-bce"

# terminfo and termcap for nice 256 color terminal
# allow bold colors - necessary for some reason
attrcolor b ".I"
# tell screen how to set colors. AB = background, AF=foreground
#termcapinfo xterm-256color 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
terminfo xterm-color hs@:cs=\E[%i%p1%d;%p2%dr:im=\E[4h:ei=\E[4l
term xterm-color

# Don't block command output if the terminal stops responding
# (like if the ssh connection times out for example).
nonblock on

bind 'K' kill
bind 'W' windowlist
bind 'V' split -v

#shelltitle     custom screen

# F8 to turn the status bar off
#bindkey -k k8 hardstatus alwayslastline
# F9 to turn the status bar on
#bindkey -k k9 hardstatus alwaysignore
# F5 and F6 to move one screen forward or backward
#bind F7 to change focus
bindkey -k k7 focus up
bindkey -k k5 prev
bindkey -k k6 next

#use x scrolling method of scrollbar
#termcapinfo xterm* ti@:te@

#screens
screen -t       Main    1       bash
echo -n Main vertical screen
#echo -ne '\ekcommand-line\e\\'
#echo -e "\033[s\033[2;0HHello World!            \n                        \033[u"
vert_split
focus down

screen -t       top     2       top
select          top
split
focus down

screen -t       php.ini         3        vim /etc/php/php.ini
select          php.ini
opening php.ini
#chdir /etc/php
#exec vim php.ini
split
focus down

screen -t       httpd   4       bash
select          httpd
echo -n restarting htttpd
exec sudo systemctl restart httpd
split
focus down

#screen -t      Bash5   5       bash
#select         Bash5
#split
#focus down

screen -t       mysq1   5       mysql -p
echo -n Logging you into mysql:

#go to default screen now
#go back to first window
focus top

# Allow editors etc. to restore display on exit
# rather than leaving existing text in place
altscreen on

Last edited by wolfdogg (2013-12-11 20:41:21)


Node.js, PHP Software Architect and Engineer (Full-Stack/DevOps)
GitHub  | LinkedIn

Offline

#2 2013-12-11 20:40:34

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: gnu screen - would like a title line before running a command

Please learn how to paste code to the boards: https://wiki.archlinux.org/index.php/Fo … s_and_Code


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2013-12-11 20:41:55

wolfdogg
Member
From: Portland, OR, USA
Registered: 2011-05-21
Posts: 545

Re: gnu screen - would like a title line before running a command

geese, give a man a chance....
i.e. more than 86 seconds  :-)
That was a quick response though, too bad it didnt contain a quick answer too, lol.

Last edited by wolfdogg (2013-12-11 20:44:12)


Node.js, PHP Software Architect and Engineer (Full-Stack/DevOps)
GitHub  | LinkedIn

Offline

#4 2013-12-11 20:50:20

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: gnu screen - would like a title line before running a command

From your .screenrc, rather than calling mysql, call a wrapper that echoes your desired text and then launches mysql.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2013-12-11 20:59:30

wolfdogg
Member
From: Portland, OR, USA
Registered: 2011-05-21
Posts: 545

Re: gnu screen - would like a title line before running a command

ok, should i launch bash first from the screen -t line,
then use exec wtih the wrapper?  or do you think that will work all from the screen -t line?


Node.js, PHP Software Architect and Engineer (Full-Stack/DevOps)
GitHub  | LinkedIn

Offline

#6 2013-12-11 21:04:26

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: gnu screen - would like a title line before running a command

I don't know how screen works, but I imagine it is similar to tmux, in which case I'd just:

screen -t       mysq1   5       /path/to/launchmysqlscript

And in the launchmysqlscript

printf "%s\n" "Logging into MySQL" && mysql -p

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#7 2013-12-11 21:21:16

wolfdogg
Member
From: Portland, OR, USA
Registered: 2011-05-21
Posts: 545

Re: gnu screen - would like a title line before running a command

ok i see what your saying.  thanks.  yes its basically the same.  are you thinking then that there isnt a command that already allows a simple line to be output before a command is run, i.e.

screen -t       mysq1   5       bash
echo -n Logging you into mysql:
exec mysql -p

but it appears echo isnt the right command for this.    heres the link for the commands list http://aperiodic.net/screen/commands:start but i cant seem to find one appropriate for the job to replace the 'echo'  portion with.  Or maybe the echo is the correct one, and the line just isnt displaying because of the fact that the screen is being split, which is kind of what i was expecting to be the problem.


Node.js, PHP Software Architect and Engineer (Full-Stack/DevOps)
GitHub  | LinkedIn

Offline

Board footer

Powered by FluxBB