Screen Cheet Sheet: Difference between revisions

From Federal Burro of Information
Jump to navigationJump to search
No edit summary
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 9: Line 9:


move control-a to control-w with an alias, in bash, like this:
move control-a to control-w with an alias, in bash, like this:
== Alias ==


<pre>
<pre>
Line 20: Line 22:
How to do other cool stuff?
How to do other cool stuff?


* windows names and titles
screen -S "myscreename"
show up when you
screen -l
* change the session name:
C-a : sessionname mysession
== Screenrc ==


* windows names and titles
* cool hardstatus lines, in your .screenrc file:
* cool hardstatus lines, in your .screenrc file:
<pre>
 
hardstatus alwayslastline
MC style:
hardstatus string "%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{r}(%{W}%n*%f %t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m/%d %{W}%c %{g}]"
 
</pre>
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %d/%m %C%a"
 
Wide:
 
hardstatus on
hardstatus alwayslastline
hardstatus string "%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{r}(%{W}%n*%f %t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m/%d %{W}%c %{g}]"
 
my current config:
 
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %d/%m %C%a"
defscrollback 10000
scrollback 10000
 
 
* scroll back, in your .screenrc file:
* scroll back, in your .screenrc file:
<pre>
<pre>
Line 41: Line 71:
* meta-' - allows you to select a screen by number.
* meta-' - allows you to select a screen by number.


=Screen and ssh-agent2=
 
 
== Screen and ssh-agent2 ==


This process will only work with ssh-agent forwarding.  
This process will only work with ssh-agent forwarding.  
Line 57: Line 89:
</pre>
</pre>


Next step is to add the following to .bashrc  
Next step is to add the following to .bashrc --> IM NOT SURE THIS WORKS


<pre>
<pre>
Line 66: Line 98:
         ln -s $SSH2_AUTH_SOCK $HOME/tmp/socket
         ln -s $SSH2_AUTH_SOCK $HOME/tmp/socket
fi
fi
</pre>
in bashrc: I KNOW THIS WORKS
<pre>
if [[ $TERM != "screen" ]] ; then
    touch ~/.agent.tmp
    chmod 600 ~/.agent.tmp
    set | grep SSH > ~/.agent.tmp
fi
if [ -a ~/.agent.tmp ] ; then
    if [[ $TERM == "screen" ]] ; then
    . ~/.agent.tmp
    fi
fi
</pre>
</pre>


[[Category:Computers]]
[[Category:Computers]]

Latest revision as of 15:40, 20 April 2018

first thing's first:

man screen

Do you have cool screen tricks?

move control-a to control-w with an alias, in bash, like this:

Alias

alias screen='screen -e ^Wa'

why would i want to do that? control-a means beginning of line by default. If you make screen's mate control-a you not longer have a "beginning of line" control sequence.

  • good external page with some info here [1]

How to do other cool stuff?

  • windows names and titles
screen -S "myscreename"

show up when you

screen -l
  • change the session name:
C-a : sessionname mysession

Screenrc

  • cool hardstatus lines, in your .screenrc file:

MC style:

hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %d/%m %C%a"

Wide:

hardstatus on
hardstatus alwayslastline
hardstatus string "%{gk}[ %{G}%H %{g}][%= %{wk}%?%-Lw%?%{r}(%{W}%n*%f %t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m/%d %{W}%c %{g}]"

my current config:

hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %d/%m %C%a"
defscrollback 10000
scrollback 10000


  • scroll back, in your .screenrc file:
termcapinfo xterm 'bc@:bs@'

useful key sequences

  • meta-escape - pageup, pagedn to scroll back in the screen buffer ( you can use arrow keys and page up page down to scroll around)
  • meta-space - next window
  • meta-backspace - backwards through windows.
  • meta-meta - previous window
  • meta-A - allows you to rename a screen (if you can find a way to rename screens dynamically based on hostname, post it here for a chance to win a mars bar!)
  • meta-" - allows you to select a screen by name.
  • meta-' - allows you to select a screen by number.


Screen and ssh-agent2

This process will only work with ssh-agent forwarding.

Make sure you have a screenrc file in your home directory. If not copy the default.

cp /etc/screenrc ~/.screenrc

Now add the following line to ~/.screenrc and make sure ~/tmp exist.

setenv SSH2_AUTH_SOCK $HOME/tmp/socket

Next step is to add the following to .bashrc --> IM NOT SURE THIS WORKS

if [ -S $HOME/tmp/socket ]; then
        echo "ssh-agent2 socket already exist"
else
        /bin/rm $HOME/tmp/socket
        ln -s $SSH2_AUTH_SOCK $HOME/tmp/socket
fi


in bashrc: I KNOW THIS WORKS

if [[ $TERM != "screen" ]] ; then
    touch ~/.agent.tmp
    chmod 600 ~/.agent.tmp
    set | grep SSH > ~/.agent.tmp
fi

if [ -a ~/.agent.tmp ] ; then
    if [[ $TERM == "screen" ]] ; then
    . ~/.agent.tmp
    fi
fi