Posts Tagged ‘screen PS1’

Nested Sessions of ’screen’ and Some PS1 Tricks

Wednesday, December 2nd, 2009

Here’s my original ’slide’ shown at NYCBUG’s December 2009 meeting.

But, here’s my full tricked out ~/.screenrc values:


escape ^tt

shelltitle makarioi

# k black
# r red
# g green
# y orange
# b blue
# m magenta
# c cyan
# w light grey
# d default
#
# R coral
# K grey
# G bright green
# Y yellow
# B purple
# M pink
# C bright cyan
# W white

hardstatus on
hardstatus alwayslastline "%{Wb}%?%-Lw%?%{Cb}%n*%f %t%?(%u)%?%{Wb}%?%+Lw%= %{Wb}@ %H %{kb}| %{Cb}%Y%{kb}_%{Cb}%m%{kb}_%{Cb}%d%{kb}_%{Cb}%D %{kb}| %{Wb}%c"

To help make sense of the hardstatus colors the following %{Cb} is ‘bright cyan‘ on a ‘black‘ background.

Ok, ok: here’s the most important part of your ~/.screenrc file: the escape directive.

ALL of my root logins have the following “escape ^^” value: vv.

Sure, you can’t ^v to paste into a shell, if your shell and desktop allow that, but *meh*, who cares? I’ve replaced that with X11’s middle click and Putty’s right click.

So, what about the rest of my user logins? I don’t exclusively login as root and I also use the Dvorak keyboard layout. With that in mind, what has worked out for me is to use, as the, what I’ll call, ‘the main login‘; which is my main user on the main host I login into – and that I would establish the root-nested-screen session at and with. (Hope that makes sense.).

With that user, I use this directive: escape ^tt.

With other, non-root, users, I use escape ^^g.

*taking a breath*

Ok, if you’re an avid *Nix user, you might have noticed how my last directive kills one particular function in both vi and vim: ^g. But, I’ve learned to live without knowing which file I’m currently editing in vi/m. No biggie.

Now, BEHOLD here are my super-select (if not secret, even!) PS1 variables and color codings:

$ echo $PS1
\[\e[00;34m\]________________________________________________________________________________\n\[\e[01;34m\](\j) \[\e[01;33m\]\h \[\e[00;31m\]<\t> \[\e[01;34m\]\w \n$ \[\e[00m\]

What? What do you mean I haven’t really shown anything really new…. You’re right. Let me redeem myself:

DIVIDER=${BLUE}
JOBCOUNTER=${PURPLE}
HOSTCOLOR=${YELLOW}
TIMECOLOR=${RED}
PATHCOLOR=${PURPLE}
OUTPUTCOLOR=${NOCOLOR}
PS2COLOR=${RED}

# Standard 'root' PS1 variable:
export PS1="\[${DIVIDER}\]________________________________________________________________________________\n\[${JOBCOUNTER}\](\j) \[${HOSTCOLOR}\]\h \[${TIMECOLOR}\]<\t> \[${PATHCOLOR}\]\w \n\$ \[${OUTPUTCOLOR}\]"
export PS2="\[${PS2COLOR}\]-> \[${OUTPUTCOLOR}\]"

*blush* I’ve forgotten how specialized I’d tricked out my $PS1 variable…. at least there’s some indications of what I’m trying to accomplish.

But, what if you don’t want to build your command prompt as I do?

Here are the color code hook-ups. You can use them in your ~/.bashrc file if you wish:

# My PS color variables:
BLACK='\e[00;30m'
BLACKISH='\e[01;30m'
RED='\e[00;31m'
ORANGE='\e[01;31m'
GREEN='\e[00;32m'
LIGHTGREEN='\e[01;32m'
BROWN='\e[00;33m'
YELLOW='\e[01;33m'
BLUE='\e[00;34m'
PURPLE='\e[01;34m'
MAGENTA='\e[00;35m'
PINK='\e[01;35m'
DARKCYAN='\e[00;36m'
CYAN='\e[01;36m'
GREY='\e[00;37m'
WHITE='\e[01;37m'
B_BLACK='\e[00;40m'
B_BLACKER='\e[01;40m'
B_RED='\e[00;41m'
B_ORANGE='\e[01;41m'
B_GREEN='\e[00;42m'
B_LIGHTGREEN='\e[01;42m'
B_BROWN='\e[00;44m'
B_YELLOW='\e[01;44m'
B_BLUE='\e[00;44m'
B_PURPLE='\e[01;44m'
B_MAGENTA='\e[00;45m'
B_PINK='\e[01;45m'
B_DARKCYAN='\e[00;46m'
B_CYAN='\e[01;46m'
B_GREY='\e[00;47m'
B_WHITE='\e[01;47m'
NOCOLOR='\e[00m'

ROCK ON!Now you, too, can use variables to specify PS1 colors as you like.

Man, I hope you enjoyed this.

Later,
bt

P.S. Coming later: If you want to have certain sessions start up automatically with a new screen session, there are some directives you can set up in your ~/.screenrc.