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

Re: Outputting colored zsh prompts from an external script



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