From: Christian Neukirchen <chneukirchen@gmail.com>
To: zsh-users@zsh.org
Subject: Re: Outputting colored zsh prompts from an external script
Date: Sun, 24 Mar 2013 22:48:05 +0100 [thread overview]
Message-ID: <871ub431wq.fsf@gmail.com> (raw)
In-Reply-To: <20130324192345.GA20437@kaeru> (seanh's message of "Sun, 24 Mar 2013 20:23:45 +0100")
seanh <snhmnd@gmail.com> 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@gmail.com> http://chneukirchen.org
next prev parent reply other threads:[~2013-03-24 21:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-24 19:23 seanh
2013-03-24 21:48 ` Christian Neukirchen [this message]
2013-03-25 13:05 ` seanh
2013-03-25 15:29 ` Bart Schaefer
2013-03-25 19:40 ` seanh
2013-03-28 20:26 ` seanh
2013-03-28 21:14 ` TJ Luoma
2013-03-29 15:07 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871ub431wq.fsf@gmail.com \
--to=chneukirchen@gmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).