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

Re: truncating string in .zprofile



On Wed, Mar 20, 2013 at 07:28:27PM +0100, Eric Smith wrote:
> I have the following prexec() in my profile;
> preexec () { print -Pn "\033k\033\134\033k[$1]\033\134" }
> 
> This prints the command in the screen caption for that window.
> 
> What I want to do is limit this window title to n chars.
> 
> However, I cannot manipulate the `$1' in the print string.
> Even if I try.
> substring=$1
> preexec () { print -Pn "\033k\033\134\033k[$substring]\033\134" }
> 
> then there is no value printed for $substring.
> 
> What is the solution?

preexec() {
    print -Pn "\033k\033\134\033k["${1[1,30]}"]\033\134"
}

Paul.

-- 
Paul Hoffman <nkuitse@xxxxxxxxxxx>



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