help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Current working directory echoed to the terminal


From: Chris Jones
Subject: Re: [Help-bash] Current working directory echoed to the terminal
Date: Mon, 09 Apr 2012 23:35:29 -0400
User-agent: Mutt/1.5.20 (2009-06-14)

On Mon, Apr 09, 2012 at 07:07:09PM EDT, Bob Proulx wrote:
> Chris Jones wrote:

Hello Bob,

> Why is the BASH_ENV variable set?  The easiest and best solution would
> seem to be to find where that is getting set and remove it so that it
> isn't ever set.

Oh, I can answer that, since I set it myself..  ;-)

The reason being that I want my personal collection of aliases and
functions to be available from the vi/Vim command line.

As an example.. when in Vim, I type:

| :! l | b 

.. instead of:

| !ls -alh -F --full-time --color=always | less -M -R -c -i -J -~ -N'

.. should I want to take a quick peek at a detailed listing of the
contents of my current working directory.

That's a lot less keystrokes and a lot less to remember, naturally.. but
even _more importantly_ it is consistent with my bash working habits: in
other words I don't have to _think_ I am in Vim or in bash and choose
a different model according to the context - it's part of my muscle
memory.. no overhead whatsoever.

Initially, I was unable to do this despite the fact that my aliases and
functions are sourced in my ~/.bashrc. It's been a while since I looked
at this but as far as I can remember the reason is that the ‘:!’ Vim
escape causes a non-interactive shell to be invoked, which bypasses
sourcing the bashrc file. So that I had to issue a ‘:sh’ in Vim to start
an interactive shell where I could use my aliases & functions and then
hit CTRL_D to return to my Vim session.. bit of a hassle..

There may be other (better?) ways to achieve the same result but apart
from this ‘cd - > /dev/null’ annoyance, I am quite happy with my setup.

As I wrote in my initial post, I'm curious as to why I did not run into
this on debian ‘lenny’. I still have this system available but I haven't
had a chance to boot into it to take a closer look.

> The ksh needed ENV set in order to source a ksh envirionment script.
> And so bash has that too as a compatibility option.  And also has
> BASH_ENV which for a bash specific override.  But in all of the years
> I have been using shells I haven't ever needed to set BASH_ENV.
> Instead I let the automatic bashrc file processing do everything.

That's actually a Vim faq of sorts - pops up now and again on vim_user.

> I think sometimes that people converting over from the old ksh to bash
> sometimes get suckered into thinking they need more configuration than
> they do and the go looking for how to set the same options they used
> to set with ksh.  But in this case it just isn't needed.  If you think
> it is then please write back and say why.  I am sure we can come up
> with a better way of doing things.

Well, I concocted my own solution w/o anyone's advice quite unaware of
what problems it might cause, so I would definitely be interested. In my
case, it was just a matter of ‘it just works’ kind of approach.

> > Unsure about the implications but for now I changed the two ‘cd -’
> > commands to ‘cd - > /dev/null’ and the directory name is no longer
> > echoed to the terminal.
> 
> The implications are that you are doing something as a workaround to
> stop doing something else that you set it up to do.  I think it is
> better to stop doing the thing you don't want it to do in the first
> place and then there isn't a need for a workaround.  Do you really
> need CDPATH set?

CDPATH is not something I would want to use and is not set in my
environment. Only BASH_ENV is. 

Thanks,

CJ
-- 
Hi! My name is bobby...



reply via email to

[Prev in Thread] Current Thread [Next in Thread]