Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

bash question

69 views
Skip to first unread message

notbob

unread,
Aug 10, 2012, 8:07:26 AM8/10/12
to
Learned a new bash trick. While writing a command on the CL, I can
enter a key shortcut:

Ctrl-x e

....which will put me in my default editor, which is allegedly
determined by my environmental variable, $EDITOR, where I can edit
said command at length. After editing said command line and exiting
my editor, the command will execute. OK, fine. It works as
advertised.

My question is, how does my bash shell know to go to emacs --which it
does, and jes happens to be my preferred editor-- if I have no $EDITOR
env var? I looked. I invoked echo $EDITOR and got a blank line. ???

Is there some other variable, determined by the distro, that defaults
to a specific editor? I'm running Slackware 13.37.

nb

--
"Do you recognize me? No!
...cuz I don't work here"
Support labelling GMO foods
http://www.nongmoproject.org/

notbob

unread,
Aug 10, 2012, 8:12:42 AM8/10/12
to
On 2012-08-10, notbob <not...@nothome.com> wrote:

> Is there some other variable, determined by the distro, that defaults
> to a specific editor? I'm running Slackware 13.37.


DOH!! Nevermind. I figured it out. From man bash:


"Bash attempts to invoke $VISUAL, $EDITOR, and emacs as the editor, in
that order."

Sorry to bother. Only 1st cuppa joe. ;)

J G Miller

unread,
Aug 10, 2012, 9:38:08 AM8/10/12
to
On Friday, August 10th, 2012, at 12:12:42h +0000, NotBoB explained:

> "Bash attempts to invoke $VISUAL, $EDITOR, and emacs as the editor, in
> that order."

It is a wonder that the vi afficianados have not gone to war
over that! ;)

It is always a good idea to set BROWSER, EDITOR, VISUAL, and PAGER
according to your preferences in your .profile or .tcshrc

Keith Keller

unread,
Aug 10, 2012, 10:32:18 AM8/10/12
to
On 2012-08-10, J G Miller <mil...@yoyo.ORG> wrote:
> On Friday, August 10th, 2012, at 12:12:42h +0000, NotBoB explained:
>
>> "Bash attempts to invoke $VISUAL, $EDITOR, and emacs as the editor, in
>> that order."
>
> It is a wonder that the vi afficianados have not gone to war
> over that! ;)

Nah--vi users, apparently unlike emacs users, know how to set the
EDITOR environment variable. ;-)

--keith

--
kkeller...@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information

Chris Davies

unread,
Aug 10, 2012, 10:20:43 AM8/10/12
to
notbob <not...@nothome.com> wrote:
> My question is, how does my bash shell know to go to emacs

The default is emacs. For the rest of us there's the "set -o vi" option
that can be put in the .bashrc.

Chris

Stan Bischof

unread,
Aug 10, 2012, 11:03:52 AM8/10/12
to
Keith Keller <kkeller...@wombat.san-francisco.ca.us> wrote:
>> It is a wonder that the vi afficianados have not gone to war
>> over that! ;)
>
> Nah--vi users, apparently unlike emacs users, know how to set the
> EDITOR environment variable. ;-)
>

Wow- there hasn't been a good editor war or even a decent flamefest
in many many years!

Are you perhaps trying to start one?

Stan

notbob

unread,
Aug 10, 2012, 11:07:39 AM8/10/12
to
On 2012-08-10, Chris Davies <chris-...@roaima.co.uk> wrote:

> The default is emacs. For the rest of us there's the "set -o vi" option
> that can be put in the .bashrc.

As if I'd voluntarily impose such an affliction upon myself!

notbob

unread,
Aug 10, 2012, 11:09:19 AM8/10/12
to
On 2012-08-10, Stan Bischof <st...@worldbadminton.com> wrote:
>
> Are you perhaps trying to start one?

Never one to be shy, allow me to cast the first stone:

"vi ....the heart of evil!" --notbob

J G Miller

unread,
Aug 10, 2012, 11:42:48 AM8/10/12
to
On Friday, August 10th, 2012, at 07:32:18h -0700, Keith Keller observed:

