Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Discussion & Documentation Documentation, Tips & Tricks
  • Search

Screen just the way we like it

Unofficial documentation for various parts of Gentoo Linux. Note: This is not a support forum.
Post Reply
Advanced search
3 posts • Page 1 of 1
Author
Message
bblount
Tux's lil' helper
Tux's lil' helper
Posts: 80
Joined: Mon Nov 08, 2004 2:21 pm

Screen just the way we like it

  • Quote

Post by bblount » Tue Oct 21, 2008 3:43 am

I wrote this little hack because I was tired of managing screen sessions and doing 'screen -r' and having to figure out which screen was the one I wanted.

Essentially what it does is ensure that you only have one screen session at any given time. Any new programs are run as new windows inside your existing screen session. You can then scroll through your open screen apps with Ctrl+A N

I called this 'scn' but you could name it whatever you want. Just put it in your path and then alias all your apps you want to run in screen to 'scn command'.

For example I have this as ~/bin/scn which I added to my $PATH and I alias pork to 'scn pork' and irssi to 'scn irssi'. I also aliased sr='screen -r' for faster access.

Code: Select all

#!/bin/bash
if [ `screen -ls | wc -l` -gt 2 ];
then
        echo "Screen found, running $@";
        screen -X screen $@;
        screen -r;
else
        echo "No screen found. Creating one."
        screen $@;
fi
I'm fairly new at bash scripting so any suggestions are welcome! I hope you guys find this as useful as I have. It really is nice not having to guess which screen session to open.

Known issues:
  • Running a command when an existing screen is found won't put that application in the foreground of your session.
  • Running the same command over and over will just make more and more windows of that same command. Instead use screen -r to get to your previously started commands.
Top
truc
Advocate
Advocate
User avatar
Posts: 3199
Joined: Mon Jul 25, 2005 9:24 am

  • Quote

Post by truc » Tue Oct 21, 2008 5:25 am

There is also 'screenie' if I remember the name correctly, that you may find usefull, to manage your different screen sessions.

I personnally have as master screeen, with nested screens inside:
F1 -> goes the window 0 of the master screen, that's where I have one of my screens
F2 -> goes the window 1 of the master screen, that's where I have an other screen
F3 -> ...
...
F5 -> goes the window 4 of the master screen, that's where I have an other screen
F6 -> is the 'escape' of the 'master' screen.

This way, I almost never play with screen -r, I just play with F{1..6}, and some aliases to create/reattach the screen in case there are detached.
The End of the Internet!
Top
Naib
Watchman
Watchman
User avatar
Posts: 6101
Joined: Fri May 21, 2004 9:42 pm
Location: Removed by Neddy
Contact:
Contact Naib
Website

  • Quote

Post by Naib » Fri Oct 24, 2008 8:16 am

Or... You name your screen sessions...

screen -dmS IRC irssi

will start a screen session called "IRC", detach yourself from it and launch the command "irssi"

a quick: screen -list will show up a more meaningful name for screen sessions

then you can re-attach with screen -r IRC

This way I have lots-o-screens running BUT can easily tell which one is which
#define HelloWorld int
#define Int main()
#define Return printf
#define Print return
#include <stdio>
HelloWorld Int {
Return("Hello, world!\n");
Print 0;
Top
Post Reply

3 posts • Page 1 of 1

Return to “Documentation, Tips & Tricks”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic