You are not logged in.

#76 2011-07-18 17:37:05

Lich
Member
Registered: 2009-09-13
Posts: 437

Re: Post your .screenrc with screenshots!

That would be an old version of uzbl tabbed, with my custom CSS but I don't use that crap for some time now (you can still find the CSS on the uzbl wiki I believe). It doesn't look good, I *made* it look good tongue. Chrome + Surf is all I require lately. You could get surf + tabbed (both suckless products) to look similar to that too, if pretty and simplistic is what you're after (I was at the time).

Last edited by Lich (2011-07-18 17:41:03)


Archlinux | ratpoison + evilwm | urxvtc | tmux

Offline

#77 2011-07-20 07:26:18

x33a
Forum Moderator
Registered: 2009-08-15
Posts: 4,181
Website

Re: Post your .screenrc with screenshots!

screen-vs in multidisplay mode (-x switch is way too cool).

http://ompldr.org/vOWp0dA

here's the .screenrc

# Fix for residual text
altscreen on

# custom statusbar
hardstatus off
hardstatus alwayslastline
hardstatus string '%{= kW}[ %{m}%H %{W}][%= %{= kw}%?%-Lw%?%{r}(%{g}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{W}][%{Y} %d/%m %{Y}%c %{W}]'

# Turn welcome message off
startup_message off

# disable vbell (so wm urgency hints can work from within screen)
vbell off

# Increase the scrollback buffer
defscrollback 5000

# programs to autostart on screen startup
screen -t htop 0 htop
screen -t root 1 su -
screen -t bash 2 
screen -t bash 3
screen -t iftop 5
stuff "sudo iftop\012"
screen -t rtorrent 6
screen -t mutt 7
stuff "mutt\012"
screen -t log 9 
stuff "tail --follow=name --retry --lines=1000 /var/log/everything.log\012"
#screen -t im 10
screen -t mc 8
stuff "mc /home/x33a /home/x33a/downloads\012"
select 1

# for mutt transparency
defbce on

# set terminal name
term rxvt-256color

# message display time (seconds)
msgwait 2

# 256 colour support for urxvt
terminfo rxvt-unicode 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'

# access terminals higher than 0-9 range
#
# add the following commands to command-class selectHighs
bind -c selectHighs 0 select 10 # C-a - 0 will open terminal 10

bind - command -c selectHighs	# bind hyphen to command-class selectHighs

EDIT: Minor additions and tweaks to .screenrc

Last edited by x33a (2011-12-07 15:04:53)

Offline

#78 2015-12-11 12:12:02

then4116
Member
Registered: 2012-09-24
Posts: 4

Re: Post your .screenrc with screenshots!

Zombie threat, I know, but I'm a bit proud of this unholy mess:

###### screenrc
###### adopted from robzn, overhauled by then4116
###### This config is aimed at powerusers, who work on a lot of machines, and need a lot of information at a glance
###### It's intendet to facilitate usage of deeply nested screen sessions
###### as such, it relies heavily on keybindings to modify other keybindings, and multi-key bindings

### options
defscrollback 10000		# set scrollback buffer to 10000
defutf8 on on			# set utf8
vbell off			# disable visual bell
startup_message off		# disable startup message 'new screen ..'
setenv DISPLAY ':0'		# eg for mplayer
deflog on			# enable logging
logfile /root/screen.%n		# set log location
nethack off			# nethack like notifications
defmonitor on			# turn on monitoring (for activity)
activity "activity in %n"	# enable activity
multiuser on			# enable screen -x
shell bash			# default shell
autodetach on			# automatically detach upon hangup
altscreen on
msgwait 3
termcapinfo xterm|xterms|xs|rxvt ti@:te@	# use xterm's normal screen buffer (which includes scrollback). Makes scrolling back with mouse/touchpad in X11 useful.
defnonblock 1
### keybindings
bind 'w' sessionname
bind '\' quit #'
bind 'k' kill
bind 'F' flow

# by default, F11/F12 switch windows left/right.
bindkey -k F1 eval 'monitor off' 'prev' 'monitor on' # turning off monitoring for the duration of the switch, so that the bell sent by nested screen sessions when switching away from them is ignored. A nicer solution would be welcome!
bindkey -k F2 eval 'monitor off' 'next' 'monitor on'

# these bindings switch the keys for window navigation between F11/F12, F9/F10, F7/F8, F5/F6, F3/F4 & F1/F2 - useful for managing nested sessions
# usage: press ^A-u[123456]. The digit is the nesting depth.
bindkey -t "^Au1" eval 'bindkey -k k1' 'bindkey -k k2' 'bindkey -k k3' 'bindkey -k k4' 'bindkey -k k5' 'bindkey -k k6' 'bindkey -k k7' 'bindkey -k k8' 'bindkey -k k9' 'bindkey -k k;'                                 'bindkey -k F1 eval "monitor off" "prev" "monitor on"' 'bindkey -k F2 eval "monitor off" "next" "monitor on"'
bindkey -t "^Au2" eval 'bindkey -k k1' 'bindkey -k k2' 'bindkey -k k3' 'bindkey -k k4' 'bindkey -k k5' 'bindkey -k k6' 'bindkey -k k7' 'bindkey -k k8'                                 'bindkey -k F1' 'bindkey -k F2' 'bindkey -k k9 eval "monitor off" "prev" "monitor on"' 'bindkey -k k; eval "monitor off" "next" "monitor on"'
bindkey -t "^Au3" eval 'bindkey -k k1' 'bindkey -k k2' 'bindkey -k k3' 'bindkey -k k4' 'bindkey -k k5' 'bindkey -k k6'                                 'bindkey -k k9' 'bindkey -k k;' 'bindkey -k F1' 'bindkey -k F2' 'bindkey -k k7 eval "monitor off" "prev" "monitor on"' 'bindkey -k k8 eval "monitor off" "next" "monitor on"'
bindkey -t "^Au4" eval 'bindkey -k k1' 'bindkey -k k2' 'bindkey -k k3' 'bindkey -k k4'                                 'bindkey -k k7' 'bindkey -k k8' 'bindkey -k k9' 'bindkey -k k;' 'bindkey -k F1' 'bindkey -k F2' 'bindkey -k k5 eval "monitor off" "prev" "monitor on"' 'bindkey -k k6 eval "monitor off" "next" "monitor on"'
bindkey -t "^Au5" eval 'bindkey -k k1' 'bindkey -k k2' 	                               'bindkey -k k5' 'bindkey -k k6' 'bindkey -k k7' 'bindkey -k k8' 'bindkey -k k9' 'bindkey -k k;' 'bindkey -k F1' 'bindkey -k F2' 'bindkey -k k3 eval "monitor off" "prev" "monitor on"' 'bindkey -k k4 eval "monitor off" "next" "monitor on"'
bindkey -t "^Au6" eval                                 'bindkey -k k3' 'bindkey -k k4' 'bindkey -k k5' 'bindkey -k k6' 'bindkey -k k7' 'bindkey -k k8' 'bindkey -k k9' 'bindkey -k k;' 'bindkey -k F1' 'bindkey -k F2' 'bindkey -k k1 eval "monitor off" "prev" "monitor on"' 'bindkey -k k2 eval "monitor off" "next" "monitor on"'
# since the F-keys are now used up, you can send them to the shell via keybindings. Just press ^A, and then type out f5, f12 or whatever. F1 must be sent as f01
bindkey -t "^Af01" stuff "^[OP~"
bindkey -t "^Af2"  stuff "^[OQ~"
bindkey -t "^Af02" stuff "^[OQ~"
bindkey -t "^Af3"  stuff "^[OR~"
bindkey -t "^Af03" stuff "^[OR~"
bindkey -t "^Af4"  stuff "^[OS~"
bindkey -t "^Af04" stuff "^[OS~"
bindkey -t "^Af5"  stuff "^[[15~"
bindkey -t "^Af05" stuff "^[[15~"
bindkey -t "^Af6"  stuff "^[[17~"
bindkey -t "^Af06" stuff "^[[17~"
bindkey -t "^Af7"  stuff "^[[18~"
bindkey -t "^Af07" stuff "^[[18~"
bindkey -t "^Af8"  stuff "^[[19~"
bindkey -t "^Af08" stuff "^[[19~"
bindkey -t "^Af9"  stuff "^[[20~"
bindkey -t "^Af09" stuff "^[[20~"
bindkey -t "^Af10" stuff "^[[21~"
bindkey -t "^Af11" stuff "^[[23~"
bindkey -t "^Af12" stuff "^[[24~"

### startup windows
# screen -t wicd 0 wicd-curses
# screen -t X 1 

### backticks
# backtick id lifespan autorefresh cmd args...
backtick 1 10 10 /usr/bin/myip2 
backtick 2 10 10 /usr/bin/memory 
backtick 3 30 30 sh -c 'screen -ls | grep --color=no -o "$PPID[^[:space:]]*"' # session title
#backtick 4 60 60 /usr/bin/battery # laptops only!

### caption & hardstatus

# Caption & hardstatus lines can be switched off/on with ^A-e/E and ^A-y/Y, respectively.
         caption always "%{= kw}|%{= kG} %3`: %{+r kg}%-w%{-r} %{+r kw}%n %t%{-r} %{+r kg}%+w%{-r} %{kG}%=%D %Y-%m-%d | %c:%s %{= kw}|" #`"
bind 'E' caption always "%{= kw}|%{= kG} %3`: %{+r kg}%-w%{-r} %{+r kw}%n %t%{-r} %{+r kg}%+w%{-r} %{kG}%=%D %Y-%m-%d | %c:%s %{= kw}|" #`"
bind 'e' caption splitonly ""

hardstatus off			# emulation of the terminal’s hardstatus line
         hardstatus lastline "%{= kw}|_%=%{kG}$USER@%H%{kw}|%{kG}%1`%{kw}|%{kG}L:%l%{kw}|%{kG}%2`%{kw}|%{kG}%4`%=%{kw}_|" #`"
bind 'Y' hardstatus lastline "%{= kw}|_%=%{kG}$USER@%H%{kw}|%{kG}%1`%{kw}|%{kG}L:%l%{kw}|%{kG}%2`%{kw}|%{kG}%4`%=%{kw}_|" #`"
bind 'y' hardstatus ignore

# Now this here is some crazy shit. In order to smoothly change colors, and still enable switching off/on of caption & hardstatus, we not only have to set the respective strings, but also the keybindings to switch them off/on. I tried to use variables for that, but it didn't quite work out.
# usage: press ^A-#[rgybmc] to change the color
bindkey -t "^A#r" eval 'caption string "%{= kw}|%{= kR} %3`: %{+r kr}%-w%{-r} %{+r kw}%n %t%{-r} %{+r kr}%+w%{-r} %{kR}%=%D %Y-%m-%d | %c:%s %{= kw}|"' 'hardstatus string "%{= kw}|_%=%{kR}$USER@%H%{kw}|%{kR}%1`%{kw}|%{kR}L:%l%{kw}|%{kR}%2`%{kw}|%{kR}%4`%=%{kw}_|"' 'bind "E" caption always "%{= kw}|%{= kR} %3`: %{+r kr}%-w%{-r} %{+r kw}%n %t%{-r} %{+r kr}%+w%{-r} %{kR}%=%D %Y-%m-%d | %c:%s %{= kw}|"' 'bind "Y" hardstatus lastline "%{= kw}|_%=%{kR}$USER@%H%{kw}|%{kR}%1`%{kw}|%{kR}L:%l%{kw}|%{kR}%2`%{kw}|%{kR}%4`%=%{kw}_|"'
bindkey -t "^A#g" eval 'caption string "%{= kw}|%{= kG} %3`: %{+r kg}%-w%{-r} %{+r kw}%n %t%{-r} %{+r kg}%+w%{-r} %{kG}%=%D %Y-%m-%d | %c:%s %{= kw}|"' 'hardstatus string "%{= kw}|_%=%{kG}$USER@%H%{kw}|%{kG}%1`%{kw}|%{kG}L:%l%{kw}|%{kG}%2`%{kw}|%{kG}%4`%=%{kw}_|"' 'bind "E" caption always "%{= kw}|%{= kG} %3`: %{+r kg}%-w%{-r} %{+r kw}%n %t%{-r} %{+r kg}%+w%{-r} %{kG}%=%D %Y-%m-%d | %c:%s %{= kw}|"' 'bind "Y" hardstatus lastline "%{= kw}|_%=%{kG}$USER@%H%{kw}|%{kG}%1`%{kw}|%{kG}L:%l%{kw}|%{kG}%2`%{kw}|%{kG}%4`%=%{kw}_|"'
bindkey -t "^A#y" eval 'caption string "%{= kw}|%{= kY} %3`: %{+r ky}%-w%{-r} %{+r kw}%n %t%{-r} %{+r ky}%+w%{-r} %{kY}%=%D %Y-%m-%d | %c:%s %{= kw}|"' 'hardstatus string "%{= kw}|_%=%{kY}$USER@%H%{kw}|%{kY}%1`%{kw}|%{kY}L:%l%{kw}|%{kY}%2`%{kw}|%{kY}%4`%=%{kw}_|"' 'bind "E" caption always "%{= kw}|%{= kY} %3`: %{+r ky}%-w%{-r} %{+r kw}%n %t%{-r} %{+r ky}%+w%{-r} %{kY}%=%D %Y-%m-%d | %c:%s %{= kw}|"' 'bind "Y" hardstatus lastline "%{= kw}|_%=%{kY}$USER@%H%{kw}|%{kY}%1`%{kw}|%{kY}L:%l%{kw}|%{kY}%2`%{kw}|%{kY}%4`%=%{kw}_|"'
bindkey -t "^A#b" eval 'caption string "%{= kw}|%{= kB} %3`: %{+r kb}%-w%{-r} %{+r kw}%n %t%{-r} %{+r kb}%+w%{-r} %{kB}%=%D %Y-%m-%d | %c:%s %{= kw}|"' 'hardstatus string "%{= kw}|_%=%{kB}$USER@%H%{kw}|%{kB}%1`%{kw}|%{kB}L:%l%{kw}|%{kB}%2`%{kw}|%{kB}%4`%=%{kw}_|"' 'bind "E" caption always "%{= kw}|%{= kB} %3`: %{+r kb}%-w%{-r} %{+r kw}%n %t%{-r} %{+r kb}%+w%{-r} %{kB}%=%D %Y-%m-%d | %c:%s %{= kw}|"' 'bind "Y" hardstatus lastline "%{= kw}|_%=%{kB}$USER@%H%{kw}|%{kB}%1`%{kw}|%{kB}L:%l%{kw}|%{kB}%2`%{kw}|%{kB}%4`%=%{kw}_|"'
bindkey -t "^A#m" eval 'caption string "%{= kw}|%{= kM} %3`: %{+r km}%-w%{-r} %{+r kw}%n %t%{-r} %{+r km}%+w%{-r} %{kM}%=%D %Y-%m-%d | %c:%s %{= kw}|"' 'hardstatus string "%{= kw}|_%=%{kM}$USER@%H%{kw}|%{kM}%1`%{kw}|%{kM}L:%l%{kw}|%{kM}%2`%{kw}|%{kM}%4`%=%{kw}_|"' 'bind "E" caption always "%{= kw}|%{= kM} %3`: %{+r km}%-w%{-r} %{+r kw}%n %t%{-r} %{+r km}%+w%{-r} %{kM}%=%D %Y-%m-%d | %c:%s %{= kw}|"' 'bind "Y" hardstatus lastline "%{= kw}|_%=%{kM}$USER@%H%{kw}|%{kM}%1`%{kw}|%{kM}L:%l%{kw}|%{kM}%2`%{kw}|%{kM}%4`%=%{kw}_|"'
bindkey -t "^A#c" eval 'caption string "%{= kw}|%{= kC} %3`: %{+r kc}%-w%{-r} %{+r kw}%n %t%{-r} %{+r kc}%+w%{-r} %{kC}%=%D %Y-%m-%d | %c:%s %{= kw}|"' 'hardstatus string "%{= kw}|_%=%{kC}$USER@%H%{kw}|%{kC}%1`%{kw}|%{kC}L:%l%{kw}|%{kC}%2`%{kw}|%{kC}%4`%=%{kw}_|"' 'bind "E" caption always "%{= kw}|%{= kC} %3`: %{+r kc}%-w%{-r} %{+r kw}%n %t%{-r} %{+r kc}%+w%{-r} %{kC}%=%D %Y-%m-%d | %c:%s %{= kw}|"' 'bind "Y" hardstatus lastline "%{= kw}|_%=%{kC}$USER@%H%{kw}|%{kC}%1`%{kw}|%{kC}L:%l%{kw}|%{kC}%2`%{kw}|%{kC}%4`%=%{kw}_|"'

sorendition +b Wk		# coloring cmds & messages
shelltitle '>|bash'		# necessary for window autorenaming magic. Set the first character to whatever your bash prompt ends in.


###### additional stuff

### this goes in your bashrc, also for window autorenaming magic
#case $TERM in
#        screen*)
#                # This is the escape sequence ESC k \w ESC \
#                #Use path as titel
#                SCREENTITLE='\[\ek\w\e\\\]'
#                #Use program name as titel
#                SCREENTITLEPROGRAM='\[\ek\e\\\]'
#                # only one of them will be filled correctly
#                ;;
#        *)
#                SCREENTITLE=''
#                SCREENTITLEPROGRAM=''
#                ;;
#esac
#PS1="${SCREENTITLEPROGRAM}${SCREENTITLE}${PS1}"


### /usr/bin/myip2
# ip -o addr list|sed -rn '1h;1!H;${;g;s/^/\n/g;s/\n[0-9]+:\s+/\n/g;s/\n(:?[^ ]+:|lo)[^\n]+//g;s/\n([^ ]+)([^\n]+)(\1:[0-9]+)/\n\3\2/g;s/\n[^\n]+scope link[^\n]+//g;s/\n([^ ]+)\s+inet6? ([^ ]+)[^\n]+/\n\1=\2/g;s/^\n//g;s/[\n ]+/ /g;p;}'


### /usr/bin/memory (really should think of a better name for this)
# awk '/^MemTotal:/{MemTotal=$2};/^MemFree:/{MemFree=$2};/^Buffers:/{Buffers=$2};/^Cached:/{Cached=$2};/^SwapTotal:/{SwapTotal=$2};/^SwapFree:/{SwapFree=$2;print"M:"int((MemTotal-MemFree-Buffers-Cached)/1024)"/"int(MemTotal/1024)",S:"int((SwapTotal-SwapFree)/1024)"/"int(SwapTotal/1024)}' /proc/meminfo


### /usr/bin/battery (needs a better name as well. I think there was a reason to put it in a script instead of just calling it directly in screenrc, but I can't remember what it was)
# acpi|cut -d" " -f4,5

Offline

#79 2015-12-13 17:23:04

x33a
Forum Moderator
Registered: 2009-08-15
Posts: 4,181
Website

Re: Post your .screenrc with screenshots!

then4116 wrote:

Zombie threat I know, but I'm a bit proud of this unholy mess:

Where... where. Shall we bring out the shotguns? tongue

But really, that's a very complex .screenrc! And you are brave enough to use nested sessions too.

Offline

#80 2016-01-15 18:22:23

then4116
Member
Registered: 2012-09-24
Posts: 4

Re: Post your .screenrc with screenshots!

x33a wrote:
then4116 wrote:

Zombie threat I know, but I'm a bit proud of this unholy mess:

Where... where. Shall we bring out the shotguns? tongue

But really, that's a very complex .screenrc! And you are brave enough to use nested sessions too.

heh, funny typo XD

Edit:
made the color changing stuff a lot more manageable through the use of registers!

Edit:
added new bindings for moving windows left/right
nesting depth is now displayed at the beginning of the caption line (in parentheses)
changed shortbatt so that it only shows up if there's something to display (same as shortextip)

Edit:
added new bindings to hide/show both status & caption line
made changing the keybindings for nesting depth less redundant and more managable via registers

Edit:
new feature: more easily move windows left/right with SHIFT + the F-key you'd use to switch window left/right on the corresponding nesting layer

Edit:
added a whooping 9 color schemes for caption & hardstatus line, in addition to the preexisting 7, for a total of 16. Taste the rainbow!
Also re-added left-handed mode for switching between windows, though not with easy keybindings to switch between leftie & righty mode. You have to comment/uncomment sections of the screenrc.
Also added 3 fun clock displays: Unix timestamp in hex, binary & Gray code!

Edit:
Major update! Added support (read: nice keybindings) for layouts
including a new 'layout mode' that makes changing layouts almost as nice as in tmux!
added color changing for the message/command/region border/copy text.
Also decided to scrap registers for the status lines for good. Was getting more troublesome with each successive update.

Edit:
semi-major redesign of the hardstatus line: Now the separator | characters are dynamically shown or hidden based on whether or not the backtick after them is on or off. Makes the whole thing a lot prettier if you choose not to display all the status monitors.
Also added a new one-liner to keep track of available storage space on your file systems! Please remember to change the list of devices/filesystems to fit your computer!
Also added another 'mode' for dealing with multi-region layouts: !!-mode lets you use Alt+arrow keys to switch between regions, regardless of nesting depth. Works in X11; still working on tty.

Edit:
No more external scripts! All the backticks are now realized purely within screenrc!
And a lot of commenting & code beautification

Edit:
added a new backtick to display CPU usage percentage for each core (updated every second), as an alternative to traditional load averages
added a new clock display: Discordian date! (depends on ddate)
new scrolling mode for the IP address display
the bindings for moving windows left/right now get set/unset dynamically (depending on nesting depth), too!

Edit:
re-implemented all multi-key bindings that start with ^A with bind & command classes instead of bindkey -t. This has the effect that the %E string escape works now, so you get a visual indication when a screen session has received the command character (session name is inverted). Very helpful in nested sessions. Inspired by freenode user ski

Edit:
added a neat little curses SSH & screen session manager (depends on dialog), because this screenrc is aimed at people who work on a lot of hosts & with a lot of sessions.
more caption & hardstatus madness: session name & clock can be moved dynamically from the caption to the hardstatus, and the window list in the caption can be reduced to show only the current window. Both options are useful when dealing with complex layouts.

###### screenrc
###### by then4116
###### This config is aimed at powerusers, who work on a lot of machines, and need a lot of information at a glance
###### It's intended to facilitate usage of deeply nested screen sessions, and complex layouts
###### as such, it relies heavily on keybindings to modify other keybindings, and multi-key bindings
###### default keybindings have been left mostly intact, but not completely
###### IT'S RECOMMENDED TO READ THE CONFIG BEFORE USING IT

##########################################################################################
###### PLEASE DON'T FORGET change your .bashrc as specified at the end of the file! ######
##########################################################################################

### some options
defscrollback 99999             # set scrollback buffer to 'a shitload'
defutf8 on                      # set utf8
vbell off                       # disable visual bell
startup_message off             # disable startup message 'new screen ..'
#setenv DISPLAY ':0'             # eg for mplayer
deflog off                      # enable/disable logging here
logfile /root/screen.%n         # set log location
nethack off                     # nethack like notifications
defmonitor off                  # turn off monitoring (for activity)
activity "activity in %n"       # enable activity
multiuser on                    # enable screen -x
shell bash                      # default shell
autodetach on                   # automatically detach upon hangup
defnonblock 1
mousetrack off                  # turn on if you want to switch regions via mouse click. Will interfere with text selection via mouse in xterm though, so off by defult.
altscreen on
msgwait 3                       # message display duration
defzombie " !"
termcapinfo xterm|xterms|xs|rxvt ti@:te@        # use xterm's normal screen buffer (which includes scrollback). Makes scrolling back with mouse/touchpad in X11 useful.
termcapinfo * Z0=\E[?3h:Z1=\E[?3l
term screen-256color
attrcolor b ".I"

### some keybindings
bind 'w' sessionname
bind '\' quit   #'
bind 'K' kill
#bind 'F' flow

### window navigation
# basically, if you don't want to use nested sessions, you can just enjoy being able to switch windows with F11/F12 (and move them wit Shift+F11/F12), instead of the tedious ^Ap and ^An (and the slightly less tedious ^A^A and ^A[0-9])
# However, if you've discovered the usefulness of nested sessions, this is for you:
# With these key bindings, you can make a nested screen session 'aware' of how deeply it's nested. This changes the bindings for switching windows to other F-keys, so that, even in deeply nested sessions, it still only takes a single keystroke to switch windows.

# beware: changing around the nesting depth too much tends to break screen's ability to interpret the F-keys at all. In these cases, it helps to detach (^Ad) & reattach (screen -r) or to lock (^Ax) & unlock the screen session.

# these bindings set the nesting depth, i.e. switch the keys for window navigation between F11/F12, F9/F10, F7/F8, F5/F6, F3/F4 & F1/F2 - useful for managing nested sessions
# usage: press ^AU[0123456] (or ^AUl[0123456] for left handed mode). The digit is the nesting depth. Nesting depth 0 means that no bindings are set, which is useful for 'transparent' sessions.
# this is also called whenever the nesting depth of a session is changed (see below how to do that). Frees up the bindings on the F-keys, before the new ones are set for the new nesting depth.

bind -c u  r bind U command -c Ur
bind -c u  l bind U command -c Ul
bind -c Ur r bind U command -c Ur
bind -c Ur l bind U command -c Ul
bind -c Ul r bind U command -c Ur
bind -c Ul l bind U command -c Ul

bind -c u 0 eval 'backtick 23 3600 3600 printf "(0)  "' 'bindkey -k k1' 'bindkey -k k2' 'bindkey -k k3' 'bindkey -k k4' 'bindkey -k k5' 'bindkey -k k6' 'bindkey -k k7' 'bindkey -k k8' 'bindkey -k k9' 'bindkey -k k;' 'bindkey -k F1' 'bindkey -k F2' 'bindkey "^[O2P"' 'bindkey "^[O2Q"' 'bindkey "^[O2R"' 'bindkey "^[O2S"' 'bindkey "^[[15;2~"' 'bindkey "^[[17;2~"' 'bindkey "^[[18;2~"' 'bindkey "^[[19;2~"' 'bindkey "^[[20;2~"' 'bindkey "^[[21;2~"' 'bindkey "^[[23;2~"' 'bindkey "^[[24;2~"'
#right handed mode (=F11/F12 used for nesting depth 1, going left as nesting level increases).
bind -c Ur 1 eval 'process o' 'backtick 23'                          'bindkey -k F1 prev' 'bindkey -k F2 next' 'bindkey "^[[23;2~" number -1' 'bindkey "^[[24;2~" number +1' 'echo "right hand mode"'
bind -c Ur 2 eval 'process o' 'backtick 23 3600 3600 printf "(2)  "' 'bindkey -k k9 prev' 'bindkey -k k; next' 'bindkey "^[[20;2~" number -1' 'bindkey "^[[21;2~" number +1'
bind -c Ur 3 eval 'process o' 'backtick 23 3600 3600 printf "(3)  "' 'bindkey -k k7 prev' 'bindkey -k k8 next' 'bindkey "^[[18;2~" number -1' 'bindkey "^[[19;2~" number +1'
bind -c Ur 4 eval 'process o' 'backtick 23 3600 3600 printf "(4)  "' 'bindkey -k k5 prev' 'bindkey -k k6 next' 'bindkey "^[[15;2~" number -1' 'bindkey "^[[17;2~" number +1'
bind -c Ur 5 eval 'process o' 'backtick 23 3600 3600 printf "(5)  "' 'bindkey -k k3 prev' 'bindkey -k k4 next' 'bindkey "^[O2R"    number -1' 'bindkey "^[O2S"    number +1'
bind -c Ur 6 eval 'process o' 'backtick 23 3600 3600 printf "(6)  "' 'bindkey -k k1 prev' 'bindkey -k k2 next' 'bindkey "^[O2P"    number -1' 'bindkey "^[O2Q"    number +1'
#left handed mode (=F1/F2 used for nesting depth 1, going right as nesting level increases).
bind -c Ul 1 eval 'process o' 'backtick 23'                          'bindkey -k k1 prev' 'bindkey -k k2 next' 'bindkey "^[O2P"    number -1' 'bindkey "^[O2Q"    number +1' 'echo "left hand mode"'
bind -c Ul 2 eval 'process o' 'backtick 23 3600 3600 printf "[2]  "' 'bindkey -k k3 prev' 'bindkey -k k4 next' 'bindkey "^[O2R"    number -1' 'bindkey "^[O2S"    number +1'
bind -c Ul 3 eval 'process o' 'backtick 23 3600 3600 printf "[3]  "' 'bindkey -k k5 prev' 'bindkey -k k6 next' 'bindkey "^[[15;2~" number -1' 'bindkey "^[[17;2~" number +1'
bind -c Ul 4 eval 'process o' 'backtick 23 3600 3600 printf "[4]  "' 'bindkey -k k7 prev' 'bindkey -k k8 next' 'bindkey "^[[18;2~" number -1' 'bindkey "^[[19;2~" number +1'
bind -c Ul 5 eval 'process o' 'backtick 23 3600 3600 printf "[5]  "' 'bindkey -k k9 prev' 'bindkey -k k; next' 'bindkey "^[[20;2~" number -1' 'bindkey "^[[21;2~" number +1'
bind -c Ul 6 eval 'process o' 'backtick 23 3600 3600 printf "[6]  "' 'bindkey -k F1 prev' 'bindkey -k F2 next' 'bindkey "^[[23;2~" number -1' 'bindkey "^[[24;2~" number +1'


# send the command character and set the nesting depth more easily, because typing out "^Aaaaaa" is tedious and error prone.
# usage: press ^Ay[123456] in the outermost session to send the command character to the desired nesting depth.
# press ^Au[123456] (or ^Aul[0123456] for left handed mode) in the outermost session to make the session on the specified nesting depth aware of its nesting depth
bind u command -c u
register o "^Au0"
bind -c Ur 0 process o
bind -c Ul 0 process o
register i "^AU1"
bind -c u  1 process i
bind -c u  2 stuff "^AU2"
bind -c u  3 stuff "^AaU3"
bind -c u  4 stuff "^AaaU4"
bind -c u  5 stuff "^AaaaU5"
bind -c u  6 stuff "^AaaaaU6"

bind y command -c y
bind -c y  1 command
bind -c y  2 stuff "^A"
bind -c y  3 stuff "^Aa"
bind -c y  4 stuff "^Aaa"
bind -c y  5 stuff "^Aaaa"
bind -c y  6 stuff "^Aaaaa"

# initializtion
bind U command -c Ur # right handed mode
#bind U command -c Ul # left handed mode
process i # start on nesting depth 1 by default

# since the F-keys are now potentially used up, you can send them to the shell via keybindings.
# Usage: press ^A, and then type out f5, f12 or whatever. F1 must be sent as ^Af01
bind f command -c f
bind -c f  0 command -c f0
bind -c f  1 command -c f1
bind -c f0 1 stuff "^[OP~"
bind -c f  2 stuff "^[OQ~"
bind -c f0 2 stuff "^[OQ~"
bind -c f  3 stuff "^[OR~"
bind -c f0 3 stuff "^[OR~"
bind -c f  4 stuff "^[OS~"
bind -c f0 4 stuff "^[OS~"
bind -c f  5 stuff "^[[15~"
bind -c f0 5 stuff "^[[15~"
bind -c f  6 stuff "^[[17~"
bind -c f0 6 stuff "^[[17~"
bind -c f  7 stuff "^[[18~"
bind -c f0 7 stuff "^[[18~"
bind -c f  8 stuff "^[[19~"
bind -c f0 8 stuff "^[[19~"
bind -c f  9 stuff "^[[20~"
bind -c f0 9 stuff "^[[20~"
bind -c f1 0 stuff "^[[21~"
bind -c f1 1 stuff "^[[23~"
bind -c f1 2 stuff "^[[24~"


### some niceties for dealing with layouts & regions
layout new # initialize with one layout instead of none
bind o layout show # show all layouts; active layout is marked with *
bind C eval 'layout new' 'layout show' # create a layout
bind V eval 'layout remove' 'layout show' # remove current layout
bind P eval 'layout prev' 'layout show' # previous layout
bind N eval 'layout next' 'layout show' # next layout
register t "^A:layout title "
bind O process t # change layout title
bind h focus left
bind j focus down
bind k focus up
bind l focus right
# this next (monstrous) command implements a 'layout mode' that allows you to rearrange your layouts in a more accessible fashion than vanilla screen, and maybe almost as nice as tmux.
# keybindings in 'layout mode':
# tab: focus next region
# shift+tab: focus previous region
# arrow keys: focus neighboring region (unless the arrow keys are captured by something else)
# h: focus left
# j: focus down
# k: focus up
# l: focus right
# H: decrease region width
# J: increase region height
# K: decrease region height
# L: increase region width
# Y/Z: decrease region width by 10
# U: increase region height by 10
# I: decrease region height by 10
# O: increase region width by 10
# =: equalize region sizes
# s: horizontal split
# |: vertical split
# x: remove current region
# q: remove all regions but the current one
# f: fit window size to current region
# C: create new layout
# V: remove current layout
# c: create new window
# v: kill current window
# p: select previous layout
# n: select next layout
# o: show layouts
# i: show window info (including dimensions)
# r: exit layout mode
# note that, ironically, you can't change layout titles in layout mode. That's because the keybindings interfere with typing the command 'layout title', and would probably interfere with typing the new title as well.
bind R eval 'backtick 20 3600 3600 printf " Layout mode. [r] to exit "' 'bindkey \011 focus' 'bindkey ^[[Z focus prev' 'bindkey h focus left' 'bindkey j focus down' 'bindkey k focus up' 'bindkey l focus right' 'bindkey -k ku focus up' 'bindkey -k kd focus down' 'bindkey -k kr focus right' 'bindkey -k kl focus left' 'bindkey H resize -h -1' 'bindkey J resize -v +1' 'bindkey K resize -v -1' 'bindkey L resize -h +1' 'bindkey Y resize -h -10' 'bindkey Z resize -h -10' 'bindkey U resize -v +10' 'bindkey I resize -v -10' 'bindkey O resize -h +10' 'bindkey = eval "resize =" "resize -h =" "info"' 'bindkey f eval "fit" "info"' 'bindkey C eval "layout new" "layout show"' 'bindkey c screen' 'bindkey V eval "layout remove" "layout show"' 'bindkey v kill' 'bindkey o layout show' 'bindkey i info' 'bindkey p eval "layout prev" "layout show"' 'bindkey n eval "layout next" "layout show"' 'bindkey s split' 'bindkey | split -v' 'bindkey q only' 'bindkey x remove' 'bindkey r eval "bindkey \"\\011\"" "bindkey ^[[Z" "bindkey h" "bindkey j" "bindkey k" "bindkey l" "bindkey -k ku" "bindkey -k kd" "bindkey -k kr" "bindkey -k kl" "bindkey H" "bindkey J" "bindkey K" "bindkey L" "bindkey Y" "bindkey Z" "bindkey U" "bindkey I" "bindkey O" "bindkey =" "bindkey f" "bindkey C" "bindkey c" "bindkey V" "bindkey v" "bindkey o" "bindkey i" "bindkey p" "bindkey n" "bindkey r" "bindkey s" "bindkey |" "bindkey q" "bindkey x" "backtick 20"'


# more caption/hardstatus customization aimed at improving interaction with complex layouts:
# you can move the session name & clock from the caption to the hardstatus line with ^A#j or ^A+j, and back to the caption line with ^A#k or ^A+k
# you can reduce the window list to show only the current window with ^A#h or ^A+h, and expand it back to the full list with ^A#l or ^A+l

###### fancy new backtick plan:
#1..9: info items
#20..29: other visible stuff (borders, modes)
backtick 20 # used to display 'layout mode' in the hardstatus line.
backtick 21 3600 3600 printf "|" # left & right border in caption & hardstatus line.
backtick 22 # also left & right border in caption & hardstatus, but with blinking in the active window. Used for !!-mode, off by default.
backtick 23 # empty by default. Is changed to display the nesting depth as you set it.
backtick 24 3600 3600 printf "$USER"
# crazy shit alert: This ugly mess is the least insane (though still plenty insane) way I could think of to make a single keybinding toggle something on and off. With this, you can put a screen session into a mode where (1) you can switch between different regions with Alt+arrow keys, and (2) the active region is helpfully marked with blinking !s on either side of the caption line
# usage: ^A!!
bind ! command -c exclam
bind -c exclam : command -c exclamcolon
bind -c exclamcolon 1 eval 'backtick 21' 'backtick 22 3600 3600 printf "!"' 'bindkey "^[[1;3A" focus up' 'bindkey "^[[1;3B" focus down' 'bindkey "^[[1;3C" focus right' 'bindkey "^[[1;3D" focus left' 'register ! "^A!:0"'
bind -c exclamcolon 0 eval 'backtick 22' 'backtick 21 3600 3600 printf "|"' 'bindkey "^[[1;3A"'          'bindkey "^[[1;3B"'            'bindkey "^[[1;3C"'             'bindkey "^[[1;3D"'            'register ! "^A!:1"'
register ! "^A!:1"
bind -c exclam ! process !
#40..59: toggles on caption line
#60..79: toggles on hardstatus line



bind          '#' eval 'command -c hash' 'echo "statusbar cfg: [123456789]: items; [roygcbmwROYGCBMW]: colors"'
bind -c hash  '#' eval 'command -c hash' 'echo "statusbar cfg: [123456789]: items, [roygcbmwROYGCBMW]: colors"'
bind -c hash1 '#' eval 'command -c hash' 'echo "statusbar cfg: [123456789]: items, [roygcbmwROYGCBMW]: colors"'
bind -c hash2 '#' eval 'command -c hash' 'echo "statusbar cfg: [123456789]: items, [roygcbmwROYGCBMW]: colors"'
bind -c hash3 '#' eval 'command -c hash' 'echo "statusbar cfg: [123456789]: items, [roygcbmwROYGCBMW]: colors"'
bind -c hash4 '#' eval 'command -c hash' 'echo "statusbar cfg: [123456789]: items, [roygcbmwROYGCBMW]: colors"'
bind -c hash5 '#' eval 'command -c hash' 'echo "statusbar cfg: [123456789]: items, [roygcbmwROYGCBMW]: colors"'
bind -c hash6 '#' eval 'command -c hash' 'echo "statusbar cfg: [123456789]: items, [roygcbmwROYGCBMW]: colors"'
bind -c hash7 '#' eval 'command -c hash' 'echo "statusbar cfg: [123456789]: items, [roygcbmwROYGCBMW]: colors"'
bind -c hash8 '#' eval 'command -c hash' 'echo "statusbar cfg: [123456789]: items, [roygcbmwROYGCBMW]: colors"'
bind -c hash9 '#' eval 'command -c hash' 'echo "statusbar cfg: [123456789]: items, [roygcbmwROYGCBMW]: colors"'

# screen session title
bind -c hash  1 eval 'command -c hash1' 'echo "session title: [0]: off, [2]: full title, [3]: short, [k]: on caption, [j]: on hardstatus"'
bind -c hash1 1 eval 'command -c hash1' 'echo "session title: [0]: off, [2]: full title, [3]: short, [k]: on caption, [j]: on hardstatus"'
bind -c hash1 0 backtick 1
bind -c hash1 2 eval "backtick 1 60 60 sh -c 'echo $(screen -ls | grep -o \"\$PPID[\^[:space:]]*\"):'"
bind -c hash1 3 backtick 1 60 60 sh -c 'printf "$PPID:"' # shortens the display of the screen session name to just the numeric ID. Useful for small terminals.
bind -c hash1 k eval 'backtick 41' 'backtick 61 3600 3600 printf " "'
bind -c hash1 j eval 'backtick 41 3600 3600 printf " "' 'backtick 61'

# window list
bind -c hash    2  eval 'command -c hash2'  'echo "windows: [3]: in caption line, [4]: on hardstatus line"'
bind -c hash2   2  eval 'command -c hash2'  'echo "windows: [3]: in caption line, [4]: on hardstatus line"'
bind -c hash23 '#' eval 'command -c hash2'  'echo "windows: [3]: in caption line, [4]: on hardstatus line"'
bind -c hash24 '#' eval 'command -c hash2'  'echo "windows: [3]: in caption line, [4]: on hardstatus line"'
bind -c hash2   3  eval 'command -c hash23' 'echo "windows on caption line: [2]: off, [4]: full, [5]: only active"'
bind -c hash23  3  eval 'command -c hash23' 'echo "windows on caption line: [2]: off, [4]: full, [5]: only active"'
bind -c hash23  2  eval 'backtick 42 3600 3600 printf " "' 'backtick 43 3600 3600 printf " "'
bind -c hash23  4  eval 'backtick 42' 'backtick 43'
bind -c hash23  5  eval 'backtick 42 3600 3600 printf " "' 'backtick 43'
bind -c hash2   4  eval 'command -c hash24' 'echo "windows on hardstatus: [3]: off, [5]: full, [6]: only active"'
bind -c hash24  4  eval 'command -c hash24' 'echo "windows on hardstatus: [3]: off, [5]: full, [6]: only active"'
bind -c hash24  3  eval 'backtick 62 3600 3600 printf " "' 'backtick 63 3600 3600 printf " "'
bind -c hash24  5  eval 'backtick 62' 'backtick 63'
bind -c hash24  6  eval 'backtick 62 3600 3600 printf " "' 'backtick 63'

# Clock displays.
bind -c hash  3 eval 'command -c hash3' 'echo "clock: [2]: off, [4]: full, [5]: short, [6]: unix, [7]: hex, [8]: binary, [9]: RBC, [0]: ddate, [k]: on caption, [j]: on hardstatus"'
bind -c hash3 3 eval 'command -c hash3' 'echo "clock: [2]: off, [4]: full, [5]: short, [6]: unix, [7]: hex, [8]: binary, [9]: RBC, [0]: ddate, [k]: on caption, [j]: on hardstatus"'
bind -c hash3 2 eval 'backtick 3'
bind -c hash3 4 backtick 3 1 1 date +'%a %F  %R:%S  UTC%:::z'
bind -c hash3 5 eval 'backtick 3 1 1 date +"%R:%S"' # simpler (shorter) clock display. Useful for small terminals.
bind -c hash3 6 eval 'backtick 3 1 1 date +"%s"' # use unix timestamp (seconds since 1970-01-01 00:00:00 UTC) for the clock display
bind -c hash3 7 eval "backtick 3 1 1 sh -c 'dc -e \"16o $(date +%s) p\"'" # unix timestamp in hexadecimal
bind -c hash3 8 eval "backtick 3 1 1 sh -c 'dc -e \"2o $(date +%s) p\"'" # unix timestamp in binary
bind -c hash3 9 eval "backtick 3 1 1 sh -c 'dc -e \"2o $(date +%s) p\"|sed -nr \"s/0/A/g;s/(\^|A)1/\\1B/g;s/(1|B)A/\\1C/g;s/(A|1)/0/g;s/(B|C)/1/gp\"'" # unix timestamp in Gray code (aka. reflected binary code, RBC), just because I can
bind -c hash3 0 backtick 3 1 1 sh -c 'echo "$(ddate +%H\ %a\ %Y-%b-%d)  $(date +%R:%S\ \ UTC%:::z)"' # Discordian date!
bind -c hash3 k eval 'backtick 44' 'backtick 64 3600 3600 printf " "'
bind -c hash3 j eval 'backtick 44 3600 3600 printf " "' 'backtick 64'

# list of all active network interfaces and their IP addresses (with subnet mask). Formerly known as 'shortip'
bind -c hash  4 eval 'command -c hash4' 'echo "IP interface & address display: [3]: off, [5]: IPv4 only [6]: IPv4 & v6, [7]: IPv4 scrolling, [8]: IPv4 & v6 scrolling"'
bind -c hash4 4 eval 'command -c hash4' 'echo "IP interface & address display: [3]: off, [5]: IPv4 only [6]: IPv4 & v6, [7]: IPv4 scrolling, [8]: IPv4 & v6 scrolling"'
bind -c hash4 3 eval 'backtick 4'
bind -c hash4 5 backtick 4 10 10 sh -c 'ip -o a|sed -nr "1h;1!H;\${;g;s/([0-9]+: lo +[^\\n]+(\$|\\n)|[^\\n]+scope link[^\\n]+(\$|\\n))//g;s/[0-9]+: ([^ ]+) +inet ([0-9a-f.:]+\\/[0-9]+) [^\\n]+(\$|\\n)/\\1=\\2 /g;s/ \$//g;p;}"' #classic mode. Static display, no shenanigans.
bind -c hash4 6 backtick 4 10 10 sh -c 'ip -o a|sed -nr "1h;1!H;\${;g;s/([0-9]+: lo +[^\\n]+(\$|\\n)|[^\\n]+scope link[^\\n]+(\$|\\n))//g;s/[0-9]+: ([^ ]+) +inet6? ([0-9a-f.:]+\\/[0-9]+) [^\\n]+(\$|\\n)/\\1=\\2 /g;s/ \$//g;p;}"' #classic mode. Static display, no shenanigans.
# scrolling IP display. Set length here--------v   Careful with this - If you switch this off again, the shell script will continue to run in the background.
bind -c hash4 7 backtick 4 0 0 bash -c 'LENGTH=15; shortip() { ip -o a|sed -nr "1h;1!H;\${;g;s/([0-9]+: lo +[^\\n]+(\$|\\n)|[^\\n]+scope link[^\\n]+(\$|\\n))//g;s/[0-9]+: ([^ ]+) +inet ([0-9a-f.:]+\\/[0-9]+) [^\\n]+(\$|\\n)/\\1=\\2 /g;s/ \$//g;p;}"; }; STRING=""; while true; do while [ ${#STRING} -lt $LENGTH ]; do STRING="$STRING $(shortip)"; done; echo "$STRING" | sed -nr "s/^(.{${LENGTH}})(.+)/\1/p"; sleep 0.5; STRING=$(echo "$STRING" | sed -nr "s/^.//p"); done'
bind -c hash4 8 backtick 4 0 0 bash -c 'LENGTH=15; shortip() { ip -o a|sed -nr "1h;1!H;\${;g;s/([0-9]+: lo +[^\\n]+(\$|\\n)|[^\\n]+scope link[^\\n]+(\$|\\n))//g;s/[0-9]+: ([^ ]+) +inet6? ([0-9a-f.:]+\\/[0-9]+) [^\\n]+(\$|\\n)/\\1=\\2 /g;s/ \$//g;p;}"; }; STRING=""; while true; do while [ ${#STRING} -lt $LENGTH ]; do STRING="$STRING $(shortip)"; done; echo "$STRING" | sed -nr "s/^(.{${LENGTH}})(.+)/\1/p"; sleep 0.5; STRING=$(echo "$STRING" | sed -nr "s/^.//p"); done'

# public IPv4 address. Formerly known as 'shortextip'. Kindly provided by freenode-user gxg. May cause lagging, therefore disabled by default.
bind -c hash  5 eval 'command -c hash5' 'echo "external IP: [4]: off, [6]: on"'
bind -c hash5 4 eval 'backtick 5'
bind -c hash5 6 backtick 5 600 600 sh -c 'EXTIP=$(curl -fs --include --request GET "https://api.duckduckgo.com/?q=ip&l=1&no_redirect=1&skip_disambig=1&format=json"  | grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"); if [ "$EXTIP" != "" ]; then echo " EXT=$EXTIP"; fi'

# CPU load averages. I know there's a screen string escape for that, but then it'd be harder to make it pretty and toggleable. Formerly known as 'shortload'
bind -c hash  6 eval 'command -c hash6' 'echo "cpu load: [5]: off, [7]: normal load avg, [8]: usage% per core"'
bind -c hash6 6 eval 'command -c hash6' 'echo "cpu load: [5]: off, [7]: normal load avg, [8]: usage% per core"'
bind -c hash6 5 eval 'backtick 6'
bind -c hash6 7 backtick 6 10 10 sh -c 'echo "L:$(cat /proc/loadavg |cut -d\  -f1,2,3)"'
# CPU usage for each core, updated every second. Careful with this - If you switch this off again, the shell script will continue to run in the background. If you switch it on/off a lot, you end up with a bunch of processes that eat your CPU. Kill manually until I find a better solution.
bind -c hash6 8 backtick 6 0 0 bash -c 'stat() { echo $(awk "/^cpu[0-9]+/{usage=\$2+\$3+\$4;total=usage+\$5;print total\" \"usage}" /proc/stat); };OLD=($(stat));seq=($(seq 0 1 $((${#OLD[@]}-1))));cores=($(seq 0 1 $(($((${#OLD[@]}/2))-1))));while $true; do sleep 1;NEW=($(stat));DIF=();for i in ${seq[@]}; do DIF=(${DIF[@]} $((${NEW[$i]}-${OLD[$i]})));done;PERCENTS="";for i in ${cores[@]}; do PERCENT=$(($((${DIF[$(($(($i*2))+1))]}*100))/${DIF[$(($i*2))]}));if [ $PERCENT -lt 10 ]; then PERCENTS="$PERCENTS  ${PERCENT}%";elif [ $PERCENT -lt 100 ]; then PERCENTS="$PERCENTS ${PERCENT}%";else PERCENTS="${PERCENTS}100%";fi;done;echo "${PERCENTS[@]}";OLD=(${NEW[@]});done'

# RAM and swap usage. Formerly known as 'shortmem'
bind -c hash  7 eval 'command -c hash7' 'echo "RAM & swap: [6]: off, [8]: on"'
bind -c hash7 7 eval 'command -c hash7' 'echo "RAM & swap: [6]: off, [8]: on"'
bind -c hash7 6 eval 'backtick 7'
bind -c hash7 8 backtick 7 10 10 sh -c 'awk "/^MemTotal:/{mt=\$2};/^MemFree:/{mf=\$2};/^Buffers:/{b=\$2};/^Cached:/{c=\$2};/^SwapTotal:/{st=\$2};/^SwapFree:/{sf=\$2;print\"M:\"int((mt-mf-b-c)/1024)\"/\"int(mt/1024)\" S:\"int((st-sf)/1024)\"/\"int(st/1024)}" /proc/meminfo'

# disk space usage. 
bind -c hash  8 eval 'command -c hash8' 'echo "disk space usage: [7]: off, [9]: on"'
bind -c hash8 8 eval 'command -c hash8' 'echo "disk space usage: [7]: off, [9]: on"'
bind -c hash8 7 eval 'backtick 8'
# List of filesystems here-------------------------v
bind -c hash8 9 backtick 8 600 600 bash -c 'DEVS=( /boot / /home ); echo $(for DEV in ${DEVS[@]}; do df -hl $DEV |awk "NR==2"; done) |sed -nr "1h;1!H;\${;g;s/[^ ]+ +([0-9]+[,.]?[0-9]*[BKMGT]?) +([0-9]+[,.]?[0-9]*[BKMGT]?) +[0-9]+[,.]?[0-9]*[BKMGT]? +[0-9]+% +(\/[^ ]*)/\3:\2\/\1/g;p;}"'

# battery charge. Formerly known as 'shortbatt'
bind -c hash  9 eval 'command -c hash9' 'echo "battery charge: [8]: off, [0] on"'
bind -c hash9 9 eval 'command -c hash9' 'echo "battery charge: [8]: off, [0] on"'
bind -c hash9 8 eval 'backtick 9'
bind -c hash9 0 backtick 9 60 60 sh -c 'SHORTBATT=$(acpi|cut -d\  -f4,5); if [ "$SHORTBATT" != "" ]; then echo "B:$SHORTBATT"; fi'

# stuff that affects whole bars
bind -c hash    0  eval 'command -c hash0' 'echo "bars: [k]: caption bar, [j]: hardstatus, [123456789]: presets"'
bind -c hash0   0  eval 'command -c hash0' 'echo "bars: [k]: caption bar, [j]: hardstatus, [123456789]: presets"'
bind -c hash0k '#' eval 'command -c hash0' 'echo "bars: [k]: caption bar, [j]: hardstatus, [123456789]: presets"'
bind -c hash0j '#' eval 'command -c hash0' 'echo "bars: [k]: caption bar, [j]: hardstatus, [123456789]: presets"'
bind -c hash0   k  eval 'command -c hash0k' 'echo "caption: [0]: splitonly, [1]: always"'
bind -c hash0k  k  eval 'command -c hash0k' 'echo "caption: [0]: splitonly, [1]: always"'
bind -c hash0k  0  caption splitonly
bind -c hash0k  1  caption always
bind -c hash0   j  eval 'command -c hash0j' 'echo "hardstatus: [0]: alwaysignore, [1]: lastline, [2]: firstline"'
bind -c hash0j  j  eval 'command -c hash0j' 'echo "hardstatus: [0]: alwaysignore, [1]: lastline, [2]: firstline"'
bind -c hash0j  0  hardstatus alwaysignore
bind -c hash0j  1  hardstatus lastline
bind -c hash0j  2  hardstatus firstline
bind -c hash0   1  eval 'register : "^A#0k1^A#0j1^A#1k^A#12^A#234^A#243^A#3k^A#34^A#46^A#54^A#67^A#78^A#89^A#90^l"' 'process :'
bind -c hash0   2  eval 'register : "^A#0k1^A#0j1^A#1k^A#12^A#234^A#243^A#3k^A#32^A#43^A#54^A#65^A#76^A#87^A#98^l"' 'process :'
bind -c hash0   3  eval 'register : "^A#0k1^A#0j1^A#1j^A#13^A#235^A#245^A#3j^A#35^A#46^A#54^A#67^A#78^A#89^A#90^l"' 'process :'
bind -c hash0   4  eval 'register : "^A#0k1^A#0j1^A#1j^A#13^A#235^A#245^A#3j^A#32^A#43^A#54^A#65^A#76^A#87^A#98^l"' 'process :'

# this defines the set of backticks that are turned on by default when screen starts
eval 'register : "^A#01"' 'process :'

### caption & hardstatus

# Caption & hardstatus lines can be switched off/on with ^A[eE] and ^A[gG], respectively, or both with ^A[tT].
# the caption is forced on if there's more than one region. This is a feature of screen, not of this config.
# bind 'e' caption splitonly
# bind 'E' caption always
# bind 'g' hardstatus alwaysignore
# bind 'G' hardstatus lastline
# register j "^Ae^Ag"
# register J "^AE^AG"
# bind 't' process j
# bind 'T' process J
# 
# #some initialization
# caption always # turns caption line on 
# hardstatus lastline # turns hardstatus line on
# hardstatus off # emulation of the terminal’s hardstatus line. Seriously, who has hardware with an actual physical hardstatus line nowadays?

# Colors
# usage: press ^A#[roygcbmwROYGCBMW] to change the color. Capital letters produce an inverted color scheme (black foreground, colored background), for a whooping 16 variants total.
#                                                 caption color goes here-----v                                                                                                                                                                                                   hardstatus color goes here-----v
bind -c hash r eval 'caption string "%{= kw}%21`%{+B}%?%F%:%{-B}%?%22`%{-B} %{R}%{=b kW}%?%PCopy mode  %?%{-}%?%E%{+r}%?%?%41`%:%23`%1`%{-r}  %?%{-r}%?%42`%:%-Lw%?%?%43`%:%{+r}%n%f %t%{-r}%?%?%42`%:%+Lw%? %=%?%44`%:%3` %?%{= kw}%{+B}%?%F%:%{-B}%?%22`%{-B}%21`"' 'hardstatus string "%{= kw}%21`%22`_%{=b kW}%20`%{-}%{R}%?%E%{+r}%?%?%61`%: %23`%1`%?%{-r}  %?%62`%:%-Lw%?%?%63`%:%{+r}%n%f %t%{-r}%?%?%62`%:%+Lw%?%=%24`@%H%?%{w}|%{-}%4`%5`%?%?%{w}|%{-}%6`%?%?%{w}|%{-}%7`%?%?%{w}|%{-}%8`%?%?%{w}|%{-}%9`%?%=%?%64`%:%3`%?%{w}_%22`%21`"'
bind -c hash o eval 'caption string "%{= kw}%21`%{+B}%?%F%:%{-B}%?%22`%{-B} %{y}%{=b kW}%?%PCopy mode  %?%{-}%?%E%{+r}%?%?%41`%:%23`%1`%{-r}  %?%{-r}%?%42`%:%-Lw%?%?%43`%:%{+r}%n%f %t%{-r}%?%?%42`%:%+Lw%? %=%?%44`%:%3` %?%{= kw}%{+B}%?%F%:%{-B}%?%22`%{-B}%21`"' 'hardstatus string "%{= kw}%21`%22`_%{=b kW}%20`%{-}%{y}%?%E%{+r}%?%?%61`%: %23`%1`%?%{-r}  %?%62`%:%-Lw%?%?%63`%:%{+r}%n%f %t%{-r}%?%?%62`%:%+Lw%?%=%24`@%H%?%{w}|%{-}%4`%5`%?%?%{w}|%{-}%6`%?%?%{w}|%{-}%7`%?%?%{w}|%{-}%8`%?%?%{w}|%{-}%9`%?%=%?%64`%:%3`%?%{w}_%22`%21`"'
bind -c hash y eval 'caption string "%{= kw}%21`%{+B}%?%F%:%{-B}%?%22`%{-B} %{Y}%{=b kW}%?%PCopy mode  %?%{-}%?%E%{+r}%?%?%41`%:%23`%1`%{-r}  %?%{-r}%?%42`%:%-Lw%?%?%43`%:%{+r}%n%f %t%{-r}%?%?%42`%:%+Lw%? %=%?%44`%:%3` %?%{= kw}%{+B}%?%F%:%{-B}%?%22`%{-B}%21`"' 'hardstatus string "%{= kw}%21`%22`_%{=b kW}%20`%{-}%{Y}%?%E%{+r}%?%?%61`%: %23`%1`%?%{-r}  %?%62`%:%-Lw%?%?%63`%:%{+r}%n%f %t%{-r}%?%?%62`%:%+Lw%?%=%24`@%H%?%{w}|%{-}%4`%5`%?%?%{w}|%{-}%6`%?%?%{w}|%{-}%7`%?%?%{w}|%{-}%8`%?%?%{w}|%{-}%9`%?%=%?%64`%:%3`%?%{w}_%22`%21`"'
bind -c hash g eval 'caption string "%{= kw}%21`%{+B}%?%F%:%{-B}%?%22`%{-B} %{G}%{=b kW}%?%PCopy mode  %?%{-}%?%E%{+r}%?%?%41`%:%23`%1`%{-r}  %?%{-r}%?%42`%:%-Lw%?%?%43`%:%{+r}%n%f %t%{-r}%?%?%42`%:%+Lw%? %=%?%44`%:%3` %?%{= kw}%{+B}%?%F%:%{-B}%?%22`%{-B}%21`"' 'hardstatus string "%{= kw}%21`%22`_%{=b kW}%20`%{-}%{G}%?%E%{+r}%?%?%61`%: %23`%1`%?%{-r}  %?%62`%:%-Lw%?%?%63`%:%{+r}%n%f %t%{-r}%?%?%62`%:%+Lw%?%=%24`@%H%?%{w}|%{-}%4`%5`%?%?%{w}|%{-}%6`%?%?%{w}|%{-}%7`%?%?%{w}|%{-}%8`%?%?%{w}|%{-}%9`%?%=%?%64`%:%3`%?%{w}_%22`%21`"'
bind -c hash c eval 'caption string "%{= kw}%21`%{+B}%?%F%:%{-B}%?%22`%{-B} %{C}%{=b kW}%?%PCopy mode  %?%{-}%?%E%{+r}%?%?%41`%:%23`%1`%{-r}  %?%{-r}%?%42`%:%-Lw%?%?%43`%:%{+r}%n%f %t%{-r}%?%?%42`%:%+Lw%? %=%?%44`%:%3` %?%{= kw}%{+B}%?%F%:%{-B}%?%22`%{-B}%21`"' 'hardstatus string "%{= kw}%21`%22`_%{=b kW}%20`%{-}%{C}%?%E%{+r}%?%?%61`%: %23`%1`%?%{-r}  %?%62`%:%-Lw%?%?%63`%:%{+r}%n%f %t%{-r}%?%?%62`%:%+Lw%?%=%24`@%H%?%{w}|%{-}%4`%5`%?%?%{w}|%{-}%6`%?%?%{w}|%{-}%7`%?%?%{w}|%{-}%8`%?%?%{w}|%{-}%9`%?%=%?%64`%:%3`%?%{w}_%22`%21`"'
bind -c hash b eval 'caption string "%{= kw}%21`%{+B}%?%F%:%{-B}%?%22`%{-B} %{B}%{=b kW}%?%PCopy mode  %?%{-}%?%E%{+r}%?%?%41`%:%23`%1`%{-r}  %?%{-r}%?%42`%:%-Lw%?%?%43`%:%{+r}%n%f %t%{-r}%?%?%42`%:%+Lw%? %=%?%44`%:%3` %?%{= kw}%{+B}%?%F%:%{-B}%?%22`%{-B}%21`"' 'hardstatus string "%{= kw}%21`%22`_%{=b kW}%20`%{-}%{B}%?%E%{+r}%?%?%61`%: %23`%1`%?%{-r}  %?%62`%:%-Lw%?%?%63`%:%{+r}%n%f %t%{-r}%?%?%62`%:%+Lw%?%=%24`@%H%?%{w}|%{-}%4`%5`%?%?%{w}|%{-}%6`%?%?%{w}|%{-}%7`%?%?%{w}|%{-}%8`%?%?%{w}|%{-}%9`%?%=%?%64`%:%3`%?%{w}_%22`%21`"'
bind -c hash m eval 'caption string "%{= kw}%21`%{+B}%?%F%:%{-B}%?%22`%{-B} %{M}%{=b kW}%?%PCopy mode  %?%{-}%?%E%{+r}%?%?%41`%:%23`%1`%{-r}  %?%{-r}%?%42`%:%-Lw%?%?%43`%:%{+r}%n%f %t%{-r}%?%?%42`%:%+Lw%? %=%?%44`%:%3` %?%{= kw}%{+B}%?%F%:%{-B}%?%22`%{-B}%21`"' 'hardstatus string "%{= kw}%21`%22`_%{=b kW}%20`%{-}%{M}%?%E%{+r}%?%?%61`%: %23`%1`%?%{-r}  %?%62`%:%-Lw%?%?%63`%:%{+r}%n%f %t%{-r}%?%?%62`%:%+Lw%?%=%24`@%H%?%{w}|%{-}%4`%5`%?%?%{w}|%{-}%6`%?%?%{w}|%{-}%7`%?%?%{w}|%{-}%8`%?%?%{w}|%{-}%9`%?%=%?%64`%:%3`%?%{w}_%22`%21`"'
bind -c hash w eval 'caption string "%{= kw}%21`%{+B}%?%F%:%{-B}%?%22`%{-B} %{W}%{=b kW}%?%PCopy mode  %?%{-}%?%E%{+r}%?%?%41`%:%23`%1`%{-r}  %?%{-r}%?%42`%:%-Lw%?%?%43`%:%{+r}%n%f %t%{-r}%?%?%42`%:%+Lw%? %=%?%44`%:%3` %?%{= kw}%{+B}%?%F%:%{-B}%?%22`%{-B}%21`"' 'hardstatus string "%{= kw}%21`%22`_%{=b kW}%20`%{-}%{W}%?%E%{+r}%?%?%61`%: %23`%1`%?%{-r}  %?%62`%:%-Lw%?%?%63`%:%{+r}%n%f %t%{-r}%?%?%62`%:%+Lw%?%=%24`@%H%?%{w}|%{-}%4`%5`%?%?%{w}|%{-}%6`%?%?%{w}|%{-}%7`%?%?%{w}|%{-}%8`%?%?%{w}|%{-}%9`%?%=%?%64`%:%3`%?%{w}_%22`%21`"'
# inverted color schemes
#             caption color goes here-----v                                                                                                                                                                                                                   hardstatus color goes here-----v
bind -c hash R eval 'caption string "%{! kr}%{-b}%21`%{+B}%?%F%:%{-B}%?%22`%{-B} %{=b kW}%?%P Copy mode %?%{-}%?%E%{=b kI}%?%?%41`%:%23`%1`%?%?%E%{-}  %:  %?%?%42`%:%-Lw%?%?%43`%:%{= I}%n%f %t%{-}%?%?%42`%:%+Lw%? %=%?%44`%:%3`%? %{+B}%?%F%:%{-B}%?%22`%{-B}%21`"' 'hardstatus string "%{!r kr}%{-b}%21`%22`_%{=b kW}%20`%{-}%?%E%{=b kI}%?%?%61`%:%23`%1`%?%?%E%{-}%?  %?%62`%:%-Lw%?%?%63`%:%{= I}%n%f %t%{-}%?%?%62`%:%+Lw%?%=%24`@%H%?|%4`%5`%?%?|%6`%?%?|%7`%?%?|%8`%?%?|%9`%?%=%?%64`%:%3`%?_%22`%21`"'
bind -c hash O eval 'caption string "%{! ky}%{-b}%21`%{+B}%?%F%:%{-B}%?%22`%{-B} %{=b kW}%?%P Copy mode %?%{-}%?%E%{=b kI}%?%?%41`%:%23`%1`%?%?%E%{-}  %:  %?%?%42`%:%-Lw%?%?%43`%:%{= i}%n%f %t%{-}%?%?%42`%:%+Lw%? %=%?%44`%:%3`%? %{+B}%?%F%:%{-B}%?%22`%{-B}%21`"' 'hardstatus string "%{!r ky}%{-b}%21`%22`_%{=b kW}%20`%{-}%?%E%{=b kI}%?%?%61`%:%23`%1`%?%?%E%{-}%?  %?%62`%:%-Lw%?%?%63`%:%{= i}%n%f %t%{-}%?%?%62`%:%+Lw%?%=%24`@%H%?|%4`%5`%?%?|%6`%?%?|%7`%?%?|%8`%?%?|%9`%?%=%?%64`%:%3`%?_%22`%21`"'
bind -c hash Y eval 'caption string "%{! kY}%{-b}%21`%{+B}%?%F%:%{-B}%?%22`%{-B} %{=b kW}%?%P Copy mode %?%{-}%?%E%{=b kI}%?%?%41`%:%23`%1`%?%?%E%{-}  %:  %?%?%42`%:%-Lw%?%?%43`%:%{= I}%n%f %t%{-}%?%?%42`%:%+Lw%? %=%?%44`%:%3`%? %{+B}%?%F%:%{-B}%?%22`%{-B}%21`"' 'hardstatus string "%{!r kY}%{-b}%21`%22`_%{=b kW}%20`%{-}%?%E%{=b kI}%?%?%61`%:%23`%1`%?%?%E%{-}%?  %?%62`%:%-Lw%?%?%63`%:%{= I}%n%f %t%{-}%?%?%62`%:%+Lw%?%=%24`@%H%?|%4`%5`%?%?|%6`%?%?|%7`%?%?|%8`%?%?|%9`%?%=%?%64`%:%3`%?_%22`%21`"'
bind -c hash G eval 'caption string "%{! kG}%{-b}%21`%{+B}%?%F%:%{-B}%?%22`%{-B} %{=b kW}%?%P Copy mode %?%{-}%?%E%{=b kI}%?%?%41`%:%23`%1`%?%?%E%{-}  %:  %?%?%42`%:%-Lw%?%?%43`%:%{= I}%n%f %t%{-}%?%?%42`%:%+Lw%? %=%?%44`%:%3`%? %{+B}%?%F%:%{-B}%?%22`%{-B}%21`"' 'hardstatus string "%{!r kG}%{-b}%21`%22`_%{=b kW}%20`%{-}%?%E%{=b kI}%?%?%61`%:%23`%1`%?%?%E%{-}%?  %?%62`%:%-Lw%?%?%63`%:%{= I}%n%f %t%{-}%?%?%62`%:%+Lw%?%=%24`@%H%?|%4`%5`%?%?|%6`%?%?|%7`%?%?|%8`%?%?|%9`%?%=%?%64`%:%3`%?_%22`%21`"'
bind -c hash C eval 'caption string "%{! kc}%{-b}%21`%{+B}%?%F%:%{-B}%?%22`%{-B} %{=b kW}%?%P Copy mode %?%{-}%?%E%{=b kI}%?%?%41`%:%23`%1`%?%?%E%{-}  %:  %?%?%42`%:%-Lw%?%?%43`%:%{= I}%n%f %t%{-}%?%?%42`%:%+Lw%? %=%?%44`%:%3`%? %{+B}%?%F%:%{-B}%?%22`%{-B}%21`"' 'hardstatus string "%{!r kc}%{-b}%21`%22`_%{=b kW}%20`%{-}%?%E%{=b kI}%?%?%61`%:%23`%1`%?%?%E%{-}%?  %?%62`%:%-Lw%?%?%63`%:%{= I}%n%f %t%{-}%?%?%62`%:%+Lw%?%=%24`@%H%?|%4`%5`%?%?|%6`%?%?|%7`%?%?|%8`%?%?|%9`%?%=%?%64`%:%3`%?_%22`%21`"'
bind -c hash B eval 'caption string "%{! kB}%{-b}%21`%{+B}%?%F%:%{-B}%?%22`%{-B} %{=b kW}%?%P Copy mode %?%{-}%?%E%{=b kI}%?%?%41`%:%23`%1`%?%?%E%{-}  %:  %?%?%42`%:%-Lw%?%?%43`%:%{= I}%n%f %t%{-}%?%?%42`%:%+Lw%? %=%?%44`%:%3`%? %{+B}%?%F%:%{-B}%?%22`%{-B}%21`"' 'hardstatus string "%{!r kB}%{-b}%21`%22`_%{=b kW}%20`%{-}%?%E%{=b kI}%?%?%61`%:%23`%1`%?%?%E%{-}%?  %?%62`%:%-Lw%?%?%63`%:%{= I}%n%f %t%{-}%?%?%62`%:%+Lw%?%=%24`@%H%?|%4`%5`%?%?|%6`%?%?|%7`%?%?|%8`%?%?|%9`%?%=%?%64`%:%3`%?_%22`%21`"'
bind -c hash M eval 'caption string "%{! km}%{-b}%21`%{+B}%?%F%:%{-B}%?%22`%{-B} %{=b kW}%?%P Copy mode %?%{-}%?%E%{=b kI}%?%?%41`%:%23`%1`%?%?%E%{-}  %:  %?%?%42`%:%-Lw%?%?%43`%:%{= I}%n%f %t%{-}%?%?%42`%:%+Lw%? %=%?%44`%:%3`%? %{+B}%?%F%:%{-B}%?%22`%{-B}%21`"' 'hardstatus string "%{!r km}%{-b}%21`%22`_%{=b kW}%20`%{-}%?%E%{=b kI}%?%?%61`%:%23`%1`%?%?%E%{-}%?  %?%62`%:%-Lw%?%?%63`%:%{= I}%n%f %t%{-}%?%?%62`%:%+Lw%?%=%24`@%H%?|%4`%5`%?%?|%6`%?%?|%7`%?%?|%8`%?%?|%9`%?%=%?%64`%:%3`%?_%22`%21`"'
bind -c hash W eval 'caption string "%{! kW}%{-b}%21`%{+B}%?%F%:%{-B}%?%22`%{-B} %{=b kW}%?%P Copy mode %?%{-}%?%E%{=b kI}%?%?%41`%:%23`%1`%?%?%E%{-}  %:  %?%?%42`%:%-Lw%?%?%43`%:%{= I}%n%f %t%{-}%?%?%42`%:%+Lw%? %=%?%44`%:%3`%? %{+B}%?%F%:%{-B}%?%22`%{-B}%21`"' 'hardstatus string "%{!r kW}%{-b}%21`%22`_%{=b kW}%20`%{-}%?%E%{=b kI}%?%?%61`%:%23`%1`%?%?%E%{-}%?  %?%62`%:%-Lw%?%?%63`%:%{= I}%n%f %t%{-}%?%?%62`%:%+Lw%?%=%24`@%H%?|%4`%5`%?%?|%6`%?%?|%7`%?%?|%8`%?%?|%9`%?%=%?%64`%:%3`%?_%22`%21`"'

# coloring cmds, messages, the selected text in copy mode & region borders
# usage: ^A![roygcbmwROYGCBMW]
bind -c exclam r eval 'rendition so Rk' 'redisplay'
bind -c exclam o eval 'rendition so yk' 'redisplay'
bind -c exclam y eval 'rendition so Yk' 'redisplay'
bind -c exclam g eval 'rendition so Gk' 'redisplay'
bind -c exclam c eval 'rendition so Ck' 'redisplay'
bind -c exclam b eval 'rendition so Bk' 'redisplay'
bind -c exclam m eval 'rendition so Mk' 'redisplay'
bind -c exclam w eval 'rendition so Wk' 'redisplay'
bind -c exclam R eval 'rendition so kr' 'redisplay'
bind -c exclam O eval 'rendition so ky' 'redisplay'
bind -c exclam Y eval 'rendition so kY' 'redisplay'
bind -c exclam G eval 'rendition so kG' 'redisplay'
bind -c exclam C eval 'rendition so kc' 'redisplay'
bind -c exclam B eval 'rendition so kB' 'redisplay'
bind -c exclam M eval 'rendition so km' 'redisplay'
bind -c exclam W eval 'rendition so kW' 'redisplay'

# color initialization is done simply by sending the desired key bindings to screen. Define here:
register c "^A#b^A!B"
process c

shelltitle '>|bash'                # necessary for window autorenaming magic. Set the first character in the quotes to whatever your bash prompt ends in.

# this implements a neat little curses ssh session manager (dependency: dialog). It parses your ~/.ssh/config, so it doesn't require any additional configuration.

bind ~ exec bash -c 'filter="1h;1!H;\${;g;s/(^|\n)[^\n]*cannot change locale[^\n]*\n|\n*\s*\$//g;s/^[^\n]+\n|\n[^\n]+\$//g;s/(^|\n)\t/\1/g;s/[\t ]/_/g;p}";screen -X title ssh-manager;while true;do exec 3>&1;r=$(dialog --scrollbar --begin 0 0 --no-items --ok-label "connect" --extra-button --extra-label "reload" --cancel-label "exit" --menu "ssh manager" 0 0 0 "localhost (no ssh)" $(grep -E "^ *Host +[^!?*,]+\$" .ssh/config | sed -nr "1h;1!H;\${;g;s/(^|\n) *Host +/ /g;p}") "[custom]" 2>&1 1>&3);xh=$?;exec 3>&-;if [ $xh -eq 0 ];then if [[ "$r" == "localhost (no ssh)" ]];then ss=$(screen -ls |sed -nr "$filter");exec 3>&1;s=$(dialog --scrollbar --begin 0 0 --no-items --ok-label "connect" --cancel-label "cancel" --menu "screen sessions" 0 0 0 "new screen" $ss "just bash" 2>&1 1>&3);xs=$?;exec 3>&-;if [ $xs -eq 0 ];then if [[ "$s" == "just bash" ]];then screen -X screen bash -c "bash";elif [[ "$s" == "new screen" ]];then screen -X screen -t localhost screen -m;else screen -X screen -t $(echo $s |sed -nr "s/_\(.+\)//p") screen -dRR $(echo $s|sed -nr "s/^([0-9]+)\..+/\1/p");fi;fi;elif [[ "$r" != "" ]];then if [[ "$r" == "[custom]" ]]; then exec 3>&1;r=$(dialog --begin 0 0 --inputbox "IP/hostname:" 0 0 2>&1 1>&3);exec 3>&-;fi;ss=$(ssh -t $r screen -ls |sed -nr "$filter");exec 3>&1;s=$(dialog --scrollbar --begin 0 0 --no-items --ok-label "connect" --cancel-label "cancel" --menu "screen sessions" 0 0 0 "new screen" $ss "just bash" 2>&1 1>&3);xs=$?;exec 3>&-;if [ $xs -eq 0 ];then if [[ "$s" == "just bash" ]];then screen -X screen ssh -t $r bash;elif [[ "$s" == "new screen" ]];then screen -X screen -t $r ssh -t $r screen -m;else screen -X screen -t $r ssh -t $r screen -dRR $(echo $s|sed -nr "s/^([0-9]+)\..+/\1/p");fi;fi;fi;elif [ $xh -eq 1 ];then break;elif [ $xh -eq 3 ];then screen -X title ssh-manager;continue;fi;done;reset;clear;'

##############################################################################
###### ADDITIONAL STUFF (put it where specified; remember to uncomment) ######
##############################################################################

### this goes in your .bashrc, for colorful prompts & window autorenaming magic
#prompt(){
#	PS1="\u@\h:\w\$>\[\e(B\e[m\]"
#	PS2=">\[\e(B\e[m\]"
#	case $1 in
#		r) PS1="\[\e(B\e[m\e[91m\]$PS1";PS2="\[\e(B\e[m\e[91m\]$PS2" ;;
#		o) PS1="\[\e(B\e[m\e[33m\]$PS1";PS2="\[\e(B\e[m\e[33m\]$PS2" ;;
#		y) PS1="\[\e(B\e[m\e[93m\]$PS1";PS2="\[\e(B\e[m\e[93m\]$PS2" ;;
#		g) PS1="\[\e(B\e[m\e[92m\]$PS1";PS2="\[\e(B\e[m\e[92m\]$PS2" ;;
#		c) PS1="\[\e(B\e[m\e[96m\]$PS1";PS2="\[\e(B\e[m\e[96m\]$PS2" ;;
#		b) PS1="\[\e(B\e[m\e[94m\]$PS1";PS2="\[\e(B\e[m\e[94m\]$PS2" ;;
#		m) PS1="\[\e(B\e[m\e[95m\]$PS1";PS2="\[\e(B\e[m\e[95m\]$PS2" ;;
#		w) PS1="\[\e(B\e[m\e[97m\]$PS1";PS2="\[\e(B\e[m\e[97m\]$PS2" ;;
#		R) PS1="\[\e(B\e[m\e[41m\e[30m\]$PS1";PS2="\[\e(B\e[m\e[41m\e[30m\]$PS2" ;;
#		O) PS1="\[\e(B\e[m\e[43m\e[30m\]$PS1";PS2="\[\e(B\e[m\e[43m\e[30m\]$PS2" ;;
#		Y) PS1="\[\e(B\e[m\e[103m\e[30m\]$PS1";PS2="\[\e(B\e[m\e[103m\e[30m\]$PS2" ;;
#		G) PS1="\[\e(B\e[m\e[102m\e[30m\]$PS1";PS2="\[\e(B\e[m\e[102m\e[30m\]$PS2" ;;
#		C) PS1="\[\e(B\e[m\e[46m\e[30m\]$PS1";PS2="\[\e(B\e[m\e[46m\e[30m\]$PS2" ;;
#		B) PS1="\[\e(B\e[m\e[104m\e[30m\]$PS1";PS2="\[\e(B\e[m\e[104m\e[30m\]$PS2" ;;
#		M) PS1="\[\e(B\e[m\e[45m\e[30m\]$PS1";PS2="\[\e(B\e[m\e[45m\e[30m\]$PS2" ;;
#		W) PS1="\[\e(B\e[m\e[107m\e[30m\]$PS1";PS2="\[\e(B\e[m\e[107m\e[30m\]$PS2" ;;
#	esac
#	case $TERM in
#		screen*) PS1="\[\ek\e\\\\\]\[\ek\w\e\\\\\]$PS1" ;;
#	esac
#}
#prompt b
#
#sudo() { echo -ne "\eksudo $1\e\\"; /usr/bin/sudo $@; }

Last edited by then4116 (2017-10-12 15:05:30)

Offline

Board footer

Powered by FluxBB