> Nah--vi users, apparently unlike emacs users, know how to set the
> EDITOR environment variable. ;-)

Personally I prefer emacs to vi, but actually tend to use vi a lot
more because I do a lot of one off editing of small configuration files.

However, since vi is usually installed by default and emacs as
an extra, I would have thought that the bash default should have
been vi.

At least it is not set to ed ;)

And there is a version of "The One True Editor" for Linux at

<http://almy.us/teco.html>

make love, not war ;)

Keith Keller

unread,
Aug 10, 2012, 11:44:17 AM8/10/12
to
On 2012-08-10, Stan Bischof <st...@worldbadminton.com> wrote:
Not intentionally! Just making a joke, which, at least to me, I thought
was obvious, since presumably anyone experienced enough to prefer emacs
over an editor like pico is experienced enough to be able to set
environment variables.

But perhaps I'm wrong. ;-)

Dan Espen

unread,
Aug 10, 2012, 12:47:31 PM8/10/12
to
Keith Keller <kkeller...@wombat.san-francisco.ca.us> writes:

> On 2012-08-10, J G Miller <mil...@yoyo.ORG> wrote:
>> On Friday, August 10th, 2012, at 12:12:42h +0000, NotBoB explained:
>>
>>> "Bash attempts to invoke $VISUAL, $EDITOR, and emacs as the editor, in
>>> that order."
>>
>> It is a wonder that the vi afficianados have not gone to war
>> over that! ;)
>
> Nah--vi users, apparently unlike emacs users, know how to set the
> EDITOR environment variable. ;-)

An Emacs user that wanted to use this feature would be setting
$EDITOR to emacsclient.

--
Dan Espen

J G Miller

unread,
Aug 10, 2012, 12:56:46 PM8/10/12
to
On Friday, August 10th, 2012, at 12:47:31h -0400, Dan Espen suggested:

> An Emacs user that wanted to use this feature would be setting
> $EDITOR to emacsclient.

An emacs user would be using bash inside Emacs anyways ;)

M-x shell

Dan Espen

unread,
Aug 10, 2012, 1:28:46 PM8/10/12
to
This Emacs user has little use for any command line tool.

M-x compile
M-x grep

etc...

I went though a short M-x shell period and found little use for it.
Years ago.

--
Dan Espen

The Natural Philosopher

unread,
Aug 10, 2012, 1:42:58 PM8/10/12
to
notbob wrote:
> On 2012-08-10, Stan Bischof <st...@worldbadminton.com> wrote:
>> Are you perhaps trying to start one?
>
> Never one to be shy, allow me to cast the first stone:
>
> "vi ....the heart of evil!" --notbob
>
..but available on every *nix system I have ever had to edit a file on..

>
> nb
>


--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.

Norbert Möndjen

unread,
Aug 10, 2012, 1:40:46 PM8/10/12
to
Emacs and vi can maybe called text-prozessors but both lack the editor-
ability. An Editor is small, easy and intuitiv to use.

Ciao Nobbe

Chris F.A. Johnson

unread,
Aug 10, 2012, 4:21:15 PM8/10/12
to
The shell in emacs does not have the capabiliies of a good terminal
window. I have only one application that I use in emacs shell:
<http://www.facebook.com/media/set/?set=a.494508738852.269597.533633852&type=3&l=c4cc76273c>

I use emacs as my editor, and I do a lot of editing (scripts, web
pages, PostScript, Usenet, email, etc.). I always have emacs open,
and use emacsclient in alpine, slrn and firefox.

--
Chris F.A. Johnson, <http://cfajohnson.com>
Author:
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)

Chris Davies

unread,
Aug 10, 2012, 5:55:44 PM8/10/12
to
> On 2012-08-10, Chris Davies <chris-...@roaima.co.uk> wrote:
>> The default is emacs. For the rest of us there's the "set -o vi" option
>> that can be put in the .bashrc.

notbob <not...@nothome.com> wrote:
> As if I'd voluntarily impose such an affliction upon myself!

Clearly the simpler option is the default, leaving us experts to make
the change to suit.

Chris
:-P

Robert Riches

