Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

howto change screen hardstatus dynamically with format, from shell ? I successfully configured screen using 256 colors and tabs and so on, here is my .screenrc : http://pastebin.com/g8XbMWBH

I use the caption for the tabs, and the hardstatus as the way it's meant to be: a messaging status line.

what I wanna do is simple: showing colored messages on hardstatus, from shell scripts returns.

Here is what I managed to do at this point:

# changing xterm window title:
echo -e '\033k'window_title'\033\\'
echo -ne "\ek window_title\e\\"

# sending non colored messages to hardstatus:
echo -ne "\e! hardstatus_global_message\e\\"
echo -ne "\e^ hardstatus_private_message\e\\"

# reformating the hardstatus string:
echo -ne "\e]0; %{.BW}%{..G}colored hardstatus try\e\\"
echo -ne "\e_ %{.BW}%{..G}colored hardstatus try\e\\"

The escape codes are available here: http://yz.kiev.ua/www/etc/screen-virt-term.txt

i still don't see how to reformat the hardstatus string, nor how to send color codes to it, nor if it's even possible or not ? searched here and everywhere for hours, now i'm tired and asking, thanks !

share|improve this question

It is possible to color the hardstatus strings as you are saying. When using the color codes as a script output, you need to use a special ASCII character (005) to escape the color codes, instead of the percent sign (%) that you would normally use in your .screenrc file. In an example script you would have something like this:

#script.sh
Black="\005{K}"
Red="\005{R}"
Green="\005{G}"
Yellow="\005{Y}"
Blue="\005{B}"
Purple="\005{M}"
Cyan="\005{C}"
White="\005{W}"

echo -ne "Here is$Green Green$White text."

Then, in your .screenrc file, as you may already know, call the above script with a backtick command:

# .screenrc
backtick 101 5 5 /path/to/script.sh

hardstatus alwayslastline "%101`"
share|improve this answer

gnil's solution with backtick is very useful if you want hardstatus to update every x number of seconds. If you only want hardstatus to update when you execute something on the shell (when you hit enter) then its better to follow this steps

  1. put somewhere in your hardstatus line %h
  2. test it by executing echo -ne '\x1B_Hello World\x1B\ this should show Hello World in your hardstatus where your placed %h
  3. create script similar to the one suggested by gnil HARDLINE="\005{g}$PWD\005{-}" echo -ne '\x1B_'$HARDLINE'\x1B\'
  4. Test this script, when you run it you should see current working directory in your hard status
  5. To make this script execute each time you hit enter update your .bashrc and add this line

    export PROMPT_COMMAND="set_hardline"

share|improve this answer
    
thanks, i will give it a try after my finals :) – scavenger Dec 9 '15 at 13:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .