简体   繁体   English

如何在打开新的Git Bash命令提示符时预定义命令

[英]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 statusexit ,另一台机器有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.

相关问题 如何从命令提示符打开 git-bash.exe 以便它自动执行“git status”并等待下一个命令而不是退出 - How do I open git-bash.exe from command prompt such that it executes "git status" automatically and waits for the next command instead of exiting 在Windows中使用git bash时看不到命令​​提示符 - I can't see the command prompt when using git bash in Windows 当我在 vs 代码内外使用 git bash 提交时如何在新窗口中打开 vs 代码 - How to open vs code in a new window when i commit with git bash outside and inside of vs code 如何在GIT中使用分支名称配置命令提示符。 我收到此错误消息:&#39;-bash:__git_ps1:命令未找到&#39; - How to configure command prompt in GIT with branch name. I get this error message: '-bash: __git_ps1: command not found' 如何在bash PROMPT中为当前的git分支添加颜色? - How can I add color to the current git branch in my bash PROMPT? 创建新标签时,只能在这种情况下使用git pre-push hook吗? - Can I use git pre-push hook only for that case when I made a new tag? 使用 anaconda 提示一切正常,但是当我尝试使用 git bash 并使用 pip 或 sudo: command not found - Using anaconda prompt everything works fine but when I try to use git bash and use either pip or sudo: command not found 快好了! 如何在bash提示中添加另一种git status颜色? - Almost there! How can I add another git status colour to bash prompt? 如何在最开始的提示下登录 Git Bash? - How do I log in to Git Bash at the very beginning prompt? 当我在命令提示符中输入 git init 时,它显示“Permission Denied” - When I type git init in Command Prompt, it says “Permission Denied”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM