Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: My zshrc; any sugestions welcome



On Mar 25, 11:45am, Marijan Peh wrote:
} 
} Any sugestions welcome, thanks.

Oh, what the heck, I've got half an hour to waste.

----------
## [[ ${+*} -eq 0 ]] = if variable is set don't set it anymore
[[ ${+USER} -eq 0 ]] && export USER=$USERNAME

You can write this as

(( ${+USER} )) || export USER=$USERNAME

Or even as

export USER=${USER:-$USERNAME}

----------
        ## display user@host and name of current process in (xterm|rxvt) title
        preexec () {print -Pn "\033]0;%n@%m [$1] %~\007"}

It'd probably be better to use ${${(z)1}[1]} there, rather than $1, if
you want just the command name.  Or even ${${${(z)1}:#*[[:punct:]]*}[1]}
in case the first "word" is an open-paren or something.

----------
        function compstyle { }

You meant `function zstyle { }', I'll bet.  It hasn't been called compstyle
for a while now.

----------
alias x='startx & disown && exit'

You can write that as

alias x='startx &! exit'

so that `disown' can't accidentally disown the wrong job.

----------
[in pskill()]

        kill -9 `print -r $pid`

Any reason why that isn't just `kill -9 $pid'?

----------
## invoke this every time when u change .zshrc to
## recompile it.
src()
{
        ! [ -f ~/.zshrc.zwc ] && zcompile ~/.zshrc
        ! [ -f ~/.zcompdump.zwc ] && zcompile ~/.zcompdump
        autoload zrecompile
        [ -f ~/.zshrc ] && zrecompile ~/.zshrc
        [ -f ~/.zcompdump ] && zrecompile ~/.zcompdump
        [ -f ~/.zshrc.zwc.old ] && rm -f ~/.zshrc.zwc.old
        [ -f ~/.zcompdump.zwc.old ] && rm -f ~/.zcompdump.zwc.old
        source ~/.zshrc
}

You should be able to get rid of those first two zcompile lines; just
change the two zrecompile lines to be:

	[ -f ~/.zshrc ] && zrecompile -p ~/.zshrc
        [ -f ~/.zcompdump ] && zrecompile -p ~/.zcompdump

----------
## restore all .bak files
## call this with something like: restore_bak 'find . -name "*.bak"'
restore_bak ()
{
        foreach f ($argv);
        mv $f ${f%%.bak};
        end
}

No problem with that (portability back to 3.0, etc.), but in 4.0:

autoload -U zmv
zmv '(**/)(*).bak' '$1$2'

----------
[in readme()]

In 4.0 with extendedglob you can write that files assignment as

	files=(./(#i)*(read*me|lue*m(in|)ut)*(ND))

----------
That's all.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



Messages sorted by: Reverse Date, Date, Thread, Author