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

Re: Execute a command after each directory change



 --- Jörg Ziefle <ziefle@xxxxxxxxxxxxxxxx> wrote: > Hello,
> 
> I would like to execute a command (i.e. ls) whenever the CWD changes.
> Of course it could be done by redefining ls, popd and pushd.  But there
> is probably a more elegant solution which accounts for a general
> directory change.

I have in my zshrc:

chpwd() {
  local result path
  [[ -t 1 ]] || return
  case $TERM in
  sun-cmd)
    print -Pn "\e]l%~\e\\"
    ;;
  *xterm*|rxvt*|(dt|k|E)term)
    path=$(print -Pn "%~");
    if [ $LE_CYGWIN ]; then
      cygpath-m $path
      path=$result
    fi
    print -Pn "\e]2;${path}@${HOST}\a"
    ;;
  esac
}

hth.

--
Le

______________________________________________________________________ 
Post your free ad now! http://personals.yahoo.ca



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