windows 更改 mingw 的启动目录或创建 mingw 符号链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7000524/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
changing mingw' startup directory or creating mingw symlinks
提问by mschmoock
whats the easiest way to set mingw's console startup directory? i only use mingw for compiling. but 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.
设置 mingw 的控制台启动目录的最简单方法是什么?我只使用 mingw 进行编译。但是由于缺少编辑器甚至符号链接,我很困惑如何告诉 mingw 控制台出现在不同的目录中,而不是常规的主目录中。
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 那样将“真正的”符号链接放置到 ntfs 驱动器,那也会很有帮助。mingw 会复制内容,这在处理 subversion 目录时是无用的。
i am a lazy guy, and i find it painful to do the cd /c/Documents/USER/.../Project all the time :>
我是一个懒惰的人,我发现一直执行 cd /c/Documents/USER/.../Project 很痛苦:>
Regards, Michael
问候,迈克尔
采纳答案by Patrick Georgi
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).
使用挂载点而不是符号链接。mingw 不支持 ntfs 符号链接(无论如何它们都很新),但是挂载点对于大多数用例都可以(例如简单访问您在 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.
设置新默认目录的最简单方法可能是.bashrc
在cd
指向所需目录的主目录中使用。
回答by hatberg
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!
我在桌面上的一行中有多个用于各种项目的快捷方式,因此我可以在每个目录中快速启动终端并开始工作!
回答by Fabar
this is the simplest way, I think:
这是最简单的方法,我认为:
open the shell
vim .profile (ESC / i to enter insert mode)
#!/bin/bash
cd /c/Users/jbr
打开外壳
vim .profile (ESC / i 进入插入模式)
#!/bin/bash
cd /c/用户/jbr
(ESC / wq to write and close editor)
(ESC / wq 编写并关闭编辑器)
test the .profile bash file: source .profile
close and reopen the shell.
测试 .profile bash 文件: source .profile
关闭并重新打开外壳。
Enjoy, Fabar
享受吧,法巴
回答by Jmini
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
.
默认情况下,当我启动时{install location of MinGW}\msys\1.0\msys.bat
,shell 是在文件夹中启动的{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:
我创建了一个{install location of MinGW}\msys\1.0\home\jbr\.profile
包含以下内容的文件:
# Cd to my windows home:
cd /c/Users/jbr
Now when I open a new shell msys.bat
; I am at the correct location:
现在,当我打开一个新外壳时msys.bat
;我在正确的位置:
This worked for me.
这对我有用。
回答by Francesco Belladonna
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
bash.bat
Place it in your path so that you can run it from cmd.exe
将它放在您的路径中,以便您可以从 cmd.exe 运行它
@echo off
set STARTUP_DIR=%CD%
D:\MinGW\msys.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
**确保你有一个名为 HOME 的环境变量集,它指向你想要的主用户目录(必须没有空格!!)在我的情况下 D:\Users\Myname
.bashrc
.bashrc
Place it in your home directory
将其放在您的主目录中
if [[ "$STARTUP_DIR" != "$PWD" ]]; then
cd $STARTUP_DIR
fi
Now, considering bash.exe will run .bash_profileand not .bashrc, I added this, in the home directory:
现在,考虑到 bash.exe 将运行.bash_profile而不是 .bashrc,我在主目录中添加了这个:
.bash_profile
.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.
我使用 Console2,所以我可以将我的 bash.bat 文件设置为启动 shell,这就是我所需要的。
回答by Charney Kaye
I edited C:\MinGW\msys\1.0\etc\profile
and changed line 32 from:
我编辑C:\MinGW\msys\1.0\etc\profile
并更改了第 32 行:
# 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.
现在,当我打开 MinGW (msys) 时,它使用默认的 Windows 主文件夹。这使功能,例如~/.profile
,~/.ssh
等等。
回答by Joshua
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 那样将“真正的”符号链接放置到 ntfs 驱动器,那也会很有帮助。mingw 会复制内容,这在处理 subversion 目录时是无用的。
Cygwin does not place real symlinks.
Cygwin 不会放置真正的符号链接。