Reputation: 1255
I install Cygwin on Windows 7 64bit, and my location on /.bashrc
location is C:/cygwin64/home/admin/bashrc
, but I can't see it from Cygwin, it's says:
bash: /.bashrc: No such file or directory
What I try is to navigate to that folder with the command:
cd /cygdrive/c/cygwin64/home/admin/
and then use:
/.bashrc
but it says:
No such file or directory
What to do to see that file?
Upvotes: 2
Views: 15060
Reputation: 551
Old topic, I know... but, may be useful for somebody. In the cygwin64\bin folder, create a bacth file named ls.bat and add this:
@echo off
ls_.exe --color=auto %*
Then rename ls.exe to ls_.exe
That's it.
Upvotes: 0
Reputation: 8150
Just to clarify: this is has nothing to do with Cygwin. It is normal Bash behavior.
~/.profile: The login script filename originally used by /bin/sh.
~/.bash_profile: The personal initialization file, executed for login shells
~/.bashrc: The individual per-interactive-shell startup file.
Each new Cygwin window (each invocation of Cygwin.bat) opens a login shell, because there is no init process and you are already logged in as Windows user. In Cygwin.bat Bash is invoked so: bash --login -i
.
Because of --login
the ~/.bash_profile is executed. More specifically, Bash reads /etc/profile and then ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and executes the first one that is readable.
Because of -i
the ~/.bashrc should be executed too. But it isn't because Bash only executes .bashrc for a shell that's both interactive and non-login.
Note that bash --login -i --rcfile=C:/Cygin/home/%USERNAME%/.bashrc
won't work either, because --rcfile
is silently ignored in case of login shells.
Therefore it is good practice to hook $HOME/.bashrc in case of a true login shell (textual login shell). This is the reason why many .bash_profile files contain the following lines:
if [ -f "${HOME}/.bashrc" ]; then
source "${HOME}/.bashrc"
fi
Textual login shells appear when you ssh/telnet to a host, boot Linux into text mode or... run Cygwin.bat.
Having come this far I'd like to add a subtle point. Many Linux desktops read ~/.profile (not ~/.bash_profile or ~/.bash_login) automatically by the Display-Manager during the start-up process desktop session. Therefore hook ~/.bashrc in ~/.profile too:
if [ -n "$BASH_VERSION" ]; then
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
Because Bash executes ~/.profile in absence of ~/.bash_profile you may get away with only ~/.profile.
Now you can do all customization in ~/.bashrc.
Upvotes: 2
Reputation: 406
I had the same problem on my Cygwin installation.
CYGWIN_NT-6.1 2.5.2(0.297/5/3) x86_64 Cygwin
I created a ~/.bashrc file in my (cygwin) home directory, but the aliases I set up did not work.
The problem was that I did not have a ~/.bash_profile file in my home directory. It must contain the following line to recognize the desired .bashrc
. ~/.bashrc
I created it by appending the needed line
echo ". ~/.bashrc" >> ~/.bash_profile
See StackOverflow > Cygwin shell doesn't execute .bashrc
Upvotes: 5
Reputation: 546
find your $HOME
and can you try this command :
cd ~/
ls -la
if he doesn't exists create it. or check this post : Cygwin shell doesn't execute .bashrc
or tries
cat ~/.bashrc
Upvotes: 0