Dealing with PATH and Bash in Windows 10

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:

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