Posts tagged ‘gnu screen’

Gnu Screen theme cycle with keybinding

gnu1.png

A co-worker of mine did this and shared with me, so i thought I’d continue spreading it around. If you have multiple gnu screen sessions going at once, wouldn’t it be nice to visually tell them apart without spending time to read the session name of each or trying to see what was going on within each?

The best way would be to color code the caption and hardlinestatus lines and be able to easily select a “color” per screen session and that’s what he and I did. Using C-g, we/you can easily cycle through various “themes”. This could also be useful if you wanted to cycle through mutiple hardstatus lines that displayed different information too if that’s the route you’d like to go. Anyways here it goes.

Continue reading ‘Gnu Screen theme cycle with keybinding’ »

Use retty in screen to attach already running applications

gnu.png

Ever left some longer running script/process/something at home and than wished you could control it via ssh and it wasn’t started in a screen session? Fear not, retty is here to rescue! To demonstrate this:

$ irssi
# switch to new terminal
$ screen -S irssi
$ retty `pgrep irssi`
/redraw

To explain what is going on here, first we start a normal application in one terminal, this could be any other thing, like a script doing heavyweight processing. In the new terminal we start the screen session, this is an optional step, it allows us to be able to later on detach/reattach the session at will. Inside the screen session we hijack the irssi PID. The last step, /redraw is only necessary because we are dealing with complex ncurses stuff which does weird stuff when it’s in operation . For the same reason you have to run “reset” in the first terminal if you want to keep using it normally. This by itself isn’t really useful, however you can use the exact same procedure to reattach something via ssh.

How to have Gnu Screen display number of updates for Arch linux

Archlinux-icon.png

1.   sudo vim /etc/cron.hourly/pacmansy

2.  and place this within

pacman -Sy

3.  then :wq the file and make it executable:

chmod a+x /etc/cron.hourly/pacmansy

4.   vim ~/bin/getupdates.pl

and place this within:

#!/usr/bin/perl
use strict;
use warnings;
print ((`pacman -Qu` =~ m/^[^\s]+\s\((\d+)\):/m) ? $1 : 0);

5.  vim ~/.screenrc and do this:  (relevant parts are bolded)

caption always “%{= KW}%-w%{= Gk}%n %t%{-}%+w %-=”

hardstatus alwayslastline “%{= kW} %-= %{= kC}Session:%u%{= kW} %5` | %{= kC}Host:%{= kW} %H | %1` |%{= kC} MEM:%{= kW} %2`MB /%{= kC} SW: %{= kW}%3`MB | %{= kC}Unread %{= kW}%4` | %{kC}Updates:%{kW} %7` | %m/%d %c”
#Backticks to display information in status bar
backtick 1 60 60 /home/username/bin/get_uptime
backtick 2 60 60 /home/username/bin/get_freemem
backtick 3 60 60 /home/username/bin/get_freeswap
backtick 4 60 60 /home/username/bin/get_gmail
backtick 5 60 60 /home/username/bin/get_sessionname
backtick 7 60 60 perl /home/username/bin/get_updates.pl

Now run screen and the number of updates awaiting for you in pacman should be displayed.  Enjoy.

How to have a lightweight, beautiful, functional terminal

terminal.png

I’ve done a lot over the past few months to make my time spent on the command line a bit more enjoyable and easier to use.  Hopefully you’ll find these steps useful as well.

Continue reading ‘How to have a lightweight, beautiful, functional terminal’ »

Automagically set titles to boxes you ssh in screen.

terminal.png

I use GNU Screen a lot – as in basically all the time, and when I SSH somewhere I like to set the title of the screen I’m in, so I can easily keep track of loads of them.

To do this I’ve come up with a script which can be executed by SSH when it connects to a remote server.

Continue reading ‘Automagically set titles to boxes you ssh in screen.’ »

Gnu Screen Tip: Password Protect Session

terminal.png
  1. Go into command mode  C-a :
  2. type “password” and hit enter, screen will then prompt for you to set a password for the session. You will have to type it in twice.

You can have screen do this simply by placing the word ‘password’ at the bottom of your .screenrc file as well.

Show Unread Gmails in Gnu Screen Status Bar

terminal.png

Below will show have to use a simple script that will fetch the total number of unread emails in your gmail account and display that in screen using backticks.

Continue reading ‘Show Unread Gmails in Gnu Screen Status Bar’ »

Patch Gnu Screen to have Vertical Split in Ubuntu 8.04

terminal.png

Just a quick post here. I recently recompiled screen with vertical split support on Ubuntu 8.04. Here’s how you do it:

Install dependencies to build screen
sudo apt-get build-dep screen
# Create an area to hold the source
cd ~/debian-src
mkdir screen
cd screen

# Get the source
apt-get source screen

# Apply vertical split patch
cd screen-4.0.3/
wget http://vsp4sdl.yuggoth.org/wrp_vertical_split_0.3_4.0.2.diff.bz2
bunzip2 wrp_vertical_split_0.3_4.0.2.diff.bz2
patch -p1 < wrp_vertical_split_0.3_4.0.2.diff

# Build it!
dpkg-buildpackage -us -uc -rfakeroot
cd ..

# Install it!
sudo dpkg -i screen_4.0.3-0.4ubuntu2_amd64.deb

Gnu Screen Cheat Sheet

Basics of Gnu Screen

gnu.png

I’ve been using screen for the past 3 years and for the first time I’ve decided to seek out more functionality out of it.  So last week I spent about 2 hours looking up some of the different functionality that I can use in the day to day. Let me tell you I found a bunch of goodies that I use now religiously (For a week now ;) ).

So for those of you who do not know what a screen session is… (STRAIGHT FROM THE MAN PAGES) Screen is a full-screen window manager that multiplexes a physical terminal between several processes (typically interactive shells).  Essentially you can have 30 terminal sessions inside one terminal and much more…..

To run Screen all you need to do is type “screen” in your terminal. You more then likely do not have it installed by default. So for those of you who have the distributions below…

  1. Fedora/CentOS/RHE/ or any RedHat based system, you will need to run “yum install screen
  2. Ubuntu/Debian based systems, you will need to run “apt-get install screen
  3. Gentoo based systems, you will need to run “emerge screen

To start a new screen session all you have to do is type “screen”

Continue reading ‘Basics of Gnu Screen’ »

Pages: 1 2 Next