Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Free scripts to improve UNIX/Finder interaction' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Free scripts to improve UNIX/Finder interaction
Authored by: andrewz on Sep 22, '03 11:31:10AM
I've installed posd and fdc in /usr/bin, and they both work fine by themselves.

However, cd "$(/usr/bin/posd)" doesn't seem to work in my shell (I'm using tcsh). I just get an error saying "Illegal variable name."

Is there a different syntax that I need to use with tcsh to cd to the directory returned by running the posd command?

[ Reply to This | # ]

Free scripts to improve UNIX/Finder interaction
Authored by: lee1 on Sep 22, '03 12:30:53PM
I've been using the bash shell for so long that I'm not sure about my csh syntax, but I think this should work: First, put the new commands someplace conventional in your path, like /usr/local/bin. I think in csh type shells (such as tcsh) you need to type rehash now. Now you can just type the commands with no path. The alias you can define this way: alias cdf "cd `posd`" where those are backticks around the posd. That should be one way to do it.

[ Reply to This | # ]
Free scripts to improve UNIX/Finder interaction
Authored by: sreeves on Sep 22, '03 02:54:18PM

Backticks alone will not work because they will be evaluated when the alias is defined, not in the current context of the shell. You can see this by looking at the output from alias cdf. It will say "cd somedirectory".

You need to use the eval command, like this:

alias cdf 'cd "`eval posd`"'



[ Reply to This | # ]
Free scripts to improve UNIX/Finder interaction
Authored by: lee1 on Sep 23, '03 09:04:54AM

Right- I should have used single quotes, which does work (I just tested it in csh):

alias cdf 'cd `posd`'



[ Reply to This | # ]
Free scripts to improve UNIX/Finder interaction
Authored by: gatorparrots on Sep 22, '03 12:35:55PM
In c-shells (csh, tcsh), you want to use backticks (`) instead of the $() form. In this case, you would use:
cd "`/usr/bin/posd`"

$(somecommand) is newer Bourne-style syntax supported by bash, ksh, zsh, etc. The advantage of using that syntax is that it is nestable.

[ Reply to This | # ]