crispy
crispy

Reputation: 5877

cygwin + console2: running cygwin bash with startup dir

I am using Console2 as a bash wrapper on Windows. Most importantly, it enables me to start up a new bash tab in a predefined project directory.

Now I would like to replace the Windows command line by a Cygwin bash. However, the "Startup Dir" setting in Console2 is not respected by Cygwin.

Basically, I see three solution approaches:

Searching around in Cygwin's documentation and the rest of the Internet, I could not find a solution to any of those approaches. I could imagine that the solution is trivial to someone else, though. :)

environment: Win XP, Console 2.00.146, Cygwin 1.7.7, GNU Bash 3.2.51(24)

Upvotes: 18

Views: 12914

Answers (7)

kerl
kerl

Reputation: 269

  1. Change the shell dir to:

    bash --login -i -c 'cd /cygdrive/c/...; exec /bin/bash'

  2. Add this line to the end of C:\cygwin\home\USERNAME\.profile

    cd -

Upvotes: 0

Martin Lütke
Martin Lütke

Reputation: 742

I had some problems with some with the approaches above (Console2 window screwed up when using c:\cygwin\bin\bash.exe as shell, xhere not reflecting my actual working dir).

So I created this batch file and used it as Console2's shell:

C:\cygwin64\cygbash.bat:

C:\cygwin64\bin\bash --login -i  -c "/bin/xhere /bin/bash `cygpath -d '%CD%'`"

Upvotes: 3

Kelly
Kelly

Reputation: 31

I tried variations of all the above, but none worked. This is what worked for me using Console2 v2.00.148:

1)..Copy the Cygwin.bat to a new file: Cygbash.bat.

2)..Replace the last line to be this: bash --login -i -c 'cd /cygdrive/c/; exec bash'

3)..Go into Console2 settings and change the shell to point to this new Cygbash.bat file.

The above will start Console2 in the root of your C drive. fyi - I'm the original poster, just forgot to login to my account first.

Upvotes: 3

Dmitry Oksenchuk
Dmitry Oksenchuk

Reputation: 121

  • In Cygwin installer add "chere" package (contains /bin/xhere script)
  • Use the following shell command in Console2 settings:

    C:\cygwin\bin\bash.exe -c '/bin/xhere /bin/bash'

The shell will run in the current working dir or in the specified "Startup Dir".

Upvotes: 5

zen
zen

Reputation: 570

I was having the same problem, saw your post, and then found this answer:

  1. Run the Setup.exe Cygwin installer and add the "chere" package
  2. In Console2, add a new tab called "Bash" with a shell path of "C:\cygwin\bin\bash". See screenshot.
  3. Finally, add the following to the registry: Code:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Open Cygwin Here...]

[HKEY_CLASSES_ROOT\Directory\shell\Open Cygwin Here...\command] @="\"C:\Program Files\Console2\Console.exe\" -t Bash -r \"/bin/xhere /bin/bash.exe '%L'\""

Found this solution at: http://www.e-texteditor.com/forum/viewtopic.php?p=8884

Upvotes: 6

Hugo
Hugo

Reputation: 496

Regarding your last bullet point, you can put for example:

cd /cygdrive/d

in ~/.bash_profile This will be picked up when using Console2 and also when you run Cygwin itself.

Upvotes: 0

Dennis Williamson
Dennis Williamson

Reputation: 360075

As for the last bullet point, edit your ~/.bashrc and add a cd command at the end.

Instead of that, you can try this for your first bullet point: If your Console2 configuration to start Bash looks something like this:

bash --login -i

change it to:

bash --login -i -c 'cd somdir; exec bash'

Upvotes: 23

Related Questions