RE: How to get cygwin command line to know where it is - seems okay now

2006-05-24 Thread Furash Gary
All the suggestions worked.

1. I put everything in .bash_profile (just easier)
2. I have the following statements in my _vimrc

set shell=C:/cygwin/bin/bash 
set shellxquote=\ 
set shellcmdflag=-c 
let $BASH_ENV='~/.bash_profile 

-Original Message-
From: A.J.Mechelynck [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 23, 2006 7:06 PM
To: Gerald Lai
Cc: Eric Arnold; Furash Gary; Gary Johnson; vim@vim.org
Subject: Re: How to get cygwin command line to know where it is

Gerald Lai wrote:
 On Wed, 24 May 2006, A.J.Mechelynck wrote:

 Eric Arnold wrote:
 Off hand, I can't remember the exact name, but I think that there is

 a special rc filename that is executed even when it isn't a login 
 shell.
 [...]

 Yes, I think so too, and I don't remember it offhand either, but man

 bash (which is quite long for a manpage) will tell you.

 Perhaps it's called .bashenv? Not sure. I use ZSH. It's equivalent 
 is .zshenv.
 --
 Gerald


As said under INVOCATION in the bash manpage:

Login shell: /etc/profile (if found), then the first one (if any) found
readable among ~/.bash_profile, ~/.bash_login, ~/.profile (all this
unless --noprofile). At exit: ~/.bash_logout (if found).

Non-login interactive shell: ~/.bashrc (if found) unless --norc

Non-interactive shell: does as if executing if [ -n BASH_ENV ]; then .
$BASH_ENV; fi but doesn't search the $PATH

There are more details about what bash does when invoked as sh, when
invoked in posix mode, when invoked by the remote shell daemon, or when
invoked in suid mode.

Under FILES, two additional files (for readline initialization) are
mentioned.


Best regards,
Tony.


How to get cygwin command line to know where it is

2006-05-23 Thread Furash Gary
I'm using VIM on windows with cygwin.  In my _vimrc I've got the
following

 automatically swithc directories 
set autochdir

 For cygwin shell
set shell=C:/cygwin/bin/bash 
set shellcmdflag=--login\ -c 
set shellxquote=\ 

When I try to use cygwin stuff with the ! command or similar things
from vim, it doesn't seem to know where it is.

That is, if I open up a file on the desktop with gvim, and do

:pwd

It prints out the path of the desktop (thanks to autochdir I think).
However, if I do

:! pwd

It prints out the location of my windows home directory.  Is there
anyway I could automatically pass to the shell the location it should
start in?


Re: How to get cygwin command line to know where it is

2006-05-23 Thread Eric Arnold

This is partly due to the use of   --login  , which causes it to act
as if it's a fresh login shell, so of course, it goes to your home
directory.  Try it with just   -c  .

Without setting that, zsh and bash seem to honor $PWD, probably, which
I suspect is exported by Vim..  I'm having trouble getting my rc file
to print it out when started from Vim.


On 5/23/06, Furash Gary [EMAIL PROTECTED] wrote:

I'm using VIM on windows with cygwin.  In my _vimrc I've got the
following

 automatically swithc directories
set autochdir

 For cygwin shell
set shell=C:/cygwin/bin/bash
set shellcmdflag=--login\ -c
set shellxquote=\

When I try to use cygwin stuff with the ! command or similar things
from vim, it doesn't seem to know where it is.

That is, if I open up a file on the desktop with gvim, and do

:pwd

It prints out the path of the desktop (thanks to autochdir I think).
However, if I do

:! pwd

It prints out the location of my windows home directory.  Is there
anyway I could automatically pass to the shell the location it should
start in?



Re: How to get cygwin command line to know where it is

2006-05-23 Thread A.J.Mechelynck

Furash Gary wrote:

I'm using VIM on windows with cygwin.  In my _vimrc I've got the
following

	 automatically swithc directories 
	set autochdir


 For cygwin shell
	set shell=C:/cygwin/bin/bash 
	set shellcmdflag=--login\ -c 
	set shellxquote=\ 


When I try to use cygwin stuff with the ! command or similar things
from vim, it doesn't seem to know where it is.

That is, if I open up a file on the desktop with gvim, and do

:pwd

It prints out the path of the desktop (thanks to autochdir I think).
However, if I do

:! pwd

It prints out the location of my windows home directory.  Is there
anyway I could automatically pass to the shell the location it should
start in?



  
:pwd and :! pwd don't return the same directory, that is normal. 
:pwd returns Vim's internal current directory, it changes whenever 
you use internal :cd, and 'autochdir' can change it implicitly; such 
changes are not brought back to the shell. To change the shell's current 
directory (as shown by :! pwd on Unix-like systems and by :! cd on 
dos-like systems) you can use the :! cd command, as follows:


au BufReadPost * exe !cd expand(%:p:h)

The above is untested but I believe it ought to work on Unix as well as 
on Windows.



Best regards,
Tony.


Re: How to get cygwin command line to know where it is

2006-05-23 Thread Gary Johnson
On 2006-05-24, A.J.Mechelynck [EMAIL PROTECTED] wrote:
 Furash Gary wrote:
  I'm using VIM on windows with cygwin.  In my _vimrc I've got the
  following
 
   automatically swithc directories 
  set autochdir
 
   For cygwin shell
  set shell=C:/cygwin/bin/bash 
  set shellcmdflag=--login\ -c 
  set shellxquote=\ 
 
  When I try to use cygwin stuff with the ! command or similar things
  from vim, it doesn't seem to know where it is.
 
  That is, if I open up a file on the desktop with gvim, and do
 
  :pwd
 
  It prints out the path of the desktop (thanks to autochdir I think).
  However, if I do
 
  :! pwd
 
  It prints out the location of my windows home directory.  Is there
  anyway I could automatically pass to the shell the location it should
  start in?
 
 
 

 :pwd and :! pwd don't return the same directory, that is normal. 

In my experience, such behavior is not normal.

 :pwd returns Vim's internal current directory, it changes whenever 
 you use internal :cd, and 'autochdir' can change it implicitly; such 
 changes are not brought back to the shell.

They are not brought back to the parent shell's environment, but
they do affect the environment of any shell that vim executes.

To change the shell's current 
 directory (as shown by :! pwd on Unix-like systems and by :! cd on 
 dos-like systems) you can use the :! cd command, as follows:

:!cd somedirectory will not do anything useful.  It will start a
shell, change the working directory of that shell, and the shell
will exit, returning control to vim.  It will not affect the
environment of vim or of any subsequent shell.

 au BufReadPost * exe !cd expand(%:p:h)
 
 The above is untested but I believe it ought to work on Unix as well as 
 on Windows.

Windows handles its process environments differently than Unix does.
If the Windows shell, cmd.exe, starts another program and that
program performs a cd, when that program exits, the working
directory of cmd.exe will have changed to the directory set by the
program.  In Unix, on the other hand, a process inherits its
environment from its parent and passes its environment on to its
children, but changes to the environment by a child are never
reflected in the parent's environment.

Regards,
Gary

-- 
Gary Johnson | Agilent Technologies
[EMAIL PROTECTED] | Wireless Division
 | Spokane, Washington, USA


RE: How to get cygwin command line to know where it is

2006-05-23 Thread Furash Gary
I copied it from a vim help note without really understanding it.  Makes
100% sense now, but... Is there still a way to get it to act like I've
logged in (e.g., run .bashrc etc.)?  

-Original Message-
From: Gary Johnson [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 23, 2006 3:14 PM
To: vim@vim.org
Subject: Re: How to get cygwin command line to know where it is

On 2006-05-23, Furash Gary [EMAIL PROTECTED] wrote:
 I'm using VIM on windows with cygwin.  In my _vimrc I've got the 
 following
 
automatically swithc directories 
   set autochdir
 
For cygwin shell
   set shell=C:/cygwin/bin/bash 
   set shellcmdflag=--login\ -c 
   set shellxquote=\ 
 
 When I try to use cygwin stuff with the ! command or similar things 
 from vim, it doesn't seem to know where it is.
 
 That is, if I open up a file on the desktop with gvim, and do
 
   :pwd
 
 It prints out the path of the desktop (thanks to autochdir I think).
 However, if I do
 
   :! pwd
 
 It prints out the location of my windows home directory.  Is there 
 anyway I could automatically pass to the shell the location it should 
 start in?

The problem is the --login option that you included in 'shellcmdflag'.
Every shell that you execute from vim is executed as a login shell,
which means it starts in your home directory.  If you just

set shellcmdflag=-c 

instead, it should work fine.

Why did you include --login?

Gary

-- 
Gary Johnson | Agilent Technologies
[EMAIL PROTECTED] | Wireless Division
 | Spokane, Washington, USA


RE: How to get cygwin command line to know where it is

2006-05-23 Thread Furash Gary
Just tried it and ran into the problem I thought I would.  Removing
login eliminates the problem of it not knowing where it is, but it no
longer runs .profile and so on, so as a result it's missing my changes
to the path, aliases, etc.

Hmm...

-Original Message-
From: Gary Johnson [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 23, 2006 3:14 PM
To: vim@vim.org
Subject: Re: How to get cygwin command line to know where it is

On 2006-05-23, Furash Gary [EMAIL PROTECTED] wrote:
 I'm using VIM on windows with cygwin.  In my _vimrc I've got the 
 following
 
automatically swithc directories 
   set autochdir
 
For cygwin shell
   set shell=C:/cygwin/bin/bash 
   set shellcmdflag=--login\ -c 
   set shellxquote=\ 
 
 When I try to use cygwin stuff with the ! command or similar things 
 from vim, it doesn't seem to know where it is.
 
 That is, if I open up a file on the desktop with gvim, and do
 
   :pwd
 
 It prints out the path of the desktop (thanks to autochdir I think).
 However, if I do
 
   :! pwd
 
 It prints out the location of my windows home directory.  Is there 
 anyway I could automatically pass to the shell the location it should 
 start in?

The problem is the --login option that you included in 'shellcmdflag'.
Every shell that you execute from vim is executed as a login shell,
which means it starts in your home directory.  If you just

set shellcmdflag=-c 

instead, it should work fine.

Why did you include --login?

Gary

-- 
Gary Johnson | Agilent Technologies
[EMAIL PROTECTED] | Wireless Division
 | Spokane, Washington, USA


Re: How to get cygwin command line to know where it is

2006-05-23 Thread Eric Arnold

Try this:

set shell=C:/cygwin/bin/bash
  let $BASH_ENV = '~/.bashrc'
  let shellcmdflag='-c'


On 5/23/06, Eric Arnold [EMAIL PROTECTED] wrote:

Off hand, I can't remember the exact name, but I think that there is a
special rc filename that is executed even when it isn't a login
shell.



On 5/23/06, Furash Gary [EMAIL PROTECTED] wrote:
 Just tried it and ran into the problem I thought I would.  Removing
 login eliminates the problem of it not knowing where it is, but it no
 longer runs .profile and so on, so as a result it's missing my changes
 to the path, aliases, etc.

 Hmm...

 -Original Message-
 From: Gary Johnson [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, May 23, 2006 3:14 PM
 To: vim@vim.org
 Subject: Re: How to get cygwin command line to know where it is

 On 2006-05-23, Furash Gary [EMAIL PROTECTED] wrote:
  I'm using VIM on windows with cygwin.  In my _vimrc I've got the
  following
 
 automatically swithc directories
set autochdir
 
 For cygwin shell
set shell=C:/cygwin/bin/bash
set shellcmdflag=--login\ -c
set shellxquote=\
 
  When I try to use cygwin stuff with the ! command or similar things
  from vim, it doesn't seem to know where it is.
 
  That is, if I open up a file on the desktop with gvim, and do
 
:pwd
 
  It prints out the path of the desktop (thanks to autochdir I think).
  However, if I do
 
:! pwd
 
  It prints out the location of my windows home directory.  Is there
  anyway I could automatically pass to the shell the location it should
  start in?

 The problem is the --login option that you included in 'shellcmdflag'.
 Every shell that you execute from vim is executed as a login shell,
 which means it starts in your home directory.  If you just

 set shellcmdflag=-c

 instead, it should work fine.

 Why did you include --login?

 Gary

 --
 Gary Johnson | Agilent Technologies
 [EMAIL PROTECTED] | Wireless Division
  | Spokane, Washington, USA




Re: How to get cygwin command line to know where it is

2006-05-23 Thread Gerald Lai

On Wed, 24 May 2006, A.J.Mechelynck wrote:


Eric Arnold wrote:

Off hand, I can't remember the exact name, but I think that there is a
special rc filename that is executed even when it isn't a login
shell.

[...]

Yes, I think so too, and I don't remember it offhand either, but man bash 
(which is quite long for a manpage) will tell you.


Perhaps it's called .bashenv? Not sure. I use ZSH. It's equivalent is 
.zshenv.
--
Gerald


Re: How to get cygwin command line to know where it is

2006-05-23 Thread A.J.Mechelynck

Gerald Lai wrote:

On Wed, 24 May 2006, A.J.Mechelynck wrote:


Eric Arnold wrote:

Off hand, I can't remember the exact name, but I think that there is a
special rc filename that is executed even when it isn't a login
shell.

[...]

Yes, I think so too, and I don't remember it offhand either, but man 
bash (which is quite long for a manpage) will tell you.


Perhaps it's called .bashenv? Not sure. I use ZSH. It's equivalent 
is .zshenv.

--
Gerald



As said under INVOCATION in the bash manpage:

Login shell: /etc/profile (if found), then the first one (if any) found 
readable among ~/.bash_profile, ~/.bash_login, ~/.profile (all this 
unless --noprofile). At exit: ~/.bash_logout (if found).


Non-login interactive shell: ~/.bashrc (if found) unless --norc

Non-interactive shell: does as if executing
if [ -n BASH_ENV ]; then . $BASH_ENV; fi
but doesn't search the $PATH

There are more details about what bash does when invoked as sh, when 
invoked in posix mode, when invoked by the remote shell daemon, or when 
invoked in suid mode.


Under FILES, two additional files (for readline initialization) are 
mentioned.



Best regards,
Tony.