Fork me on GitHub

CDW - by tarolandia

Shortcut to your projects. Go directly to your project's root using this small function.

You just need to add this code to your bashrc file.
File: cdw.bashrc

# CDW custum function
export PATH_CDW=/var/www/
function cdw 
{
  if [ -z "$1" ]; then
    echo "Empty params: switching to CDW path..."
    cd $PATH_CDW
  else
    cd $PATH_CDW
    if [ -d $1 ]; then
      cd $1
    else
      echo "$PATH_CDW$1: project not found"
      cd -
    fi
  fi  
}  

IMPORTANT This script must be placed before these lines if you use the auto-completion:

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
   /etc/bash_completion
fi

Example

ls /var/www/
project1 project2 projec3 qwe qwe3 qwe4

#From anywhere

cdw [tab] [tab]
project1 project2 projec3 qwe qwe3 qwe4

cdw qwe[tab]
qwe qwe3 qwe4

[enter]

/var/www/qwe/

Authors

Lautaro Orazi (orazile@gmail.com)

Contact

Lautaro (orazile@gmail.com)

Download

You can download this project in either zip or tar formats.

You can also clone the project with Git by running:

$ git clone git://github.com/tarolandia/cdw