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

Re: truncating string in .zprofile



On Wed, Mar 20, 2013 at 09:54:48PM +0100, Eric Smith wrote:
> I did this -
> preexec () { print -Pn
> "\033k\033\134\033k[${1[1,12]}..${1[-6,$]}]\033\134" }
> 
> How would I do arbitrary string searching and replacement in the `$1'?

Any way you want -- grep, sed, or plain zsh.

preexec() {
    print -Pn "\033k\033\134\033k[$(
        print -n 'uptime: '
        uptime | perl -pe ...
    )]\033\134"
}

Paul.

-- 
Paul Hoffman <nkuitse@xxxxxxxxxxx>



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