Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Outputting colored zsh prompts from an external script
- X-seq: zsh-users 17736
- From: Christian Neukirchen <chneukirchen@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Outputting colored zsh prompts from an external script
- Date: Sun, 24 Mar 2013 22:48:05 +0100
- In-reply-to: <20130324192345.GA20437@kaeru> (seanh's message of "Sun, 24 Mar 2013 20:23:45 +0100")
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20130324192345.GA20437@kaeru>
- Sender: chris@juno
seanh <snhmnd@xxxxxxxxx> writes:
> This all works fine, I've got my Python script ouptutting a nicely
> truncated current working directory
I ported this to zsh for fun:
fishpwd() {
local maxlen=${1:-20} pwd
local -a segs
segs=("${(s:/:)${(D)PWD}}")
for i in {1..$(($#segs-1))}; do
pwd=${(j:/:)segs}
(( $#pwd <= maxlen )) && break
segs[$i]=${segs[$i][1]}
done
print $pwd
}
fishpwd 30
fishpwd 20
fishpwd 10
fishpwd
--
Christian Neukirchen <chneukirchen@xxxxxxxxx> http://chneukirchen.org
Messages sorted by:
Reverse Date,
Date,
Thread,
Author