Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Whenever I start cygwin, I need to cd several levels down to the only directory that I care about when using cygwin.

How can I get cygwin to start in this particular directory by default...i.e., each time I start Cygwin it will be in that directory already?

I found some things that may be it, or close, but I don't understand them, and there's really no results when I search for these (n00b) terms. Any help would be great!

share|improve this question

Just add

cd /path/to/directory/you/care/about

to the bottom of your ~/.bashrc file.

share|improve this answer
where is that ~/.bashrc file in windows installation – Erdem Ece Nov 17 '14 at 12:02
It depends on how you installed Cygwin, but the Windows path to your Cygwin home directory is usually C:\cygwin\home\%USERNAME%, which would make the Windows path to ~/.bashrc C:\cygwin\home\%USERNAME%\.bashrc. – garyjohn Nov 17 '14 at 19:55
what if the dafault home directory is a directory where I don't want to put any file. – Arturo Mar 14 '15 at 15:56

in the last line of your .bash_profile (or .profile), put cd your/dirctory/here

share|improve this answer

Define "start cygwin"? You can run cygwin servers when you power your machine up, but I'm assuming that's not what you mean.

If you mean, end up in a specific folder every time you open a shell prompt, you can put that in your $HOME/.bashrc

Edit your $HOME/.bashrc using a cygwin editor (one that uses UNIX line endings), add a line

cd /whatever/directory/you/want

If you're constantly going to this directory, you're probably better off making an alias as well.

In your $HOME/.bashrc put:

alias GT='cd /whatever/directory/you/want'

Call it whatever you want; I just used GT for "go there", and I uppercase because it makes it easy to separate from builtin commands, which are never capitalized.

share|improve this answer

python script

!!before use add .bashrs any string to the end!!

use c:\path

path_bachrc - path to .bashrc

cmd - path to cygwin.bat

#                         #
import argparse
import subprocess
import os

path_bachrc = 'c:/PP/cygwin/home/adm/.bashrc'
cmd = 'c:\PP\cygwin\Cygwin.bat'

def delEndLineFromFile(filename):
    with open(filename, 'r') as f:
        aList = f.readlines()

    bList = aList[0:-1]

    with open(filename, 'w') as fd:

parser = argparse.ArgumentParser()
parser.add_argument("newPath", type=str, help="New path in .bachrc cygwin")
args = parser.parse_args();


p = args.newPath;
pNew = 'cd /cygdrive/' + p[:1] + p[2:].replace('\\', '/')

with open(path_bachrc, 'a') as f:

PIPE = subprocess.PIPE
p = subprocess.Popen(cmd, shell = True)
share|improve this answer
Please explain. – Roney Michael Jul 10 '13 at 4:11
python script use c:\path\ – user236976 Jul 10 '13 at 5:25
path_bachrc - path to .bashrc – user236976 Jul 10 '13 at 5:25
cmd - path to cygwin.bat – user236976 Jul 10 '13 at 5:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .