A common problem you'll run into when working inside of your terminal is the desire to rename the directory you're currently in. This is achieved in 3 steps: back out of the directory, mv
to a new name, then back inside of it. Rather than 3 separate commands, let's take this down to a single command in a Zsh function. This lesson walks you through the process of creating a Zsh function to rename your current directory by using ${PWD##*/} to find the name of the directory your in then walking through the steps.
create a new file rename-dir:
#path/to/current/dir # will only return 'dir' currentDir=echo ${PWD##*/} cd .. mv $currentDir $1 cd $1
Run:
autoload rename-dir
Cd into a folder need to be renamed:
run:
rename-dir good-name