This post serves as a convenience reminder to myself and possibly others on how to manage working within Git Bash and Command Line in general within Windows 10. It can be a real pain in the neck to deal with PATH.
Git Bash Notes:
- Git Bash does not always work with Windows Path. Sometimes you have to use winpty and alias to setup and run things (like Node or Python): https://stackoverflow.com/questions/32597209/python-not-working-in-the-command-line-of-git-bash
- Set your default Git Bash startup location: https://stackoverflow.com/questions/7671461/how-do-i-change-the-default-location-for-git-bash-on-windows
- Set your Git Bash for Windows to use your own bashrc settings. Git Bash for Windows now looks for a file named: .bash_profile / formerly named: .bashrc : https://stackoverflow.com/questions/6883760/git-for-windows-bashrc-or-equivalent-config-files-for-git-bash-shell
-
Git Bash 2.5.0 in Windows 10. I renamed my ‘.bashrc’ -> ‘.bash_profile’ and relaunched Git Bash. Place in home directory of your user as the file itself. An existing one may already be there as generated by Git for Windows.
-
- Append Bash history to prevent multiple windows overwriting: https://unix.stackexchange.com/questions/1288/preserve-bash-history-in-multiple-terminal-windows
- Helpful commands:
- alias https://askubuntu.com/questions/17536/how-do-i-create-a-permanent-bash-alias
- history
- grep
- winpty
Windows PATH Tips/Instructions:
- Control Panel > System > Advanced > Environment Variables
- Edit Path to add a folder or System Variable
- Add a folder: Point the resource you need by adding a folder path without the .exe
- Add a System Variable: First point the directory and assign a variable name by adding to the System Variables. Next append the name of the variable to the Path ( ex. %JAVA%; ).
- Windows Environment Variable added without restarting (ha): https://serverfault.com/questions/8855/how-do-you-add-a-windows-environment-variable-without-rebooting
- Add things for convenience like c:/eclipse/ and then simply type eclipse to open the IDE
.bash_profile/.bashrc Examples:
https://www.tldp.org/LDP/abs/html/sample-bashrc.html
https://gist.github.com/susanBuck/ee3a0a53d72198c1a244
My example .bash_profile:
# Upon open go to my dev directory
cd 'C:\Users\AlexanderRamsey\dev'
# Launch Sublime in current dir
alias sublime='subl.exe .'
# Launch python in git bash
alias pyth='winpty py'
# Search history. Example usage: histg foo
alias histg="history | grep"
# Handle history among multiple windows
# Avoid duplicates
export HISTCONTROL=ignoredups:erasedups
# When the shell exits, append to the history file instead of overwriting it
shopt -s histappend
# After each command, append to the history file and reread it
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r"
My example .gitconfig
[color "diff"]
meta = yellow bold
[alias]
st = status
ch = checkout
co = commit
s = status
p = pull
d = diff
Sublime Text Config File
{ "font_size": 12, "hot_exit": false, "ignored_packages": [ "Vintage" ], "remember_open_files": false, "tab_size": 3, "theme": "Adaptive.sublime-theme" }