View previous topic :: View next topic |
Author |
Message |
bblount Tux's lil' helper
Joined: 08 Nov 2004 Posts: 80
|
Posted: Tue Oct 21, 2008 3:43 am Post subject: Screen just the way we like it |
|
|
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: |
#!/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.
|
|
Back to top |
|
|
truc Advocate
Joined: 25 Jul 2005 Posts: 3199
|
Posted: Tue Oct 21, 2008 5:25 am Post subject: |
|
|
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! |
|
Back to top |
|
|
Naib Watchman
Joined: 21 May 2004 Posts: 6051 Location: Removed by Neddy
|
Posted: Fri Oct 24, 2008 8:16 am Post subject: |
|
|
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 _________________
Quote: | Removed by Chiitoo |
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|