What's the easiest way to set mingw's console startup directory? I only use mingw for compiling. b开发者_如何学JAVAut due to the lack of editors or even symlinks I am confused how to tell mingw console to come up in a different directory rather than regular home dir.
It would also be helpful if someone knows how to place "real" symlinks to ntfs drives like cygwin can do. mingw copies the content and that is useless when working on a subversion dir.
I am a lazy guy, and i find it painful to do the cd /c/Documents/USER/.../Project all the time :>
If anyone else finds this post looking for an answer, what worked for me was
- Create shortcut if one doesn't already exist. Could be on your desktop or taskbar.
- Right click >> Properties >> and change the Start in: value.
- Use the shortcut and instantly start in your project directory.
I have several shortcuts for various projects in a line on my Desktop so I can quickly start a terminal in each of those directories and get right to work!
this is the simplest way, I think:
open the shell
vim .profile (ESC / i to enter insert mode)
#!/bin/bash
cd /c/Users/jbr
(ESC / wq to write and close editor)
test the .profile bash file: source .profile
close and reopen the shell.
Enjoy, Fabar
I found the following solution, I didn't want mountpoints, I wanted explicitly the possibility to start from any directory where I am currently (working dir) so I made a bunch of scripts.
They works, but still have issues with path containing spaces (I'm sorry):
bash.bat
Place it in your path so that you can run it from cmd.exe
@echo off
set STARTUP_DIR=%CD%
D:\MinGW\msys\1.0\bin\bash.exe --login
**Ensure you have an environment variable set called HOME which points to what you want as home user directory (must be without spaces!!) in my case D:\Users\Myname
.bashrc
Place it in your home directory
if [[ "$STARTUP_DIR" != "$PWD" ]]; then
cd $STARTUP_DIR
fi
Now, considering bash.exe will run .bash_profile and not .bashrc, I added this, in the home directory:
.bash_profile
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
I use Console2 so I can just set as startup shell my bash.bat file and that's all I need.
By default when I start {install location of MinGW}\msys\1.0\msys.bat
the shell is started in the folder {install location of MinGW}\msys\1.0\home\jbr
.
I created a file {install location of MinGW}\msys\1.0\home\jbr\.profile
containing this:
# Cd to my windows home:
cd /c/Users/jbr
Now when I open a new shell msys.bat
; I am at the correct location:
This worked for me.
I edited C:\MinGW\msys\1.0\etc\profile
and changed line 32 from:
# Set up USER's home directory
if [ -z "$HOME" ]; then
HOME="/home/$LOGNAME"
fi
to:
HOME="/c/Users/$LOGNAME"
And now when I open MinGW (msys) it uses the default Windows home folder. This enables functionality such as ~/.profile
, ~/.ssh
and so forth.
Use mount points instead of symlinks. mingw doesn't support ntfs symlinks (they're rather new anyway), but mount points are okay for most use cases (such as simple access to the directory you're working in outside mingw).
And the easiest way to set a new default directory is probably using a .bashrc
in the home directory that cd
s to the desired directory.
It would also be helpful if someone knows how to place "real" symlinks to ntfs drives like cygwin can do. mingw copies the content and that is useless when working on a subversion dir.
Cygwin does not place real symlinks.
精彩评论