//View Tip #546
Similar Tips
» .. revisited
» Move a file and link to the new location
» Go up n directory levels

 

Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
This can be used instead of "mv" to move file(s) and then cd into the destination folder.

mvf() {
if  mv "$@"; then
  shift $(($#-1))
  if [ -d $1 ]; then
    cd ${1}
  else
    cd `dirname ${1}`
  fi
fi
}


View Comments »




Comments 

Add your comment

Comments are currently disabled
This can also be done in zsh with:

mvw()
{
   mv "$@" && cd "${@[-1]}";
}
Posted 2009-02-25 19:17:34
Eric D.
That's not the same: if you move a file and rename it at the same time the zsh version will fail. (eg. mvw file folder/newfile)
Posted 2009-03-25 19:31:42

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit