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


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}
    cd `dirname ${1}`

View Comments »


Add your comment

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

   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