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

Add global command-line shortcuts Desktop
A friend of mine just sent this to me:

"I don't know if you've seen references to creating your own .cshrc file anywhere. I've been playing with it a bit. The way to do it is to edit the /etc/csh.cshrc file. If you do this one, the aliases you add are usable by all users - including root and sudo-ed uses. I added this:
alias bbopen "open -a '/Applications/Text/BBEdit 6.1/BBEdit 6.1 for OS X'"
which makes the command "bbopen FILENAME" (without quotes, FILENAME is the name of the file) open any file you want. Note that my path to BBEdit may not be yours."

...and I was just getting to tolerate pico, too, but I LOVE by BBEdit.
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)

Add global command-line shortcuts | 16 comments | Create New Account
Click here to return to the 'Add global command-line shortcuts' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
sudo vs. su root
Authored by: sssss on Oct 15, '01 11:59:18AM

I'm anonymous' friend.

And I actually can't get this to work with sudo. su root works fine, but if anyone can figure out how or where to made sudo work I'd love to hear it.

[ Reply to This | # ]
sudo vs. su root
Authored by: RLeatherwood on Oct 15, '01 02:03:35PM

I had this problem too. sudo would not work. I discovered that your user-id must have a password and it must be admin or it won't work.

[ Reply to This | # ]
sudo vs. su root
Authored by: sssss on Oct 15, '01 03:39:25PM

Well, I can get sudo to work fine by itself.
It is just the aliases that won't work With sudo that I'm having trouble with.

[ Reply to This | # ]
sudo vs. su root
Authored by: sjonke on Oct 15, '01 04:45:37PM

sudo doesn't let you use the cd command either, which is a nuissance. It seems that cd is not included in the "ALL" allowed commands? Weird. Is there a way to fix this and to add bbedit/bbeopen as a valid command, or is this an intentional security feature that can be changed?

[ Reply to This | # ]
Authored by: sjonke on Oct 15, '01 04:11:45PM

Why not make an alias called bbedit instead of bbopen?

[ Reply to This | # ]
Authored by: sssss on Oct 15, '01 05:42:35PM

No reason. Call it whatever you like.
"bbopen" was good for me because I wanted it to be different than the name of the program. More equivalent to 'open with BBEdit' than anything else. But you can really call it anything you want as long as it's unique. I think if you name it the same as another command, or a folder, you would have issues when you wanted to access that command or folder.

[ Reply to This | # ]
just 'open' works
Authored by: ashill on Oct 15, '01 06:59:26PM

I find that a simple open command does the same thing, without the BBEdit alias. (I have set all text or unknown files to open in BBEdit by default (from the Finder), which is probably the reason.)

[ Reply to This | # ]
I use this...
Authored by: rwh on Oct 15, '01 09:03:11PM
This was on ResExcellence the other day, a little easier, and works with everything that ends in ".app".

[ Reply to This | # ]
please see this...
Authored by: jimr on Oct 16, '01 01:48:49AM
if you look in the directory

you will see


if you read the contents of

there is a line similar to this...
source /usr/share/init/tcsh/rc

starting to look familiar?

then if you actually bother to read the README

you can find that each users account may be customized by

cd ~
cd Library/
mkdir init
cd init/
mkdir tcsh
cd tcsh
(you could just use the -p with mkdir -p init/tcsh)
pico environment.mine
Add additional environment variables
like custom colors for color ls

pico aliases.mine
make your aliases here...
pico login.mine
adjust your login environment
pico path
set up any custom paths which you might need

if you are the only user... sure edit the global files.

using this method... you will find you can keep users
environments and characteristics separate.
or alternatively as an administrator give
all of your users a common starting point.

[ Reply to This | # ]
re: please see this...
Authored by: sssss on Oct 16, '01 07:17:36PM

ooh! a README! cool, we need more of those.
thanks for pointing that out.
setting a user's aliases, etc, doesn't work for sudo though, huh?
do you know how to do that?

[ Reply to This | # ]
re: please see this...
Authored by: jimr on Oct 17, '01 06:41:59AM

aliases are part of the shell

so if you

[devlin:~] jim% sudo ll
sudo: ll: command not found

where ll is one of the default aliases

on the other hand,

if you perform some trivial operation like ls
then ask for an alias

it seems to work

sudo ls; ll

in this case, the ll is performed as superuser

also check
sudo ls; alias
sudo ls; env

to prove this to myelf, I made a file as root

-rw-r--r-- 1 root wheel 5 Oct 17 19:22 remove_file

sudo ls; rm remove_file


I have a shell alias which sets edit to "pico"

so if I
sudo edit <filename>

sudo: edit: command not found


sudo ls; edit test_file

the file is still made/owned by me
-rw-r--r-- 1 jim wheel 16 Oct 17 19:31 test_file

but for rm it works

so ....

seems better just to su

and get your self logged as root.

copy your aliases over to the root folder

check this out

sudo -s

then type "env"

Trying to decide what that is...
probably related to the security thing

best to type sudo -k if you go away from your keyboard.

[ Reply to This | # ]
Why sudo alias's don't work
Authored by: serversurfer on Oct 17, '01 08:34:11AM
Tcsh only checks the first word of each command to see if it's an alias. The command:

sudo ls; alias file

applies the alias to the file because the first word of the second command is an alias. But it's still performed via sudo because sudo applies to everything on the line.

[ Reply to This | # ]
use a shell script...
Authored by: smark on Oct 17, '01 10:31:53AM
To use bbopen (actually I prefer simply bb) with sudo, just add the following script (with whatever name you choose) to /usr/local/bin (or similar) :
if [ -z "$1" ]; then	
	echo usage: bbopen file1 file2 ...	
open -a "/Applications/BBEdit [Lite] 6.1/BBEdit [Lite] 6.1 for OS X" $*
Then a simple
chmod u+x bbopen 
and you're set (although BBEdit obviously can't be running yet to launch as root, which can be a pain)
Note: if you leave out the if ... fi, you can use the command
sudo bbopen
to just launch BBEdit as root

[ Reply to This | # ]
good work smark
Authored by: jimr on Oct 17, '01 01:02:50PM
here is some modification to your script
so you can have a help flag
and choose to just open or choose to open an existing file

now if we can use that other hint about osascript to open a new file....

I also suspect that closing, then opening the terminal from the Apple menu will log you in as root while you have bbedit opened by sudo.

yes it does.....

however the amusing thing is that terminal was not in the list of recent apps
as it is open alot without closing and had been moved out of my recent 10....
so I had to open it once more...from the dock to get it to appear.

anyway be careful with any GUI app opening as root user....until apple makes some security fix...
----cut here----


if test -n $1 && test $1 = "-h"; then
echo usage: bbopen file1 file2 ...
echo bbopen -h show help

if test -z $1; then
open "/Applications/Text/BBEdit 6.1 for OS X"
echo Opening BBEdit

open -a "/Applications/Text/BBEdit 6.1 for OS X" $*
echo Opening $* with BBEdit

[ Reply to This | # ]
Authored by: jimr on Oct 17, '01 02:17:37PM

thought I got rid of that parameter error

back to the drawing board works but not perfect

[ Reply to This | # ]
Just use 'bbedit'
Authored by: useEvil on Jun 12, '02 02:18:25PM

Why not just use the 'bbedit' command provided by the BBEdit application? Or does the Lite version not come with it?

[ Reply to This | # ]