docs:tips_n_tricks:screen.html
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
docs:tips_n_tricks:screen.html [07.07.2010 18:04 CEST] – peter | docs:tips_n_tricks:screen.html [16.03.2024 00:38 CET] (current) – [Logging and reading logs] peter | ||
---|---|---|---|
Line 2: | Line 2: | ||
===== show current directory or command in window name when using zsh ===== | ===== show current directory or command in window name when using zsh ===== | ||
+ | ==== Linux ==== | ||
put this in your '' | put this in your '' | ||
Line 11: | Line 11: | ||
precmd () { | precmd () { | ||
let "len = 54 - ${# | let "len = 54 - ${# | ||
- | screen -X -S " | + | screen -X -S " |
} | } | ||
preexec () { | preexec () { | ||
screen -X -S " | screen -X -S " | ||
+ | _my_last_cmd=" | ||
# # Maybe $2 or $3 is a better choice - I didn't get the difference yet. You may | # # Maybe $2 or $3 is a better choice - I didn't get the difference yet. You may | ||
# # analyse this with the statement: | # # analyse this with the statement: | ||
Line 21: | Line 22: | ||
;; | ;; | ||
esac | esac | ||
+ | |||
+ | ==== Mac OS X ==== | ||
+ | On Mac OS X (maybe on BSD systems in general), screen launches a '' | ||
+ | use the following lines in your '' | ||
+ | case "`ps -o ' | ||
+ | " | ||
+ | *) pppid=" | ||
+ | esac | ||
+ | | ||
+ | case " | ||
+ | "" | ||
+ | ;; | ||
+ | " | ||
+ | eval " | ||
+ | precmd () { | ||
+ | let \"len = 54 - \$# | ||
+ | screen -X -S " | ||
+ | } | ||
+ | preexec () { | ||
+ | screen -X -S \" | ||
+ | } | ||
+ | " | ||
+ | ;; | ||
+ | esac | ||
+ | |||
===== show current directory or command in window name when using bash ===== | ===== show current directory or command in window name when using bash ===== | ||
Line 44: | Line 70: | ||
PROMPT_COMMAND=' | PROMPT_COMMAND=' | ||
screentitle() { preexec " | screentitle() { preexec " | ||
- | trap screentitle DEBUG | + | |
+ | # trap screentitle | ||
+ | on_debug() | ||
+ | { | ||
+ | case " | ||
+ | " | ||
+ | *) preexec " | ||
+ | esac | ||
+ | } | ||
+ | trap on_debug | ||
fi | fi | ||
# as we show user and cwd in screen title, | # as we show user and cwd in screen title, | ||
Line 52: | Line 87: | ||
esac | esac | ||
- | This seems to break some Pipe chains. There might be a better approach at [[http:// | + | This seems to break some Pipe chains. There might be a better approach at [[http:// |
Actually, I consider this trick dirty and hence both solutions. | Actually, I consider this trick dirty and hence both solutions. | ||
+ | |||
+ | ===== Have a separate history for each screen window ===== | ||
+ | Put this in your '' | ||
+ | |||
+ | [ -n " | ||
===== sample .screenrc file ===== | ===== sample .screenrc file ===== | ||
- | | + | <code screen .screenrc> |
- | bind ^k | + | #remove some stupid / dangerous key bindings |
- | bind ^\ | + | bind ^k |
- | bind k | + | bind ^\ |
- | startup_message off | + | bind k |
- | vbell on | + | # # don't lock screen accidently - use if you don't know the accounts |
- | vbell_msg " Klingeling! " | + | # # password (e.g. when access is managed by ssh keys) |
- | bindkey -k kb stuff ^? | + | # bind x |
- | defscrollback 500 | + | # bind ^x |
- | + | startup_message off | |
- | caption always | + | vbell on |
- | caption string " | + | vbell_msg " Klingeling! " |
- | # caption string " | + | bindkey -k kb stuff ^? |
- | | + | # Enable cycling backward throug regions in Putty by C-a, |
- | hardstatus on | + | bindkey -t " |
- | hardstatus alwayslastline | + | # Make C-a C-a work smooth again |
- | msgminwait 0 | + | bindkey -t " |
+ | |||
+ | defscrollback 500 | ||
+ | |||
+ | # make $HOME the base for all relative paths | ||
+ | chdir | ||
+ | |||
+ | caption always | ||
+ | # # show window title and optional | ||
+ | # # hardware status line text | ||
+ | # caption string " | ||
+ | |||
+ | # # show window title if set, else hardware status line text | ||
+ | # windowlist string "%3n %? | ||
+ | # windowlist title "Num Name|HW Status" | ||
+ | # # show window title and hardware status line text if set | ||
+ | # windowlist string "%3n %t %? | ||
+ | # windowlist title "Num Name [HW Status]" | ||
+ | # # Use approximately original windowlist string appended by hardware statusline if set | ||
+ | windowlist string "%3n %t%=%? | ||
+ | windowlist title "Num Name%=[HW Status] Flags" | ||
+ | # # show clock in caption line | ||
+ | # caption | ||
+ | # Higlight active window, show hold and escape-key state | ||
+ | caption | ||
+ | |||
+ | hardstatus on | ||
+ | hardstatus alwayslastline | ||
+ | msgminwait 0 | ||
+ | |||
+ | logfile .screenlog/ | ||
+ | |||
+ | zombie xr onerror | ||
+ | # If you're using bash (won't hurt otherwise) | ||
+ | setenv PROMPT_COMMAND ' | ||
+ | </ | ||
+ | ===== Logging and reading logs ===== | ||
+ | <code screenrc .screenrc> | ||
+ | : | ||
+ | chdir | ||
+ | logfile screenlog/ | ||
+ | : | ||
+ | </ | ||
+ | |||
+ | col < ~/ | ||
+ | |||
+ | __References__: | ||
+ | * [[https:// | ||
+ | ===== Starting root shell in new screen with non-default shell ===== | ||
+ | screen -t root sudo ZDOTDIR=$HOME -i /bin/zsh - | ||
+ | screen -t root sudo su - -c " |
docs/tips_n_tricks/screen.html.1278518649.txt.gz · Last modified: 07.07.2010 18:04 CEST by peter