quando inicia a sessão com qualquer nome como estescreen -S name1
eu quero abrir janelas de abas nesta sessão de tela como quando abrimos abas no gnome-terminal assim
gnome-terminal --tab -e "some commands"
então como fazer isso?
Responder1
1. Guias na tela
Você está procurando isso para adicionar ao seu arquivo .screenrc:
screen -t tab1
screen -t tab2
Aqui está um bom .screenrc básico para você começar com uma barra de status, etc.OBSERVAÇÃO:Geralmente, ele está localizado em seu diretório inicial /home/<username>/.screenrc
.
screen -t validate #rtorrent
screen -t compile #irssi
screen -t bash3
screen -t bash4
screen -t bash5
altscreen on
term screen-256color
bind ',' prev
bind '.' next
#
#change the hardstatus settings to give an window list at the bottom of the
#screen, with the time and date and with the current window highlighted
hardstatus alwayslastline
#hardstatus string '%{= kG}%-Lw%{= kW}%50> %n%f* %t%{= kG}%+Lw%< %{= kG}%-=%c:%s%{-}'
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]'
captura de tela
2. Guias na tela (com comandos executados dentro)
O exemplo .screenrc
abaixo criará 2 guias e executará 3 comandos de eco em cada uma.
screen -t tab1
select 0
stuff "echo 'tab1 cmd1'; echo 'tab1 cmd2'; echo 'tab1 cmd3'^M"
screen -t tab2
select 1
stuff "echo 'tab2 cmd1'; echo 'tab2 cmd2'; echo 'tab2 cmd3'^M"
altscreen on
term screen-256color
bind ',' prev
bind '.' next
#
#change the hardstatus settings to give an window list at the bottom of the
#screen, with the time and date and with the current window highlighted
hardstatus alwayslastline
#hardstatus string '%{= kG}%-Lw%{= kW}%50> %n%f* %t%{= kG}%+Lw%< %{= kG}%-=%c:%s%{-}'
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]'
Esta técnica faz uso de telas select
e stuff
comandos para selecionar inicialmente uma das guias e, em seguida, "colocar" uma string nela.
captura de tela
3. Criando o número 2 sem usar um .screenrc
arquivo
Se você está procurando o cenário em que pode:
- criar uma sessão de tela
- carregue-o com guias
- faça com que cada guia execute seus próprios comandos
- não requer um
.screenrc
arquivo
Então este é o ideal para você! Esteja preparado embora. Este pode ser um pouco complicado com as linhas de comando.
Para começar, vamos criar uma sessão de tela:
$ screen -AdmS myshell -t tab0 bash
Os interruptores -AdmS
fazem o seguinte:
(Veja opágina de manual da telapara mais detalhes)
-A
Adapt the sizes of all windows to the size of the current terminal. By default, screen tries to restore its old window sizes when attaching to resizable terminals
-d-m
Start screen in "detached" mode. This creates a new session but doesn't attach to it. This is useful for system startup scripts.
-S nome da sessão
When creating a new session, this option can be used to specify a meaningful name for the session. This name identifies the session for "screen -list" and "screen -r" actions. It substitutes the default [tty.host] suffix.
Agora vamos começar a carregá-lo com abas + seus comandos:
$ screen -S myshell -X screen -t tab1 vim
$ screen -S myshell -X screen -t tab2 ping www.google.com
$ screen -S myshell -X screen -t tab3 bash
Esses 3 comandos criarão 3 guias adicionais e executarão o vim, executarão ping no google e iniciarão um shell bash. Se listarmos as sessões de tela, veremos o seguinte:
$ screen -ls
There is a screen on:
26642.myshell (Detached)
1 Socket in /var/run/screen/S-root.
Se nos conectarmos à sessão de tela,minha conchae liste as guias que ele contém, veremos o seguinte:
$ screen -r myshell
Pressione esta combinação de teclas: Ctrl+ Aseguido de Shift+"
Num Name Flags
0 tab0 $
1 tab1 $
2 tab2 $
3 tab3 $
Mudando paratab2:
64 bytes from ord08s08-in-f20.1e100.net (74.125.225.116): icmp_seq=443 ttl=55 time=41.4 ms
64 bytes from ord08s08-in-f20.1e100.net (74.125.225.116): icmp_seq=444 ttl=55 time=33.0 ms
64 bytes from ord08s08-in-f20.1e100.net (74.125.225.116): icmp_seq=445 ttl=55 time=30.1 ms
captura de tela
Os comandos acima são a maneira básica de realizar o que o OP estava procurando. É claro que isso pode ser condensado e refinado usando aliases Bash ou até mesmo scripts de shell, isso é apenas para demonstrar a capacidade e mostrar o caminho!
Referências
Responder2
uma pequena adição à resposta. stuff primeiro ecoa o comando, depois o coloca na linha de comando e o executa se \n ou ^M terminar a linha.
como o eco me incomodou, encadeei \nclear\n como o último comando, para que a janela da tela comece limpa.