Your system aliases

ckester said:
If whereis returns an empty string, the cdport alias takes you to your home directory -- which might be unexpected or not what you want.

So in bash I would use a shell function instead.

For csh, I'd have the alias invoke a script, like so:

Code:
alias src source $HOME/bin/cdsrc

A simple cdsrc script might look like this:

Code:
#!/bin/csh

set d = `whereis -sq $1`

if ( "X$d" == "X" ) then
	echo "No source directory found for $1"
else
	cd $d
endif

Weird, on mine it doesn't change directories, it just gives an error.. also, if i make a script, the script works, but it appears to be run in a subshell, which exits upon completion of the script, thus I am back where i was before, any ideas how to fix this?
 
ikbendeman said:
Weird, on mine it doesn't change directories, it just gives an error.. also, if i make a script, the script works, but it appears to be run in a subshell, which exits upon completion of the script, thus I am back where i was before, any ideas how to fix this?

To avoid the subshell, use "source" as shown in my csh example.

What's the text of the error you get with the alias?
 
Back
Top