Re: change default editor to bbedit

1,452 views
Skip to first unread message

Rich Siegel

unread,
Jun 13, 2012, 7:05:51 PM6/13/12
to bbe...@googlegroups.com
On Wednesday, June 13, 2012, bobPCL <b...@purplecrowlidar.ca> wrote:

>"-bash: edit: command not found".

"edit" is not a bash command. You can invoke BBEdit using
"bbedit"; but the EDITOR variable is used by other programs to
invoke your preferred editor, and has no bearing on what you can
(or can't) do at the command line.

R.
--
Rich Siegel Bare Bones Software, Inc.
<sie...@barebones.com> <http://www.barebones.com/>

Someday I'll look back on all this and laugh... until they
sedate me.

bobPCL

unread,
Jun 13, 2012, 8:04:07 PM6/13/12
to bbe...@googlegroups.com
Thanks for the response, sorry I wasn't clear. What I'm trying to do is use a command line window (e.g. terminal) and type the word "edit" and get bbedit to open. I have another script I want to run that using the default environment editor, which is currently not bbedit.

So do you (or anyone) know how to make bbedit the "preferred" editor?

François Schiettecatte

unread,
Jun 13, 2012, 8:08:38 PM6/13/12
to bbe...@googlegroups.com
Bob

Works for me:

macpro: ~ > which bbedit
/usr/bin/bbedit

in .bash_profile :

#export EDITOR='vi'
export EDITOR='/usr/bin/bbedit'


macpro: ~ > source .bash_profile
macpro: ~ > echo $EDITOR
/usr/bin/bbedit
macpro: ~ > crontab -e (opens crontab in bbedit)
crontab: no changes made to crontab
macpro: ~ >


François
> --
> You received this message because you are subscribed to the
> "BBEdit Talk" discussion group on Google Groups.
> To post to this group, send email to bbe...@googlegroups.com
> To unsubscribe from this group, send email to
> bbedit+un...@googlegroups.com
> For more options, visit this group at
> <http://groups.google.com/group/bbedit?hl=en>
> If you have a feature request or would like to report a problem,
> please email "sup...@barebones.com" rather than posting to the group.
> Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

bobPCL

unread,
Jun 13, 2012, 8:25:20 PM6/13/12
to bbe...@googlegroups.com
thanks. That does work for crontab. Unfortunately it does work if you say "edit file.name", you can say bbedit but not edit.

I guess it only works in some contexts. On my old unix systems I used to have emacs come up instead of vi, I just can't remember how I used to do it.

François Schiettecatte

unread,
Jun 13, 2012, 8:30:25 PM6/13/12
to bbe...@googlegroups.com
Bob

again in .bash_profile

alias edit='/usr/local/bbedit'

macpro: ~ > source .bash_profile
macpro: ~ > alias edit
alias edit='/usr/bin/bbedit'
macpro: ~ > edit .bash_profile

Cheers

François
> > bbedit+un...@googlegroups.com
> > For more options, visit this group at
> > <http://groups.google.com/group/bbedit?hl=en>
> > If you have a feature request or would like to report a problem,
> > please email "sup...@barebones.com" rather than posting to the group.
> > Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
>
>
> --
> You received this message because you are subscribed to the
> "BBEdit Talk" discussion group on Google Groups.
> To post to this group, send email to bbe...@googlegroups.com
> To unsubscribe from this group, send email to
> bbedit+un...@googlegroups.com

François Schiettecatte

unread,
Jun 13, 2012, 8:33:00 PM6/13/12
to bbe...@googlegroups.com
Bob

I should point out there is a big difference between the EDITOR environment variable (explained by Rich below) and the 'alias' command.

You might want to check this resources:

http://www.gnu.org/software/bash/manual/

The O'Reilly Bash book is pretty good too!

Cheers

François
> > bbedit+un...@googlegroups.com
> > For more options, visit this group at
> > <http://groups.google.com/group/bbedit?hl=en>
> > If you have a feature request or would like to report a problem,
> > please email "sup...@barebones.com" rather than posting to the group.
> > Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
>
>
> --
> You received this message because you are subscribed to the
> "BBEdit Talk" discussion group on Google Groups.
> To post to this group, send email to bbe...@googlegroups.com
> To unsubscribe from this group, send email to
> bbedit+un...@googlegroups.com

Robert Sica

unread,
Jun 13, 2012, 8:38:14 PM6/13/12
to bbe...@googlegroups.com
aahhh, now I get what Rich was telling me. Thanks so much to both of you, I see the difference now.

Phil Dobbin

unread,
Jun 13, 2012, 11:34:18 PM6/13/12
to bbe...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 13/06/2012 23:25, bobPCL wrote:

> I can open a terminal window in Mac Lion and run the command:
>
>>bbedit file.name
>
> and bbedit works, and says it is in /usr/bin/bbedit.
>
> If I try to put in my .profile: export EDITOR='/usr/bin/bbedit' I get
> "-bash: edit: command not found". Or the same thing happens if I put the
> command in .bashrc. Or if I leave off the /usr/bin and put it in either
> place. Always the same error.
>
> That being said if I put /usr/bin/edit that works (but not for bbedit).
>
> Would someone please let me know what I'm doing wrong? I'm running from
> an account with admin access.

Try:

`export EDITOR=/usr/bin/bbedit` (without the backticks)

in your bash_profile (assuming when you installed the command line tools
you chose `/usr/bin/`).

Similarly, you can use:

`export GIT_EDITOR=/usr/bin/bbedit`

for your git commit messages if you don't want to pass the `m` flag on
your commits.

That will work if you run your shell as a login shell (see
<https://rvm.io/support/faq/#shell_login> from the wonderful Wayne E.
Seguin for a brief explanation).

Also, unfortunately, there is no `sudo update-alternatives --config
editor` on OS X as there is GNU/Linux to make this scenario plainer.
Blame FreeBSD :-)

Cheers,

Phil...

- --
But masters, remember that I am an ass.
Though it be not written down,
yet forget not that I am an ass.

Wm. Shakespeare - Much Ado About Nothing

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: §auto-key-locate cert pka ldap hkp://keys.gnupg.net
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJP2Vu3AAoJEKpMeDHWT5ADsE8IAKtqYGtydTQouQBToMV+tfea
jquUKm5RfcyLwyh3zCVaqyurDl4bWFNJ75YYo+5BW5TrqIDnN6gPMMH1aEqEo5zA
2AhGl6zu+OMIdhxVNBie7Pd6quGjXs204sj9yJAVDSPZJK22fqduUmgvedIS1QHb
cgsj1lA+bMAXDzG7BdXXNG2o8leNvYe6kB4VzzMZc7dCV2MRAWyX0gleJek453Fx
ox79gwmXmqJZhxprN6CdU6ShgUpAGBy7V1hXwtQF2mA3yjo3GzNRG5UhqaGFytZT
AJBO6Grh4HryCRFKTB+IoFqI6/2kLvS9EtW8deEs764wPCx+9f4JvNx8qYSFg/I=
=Fl2o
-----END PGP SIGNATURE-----

Alex Satrapa

unread,
Jun 14, 2012, 12:39:24 AM6/14/12
to bbe...@googlegroups.com
Just a note about using BBEdit for editing commit messages: I use '/usr/local/bin/bbedit --wait --resume' for that purpose, mainly to allow the commit message to be written before returning control to the invoking process. The "--wait" means "wait for document to be closed in BBEdit" and "--resume" means "restore focus to the invoking application when the document is closed in BBEdit".

HTH

Rod Buchanan

unread,
Jun 14, 2012, 9:28:45 AM6/14/12
to bbe...@googlegroups.com
On Jun 13, 2012, at 7:25 PM, bobPCL wrote:

> thanks. That does work for crontab. Unfortunately it does work if you say "edit file.name", you can say bbedit but not edit.

Add this to ~/.bashrc

alias edit='/usr/bin/bbedit'

--
Rod

Ryan Wilcox

unread,
Jun 14, 2012, 10:46:02 AM6/14/12
to bbe...@googlegroups.com


On Thursday, June 14, 2012 12:39:24 AM UTC-4, Grail wrote:
Just a note about using BBEdit for editing commit messages: I use '/usr/local/bin/bbedit --wait --resume' for that purpose, mainly to allow the commit message to be written before returning control to the invoking process.

Grail raises an excellent point: by default the bbedit command will turn immediately. This causes some confusion with some command line tools, which expect the editor command to quit only after the user has saved and quit their writing.

In English, most command line tools expect to fire off the editor, and expect to hear back from the user when they are done editing. Instead, what the bbedit command does (by default) is to open the file in BBEdit then return immediately. 

So, the bbedit tool is written to behave like: "Ok, I have displayed the file to the user, my job is done". Where as most command line tools expect the editor's job to be done when the user saves + closes the document in question.

Here's the line from my own unix config:

export EDITOR=~/bin/bb


My ~/bin/bb script looks like this:

#!/bin/sh

# Information for this script comes from:

if [[ $SSH_CONNECTION ]]
then
  vim "$@"
else
  bbedit -w  "$@"
fi


This script says, "If the user is SSHing in right now, use vim as the editor. Else use BBEdit and wait around until the user closes the document in question".

Why the check about SSH connections? I sometimes SSH into my main OS X machine using a Linux netbook. If I need to edit a file I don't want to launch BBEdit because I have no way of editing the text then because I'm not in front of OS X right now.

Hope this helps,
_Ryan Wilcox

Rick Gordon

unread,
Jun 14, 2012, 1:58:37 PM6/14/12
to bbe...@googlegroups.com
But how will that work for other classes of documents, such as images, which have their own default editor?

------------------

On 6/14/12 at 8:28 AM -0500, Rod Buchanan wrote in a message entitled
"Re: change default editor to bbedit":
--
___________________________________________________

RICK GORDON
EMERALD VALLEY GRAPHICS AND CONSULTING
___________________________________________________

WWW: http://www.shelterpub.com

François Schiettecatte

unread,
Jun 14, 2012, 2:10:34 PM6/14/12
to bbe...@googlegroups.com
It is not relevant, all the alias does is replace the command 'edit' with the command '/usr/bin/bbedit', the default MacOS X install does not have an 'edit' command.

Note that you can add parameters to the alias:

alias edit='/usr/bin/bbedit --wait --resume'

There is the '/usr/bin/open' command which will open a document with its Mac application, so I would use that for you images, etc...

François
> --
> You received this message because you are subscribed to the
> "BBEdit Talk" discussion group on Google Groups.
> To post to this group, send email to bbe...@googlegroups.com
> To unsubscribe from this group, send email to
> bbedit+un...@googlegroups.com

Rick Gordon

unread,
Jun 14, 2012, 2:28:34 PM6/14/12
to bbe...@googlegroups.com
Ah, right. I was confusing edit and open.

------------------

On 6/14/12 at 2:10 PM -0400, François Schiettecatte wrote in a message entitled
Reply all
Reply to author
Forward
0 new messages