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:
cd ‘C:\dev’
alias np=’start notepad++’
alias c=’code .’
alias dock=’docker-compose up’
alias dockb=’docker-compose.exe run app –entrypoint run build:dev’
alias histg=’history | grep’
alias g=’git’
export HISTCONTROL=ignoredups:erasedups
shopt -s histappend
export PROMPT_COMMAND=”${PROMPT_COMMAND:+$PROMPT_COMMAND$’\n’}history -a; history -c; history -r”
env=~/.ssh/agent.env
agent_load_env () { test -f “$env” && . “$env” >| /dev/null ; }
agent_start () {
(umask 077; ssh-agent >| “$env”)
. “$env” >| /dev/null ; }
agent_load_env
# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)
if [ ! “$SSH_AUTH_SOCK” ] || [ $agent_run_state = 2 ]; then
agent_start
ssh-add
elif [ “$SSH_AUTH_SOCK” ] && [ $agent_run_state = 1 ]; then
ssh-add
fi
unset env
My example .gitconfig
[color “diff”]
meta = yellow bold
[alias]
st = status
ch = checkout
co = commit
s = status
p = pull
d = diff