我刚刚为Windows安装了Git,很高兴看到它安装了Bash。
我想像在Linux下一样定制shell (例如,为ls -l设置别名ll ),但我似乎找不到.bashrc或类似的配置文件。
我应该编辑什么?
发布于 2015-09-02 20:24:28
在更新版本的Git for Windows中,Bash是用--login启动的,这导致Bash不能直接读取.bashrc。相反,它显示的是.bash_profile。
如果该文件不存在,请使用以下内容创建该文件:
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi这将导致Bash读取.bashrc文件。根据我对this issue的理解,Git for Windows应该会自动做到这一点。然而,我刚刚安装了2.5.1版,但它没有。
发布于 2016-02-06 01:22:06
1)首先在管理员模式下打开git-bash.exe。(右键单击文件并选择“以管理员身份运行”,或在“属性”“→Compatibility→”中更改设置以管理员身份运行此程序。)
2)运行cd ~。它会带你去C:/Users/<Your-Username>。
3)运行vi .bashrc。这将打开您进入编辑器。点击INSERT,然后开始输入以下信息:
alias ll="ls -la" # this changes the default ll on git bash to see hidden files.
cd "C:\directory\to\your\work\path\"
ll # this shows your your directory before you even type anything.发布于 2019-07-02 16:09:50
只需从git bash shell执行notepad ~/.bashrc并保存file.That即可。
注意:请确保您需要重新启动终端以使更改生效。
https://stackoverflow.com/questions/6883760
复制相似问题