Par MadCoder, Friday 19 August 2005 à 21:03 ::
Geeky
Well, my DSL provider killed my connection for 10 days, and then I had some vacation ...
Long time no see.
Though, I've played with my dotfiles recently, and I set up some really nice things, picked from the web.
Screen and zsh cooperation
The one I find the best is the tight collaboration between screen and zsh to have nice labelled windows in the screen status line.
You have to do this like that :
# in your .zshrc, add the following code to you preexec :
preexec () {
if [[ "$TERM" == "screen" ]]; then
local CMD=${1[(wr)^(*=*|sudo|-*)]}
echo -ne "\ek$CMD\e\\"
fi
}
# and this code in order to reset the title when zsh gets the hand back
if [[ "$TERM" == "screen" ]]; then
PROMPT="${PROMPT}%{^[kzsh^[\\%}"
fi
Then, you can have in your .screenrc some dark margic like :
bind s select zsh
which make Ctrl-A s find your first available shell (really nice).
Make Shift+PgUp/PgDown work in screen
well, this is complete dark magic, but it works :
# tell screen that you term can scroll
termcapinfo xterm ti@:te@
# bind Shift+PgUp/PgDn
bindkey -m "^[[5;2~" stuff ^b
bindkey -m "^[[6;2~" stuff ^f
And another great setting is altscreen :
# Support alternate screens so that, for example, when you
# quit out of vi, the display is redrawn as it was before vi
# redrew the full screen.
altscreen on
Though, now, Shift-Tab doesn't work anymore in screen, and since in vimrc I have things like :
" {{{ Tab Key magic ...
vmap <tab> >gv
vmap <bs> <gv
function! CleverTab()
if strpart( getline('.'), col('.')-2, 1 ) =~ '^\s*$'
return "\<Tab>"
else
return "\<C-P>"
endif
endfunction
inoremap <Tab> <C-R>=CleverTab()<CR>
inoremap <S-Tab> <Tab>
" }}}
it's quite important that Shift+Tab works ...
zsh does not eat non "\n" terminated lines
I don't like the option
setopt no_prompt_cr
that tells zsh no to print a "\r" before each prompt : I have a rprompt, and if a command (e.g. echo -n "f*****g command") is performed just before a shell prompt display, then my rprompt is wrapped, it's ugly.
but printing a "\r" each time eats the line if no "\n" was present, which happens sometime, and makes you think the command you launched failed.
I found that jewel on the zsh-users MailList :
precmd() {
local escape colno lineno
IFS='[;' read -s -d R escape\?$'\e[6n' lineno colno
(( colno > 1 )) && echo ''
}
Basically, it checks before writing the prompt if the current column position is 0, and if not, it prints an "\n". I guess it may exists some races if you have a background job, but for alldays use, it's perfect.