unread,
Aug 11, 2012, 12:10:00 AM8/11/12
to
On 2012-08-10, The Natural Philosopher <t...@invalid.invalid> wrote:
> notbob wrote:
>> On 2012-08-10, Stan Bischof <st...@worldbadminton.com> wrote:
>>> Are you perhaps trying to start one?
>>
>> Never one to be shy, allow me to cast the first stone:
>>
>> "vi ....the heart of evil!" --notbob
>>
> ..but available on every *nix system I have ever had to edit a file on..
>
>>
>> nb

And some versions of vi actually let you delete a character that
was in the file before you brought up the editor. It's a pain to
be stuck one of the versions of vi that doesn't allow it.

Emacs, a _REAL_ editor.

--
Robert Riches
spamt...@jacob21819.net
(Yes, that is one of my email addresses.)

notbob

unread,
Aug 11, 2012, 9:01:47 AM8/11/12
to
On 2012-08-11, Robert Riches <spamt...@jacob21819.net> wrote:

> And some versions of vi actually let you delete a character that
> was in the file before you brought up the editor. It's a pain to
> be stuck one of the versions of vi that doesn't allow it.

You mean it's a one mode vi? Never heard of such a thing.

That's my entire case against vi(x). Ya gotta change modes to edit.
What genius came up with that stroke of insanity? Jay-sus, a half
century old Underwood doesn't even require that. Sure, I can use vi
if necessary, but why would I want to.

> Emacs, a _REAL_ editor.

I'll be the first to admit, it can be a _REAL_ pain! But, at least ya
don't hafta change modes to edit. Plus, it's a great file mgr. That,
IMO, is what makes emacs so great. I always start emacs in dired /.
You can do anything from there.

nb


--
"Do you recognize me?
No! ...cuz I don't fsckin' work here"

Aragorn

unread,
Aug 11, 2012, 12:08:53 PM8/11/12
to
On Saturday 11 August 2012 15:01, notbob conveyed the following to
comp.os.linux.misc...

> On 2012-08-11, Robert Riches <spamt...@jacob21819.net> wrote:
>
>> And some versions of vi actually let you delete a character that
>> was in the file before you brought up the editor. It's a pain to
>> be stuck one of the versions of vi that doesn't allow it.
>
> You mean it's a one mode vi? Never heard of such a thing.
>
> That's my entire case against vi(x). Ya gotta change modes to edit.
> What genius came up with that stroke of insanity? Jay-sus, a half
> century old Underwood doesn't even require that. Sure, I can use vi
> if necessary, but why would I want to.
>
>> Emacs, a _REAL_ editor.
>
> I'll be the first to admit, it can be a _REAL_ pain! But, at least ya
> don't hafta change modes to edit. Plus, it's a great file mgr. That,
> IMO, is what makes emacs so great. I always start emacs in dired /.
> You can do anything from there.

Ahh, it's been a long time since I last witnessed the editor wars... :p

Just for the record, I have used vi in the past on proprietary UNIX -
Sperry OS/3, to be precise - and I have both vim and emacs installed
here on my GNU/Linux system. Both are very powerful editors - and
perhaps too powerful for my own needs - but personally, I prefer emacs
as well. ;-)

--
= Aragorn =
(registered GNU/Linux user #223157)

Eli the Bearded

unread,
Aug 14, 2012, 6:47:04 PM8/14/12
to
In comp.os.linux.misc, J G Miller <mil...@yoyo.ORG> wrote:
> On Friday, August 10th, 2012, at 12:12:42h +0000, NotBoB explained:
> > "Bash attempts to invoke $VISUAL, $EDITOR, and emacs as the editor, in
> > that order."
> It is a wonder that the vi afficianados have not gone to war
> over that! ;)

Simple, don't use bash. In AT&T ksh the default editor for history is
(wait for it):

$ env -i ksh -e set |grep -iE 'edit|visual'
FCEDIT=/bin/ed
$

> It is always a good idea to set BROWSER, EDITOR, VISUAL, and PAGER
> according to your preferences in your .profile or .tcshrc

BROWSER? I've lived all these years and never set that and never
had a problem by not setting it.

Elijah
------
is comfortable editing files with ed
0 new messages