[英]How can I pre-define commands for when I open a new Git Bash command prompt
I have noticed that on my various (Windows 7) machines running Git that when I open a new Git Bash command prompt I can often access previous commands by pressing the up arrow. 我注意到在运行Git的各种(Windows 7)计算机上,当我打开一个新的Git Bash命令提示符时,我可以通过按向上箭头来访问以前的命令。
These commands differ from machine to machine, but each machine has the same preset commands every time I open Git Bash. 这些命令因机器而异,但每次打开Git Bash 时 ,每台机器都有相同的预设命令。 One machine for example lets me scroll thorough
git status
and exit
, another has exit
and two blanks lines, while a third machine has no previous commands. 例如,一台机器让我滚动彻底的
git status
并exit
,另一台机器有exit
和两个空白行,而第三台机器没有先前的命令。
Can anyone say how these are set and what I can do to edit them? 任何人都可以说这些是如何设置的以及我可以做些什么来编辑它们?
To predefine aliases that stick, put things like 要预定义粘贴的别名,请添加类似的内容
alias gs="git status"
into your ~/.bashrc
. 进入你的
~/.bashrc
。
~
would be C:\\Users\\<username>
in Windows. ~
将是Windows中的C:\\Users\\<username>
。
Since you were not overly specific with what you wanted: 既然你没有过分具体想要的东西:
You seem to want to have a set of commands you can cycle through with up , based on the commands on all the machines you have used lately. 你似乎想拥有一组命令,你可以循环使用,开发了基于你近来使用的所有计算机上的命令。 (Which are saved locally in
~/.bash_history
on each machine.) (在每台机器的
~/.bash_history
本地保存。)
To just have a common history among all machines without some real dirty hackery is not possible, and also just very unlikely worth the effort. 只是在所有机器中只有一个共同的历史,没有一些真正的脏兮兮的hackery是不可能的,也是非常不值得的努力。 On how to achieve the cycle-through functionality, I have no clue.
关于如何实现循环功能,我不知道。
这些命令存储在bash_history文件中,在Windows中为C:\\Users\\[YOUR USERNAME]\\.bash_history\\
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.