Ok, I found the solution on my own. I was making the following mistake in my .tcshrc:
Code:
foreach i (`\ls -1 ~/myscripts`)
eval alias `basename "$i" .sh` "~/myscripts/$i"
end
That was causing each script to be executed as a command. The right (and rather arcane!) way to make it work is to use 'source':
Code:
foreach i (`\ls -1 ~/myscripts`)
eval alias `basename "$i" .sh` "source ~/myscripts/$i"
end
Now it works. And here is the complete solution in case someone ever wants to use the idea:
in .tcshrc:
Code:
foreach i (`\ls -1 ~/myscripts`)
eval alias `basename "$i" .sh` "source ~/myscripts/$i"
end
# or just make one specific alias:
# alias x "source ~/myscripts/x.sh"
alias xx 'cd - '
in ~/myscripts/x.sh:
Code:
#!/usr/bin/env tcsh
if ( $#argv < 1 ) then
popd
exit
endif
if ( -e "$1" ) then
pushd "$1"
else
echo "$1 not found."
endif
Note: I like the whole idea better with this line in .tcshrc:
And a little bit of complete magic:
Code:
complete {cd,popd,pushd,x} 'n/*/d/'