port cddir

Ryan Schmidt ryandesign at macports.org
Wed Jun 20 03:48:12 PDT 2007


I find myself wanting to cd into a port's directory quite often. I  
used to do:

$ cd `port dir foo`

but got tired of typing the backticks, and also I was used to typing  
"port <action> foo", as in "port edit foo" which to me is a shortcut  
for "edit `port file foo`". Now I've added a script to my  
~/.bash_profile so that I can now do:

$ port cddir foo

which is more intuitive to me. I can also do:

$ port cddir

to go to the root of the dports tree. This is the script:


port() {
	case "$1" in
		cddir)
			if [ -z "$2" ]; then
				cd `port echo all | head -n 1 | xargs port dir`/../..
			else
				cd `port dir $2`
			fi
			;;
		*)
			/opt/local/bin/port "$@"
			;;
	esac
}


Do others find this useful? I think it might be worthwhile to build  
"port cddir" into the port command properly.




More information about the macports-users mailing list