{"id":538,"date":"2023-02-04T11:44:39","date_gmt":"2023-02-04T11:44:39","guid":{"rendered":"http:\/\/alexanderramsey.com\/blog\/?p=538"},"modified":"2025-08-05T04:48:16","modified_gmt":"2025-08-05T04:48:16","slug":"dealing-with-path-and-bash-in-windows-10","status":"publish","type":"post","link":"http:\/\/alexanderramsey.com\/blog\/?p=538","title":{"rendered":"Dealing with PATH, Bash Profiles, Git config in Windows"},"content":{"rendered":"\n<p>This post serves as a convenience for me and <em>possibly <\/em>others (probably not because nobody develops on windows) 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 develop on Windows.<em> (Updated for 11 in 2023!)<\/em><\/p>\n\n\n\n<!--more-->\n\n\n\n<p>I primarily use Windows because my life is between software and business.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><a href=\"https:\/\/alexanderramsey.com\/blog\/wp-content\/uploads\/2023\/02\/image.png\"><img loading=\"lazy\" decoding=\"async\" width=\"398\" height=\"462\" src=\"https:\/\/alexanderramsey.com\/blog\/wp-content\/uploads\/2023\/02\/image.png\" alt=\"\" class=\"wp-image-609\" srcset=\"http:\/\/alexanderramsey.com\/blog\/wp-content\/uploads\/2023\/02\/image.png 398w, http:\/\/alexanderramsey.com\/blog\/wp-content\/uploads\/2023\/02\/image-258x300.png 258w\" sizes=\"auto, (max-width: 398px) 100vw, 398px\" \/><\/a><figcaption class=\"wp-element-caption\">XKCD #763<\/figcaption><\/figure>\n\n\n\n<p><strong>Git Bash Notes<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>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):&nbsp;<a href=\"https:\/\/stackoverflow.com\/questions\/32597209\/python-not-working-in-the-command-line-of-git-bash\">https:\/\/stackoverflow.com\/questions\/32597209\/python-not-working-in-the-command-line-of-git-bash<\/a><\/li>\n\n\n\n<li>Set your default Git Bash startup location:&nbsp;<a href=\"https:\/\/stackoverflow.com\/questions\/7671461\/how-do-i-change-the-default-location-for-git-bash-on-windows\">https:\/\/stackoverflow.com\/questions\/7671461\/how-do-i-change-the-default-location-for-git-bash-on-windows<\/a><\/li>\n\n\n\n<li>Set your Git Bash for Windows to use your own bashrc settings. Git Bash for Windows now looks for a file&nbsp;<strong>named: .bash_profile<\/strong> \/ <em>formerly named: .bashrc&nbsp;<\/em>:&nbsp;<a href=\"https:\/\/stackoverflow.com\/questions\/6883760\/git-for-windows-bashrc-or-equivalent-config-files-for-git-bash-shell\">https:\/\/stackoverflow.com\/questions\/6883760\/git-for-windows-bashrc-or-equivalent-config-files-for-git-bash-shell<\/a>\n<ul class=\"wp-block-list\">\n<li> <span style=\"font-size: revert;\">Git Bash 2.5.0 in Windows 10. I renamed my &#8216;.bashrc&#8217; -&gt; &#8216;.bash_profile&#8217; 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.<\/span> <\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Append Bash <strong>history <\/strong>to prevent multiple windows overwriting:&nbsp;<a href=\"https:\/\/unix.stackexchange.com\/questions\/1288\/preserve-bash-history-in-multiple-terminal-windows\">https:\/\/unix.stackexchange.com\/questions\/1288\/preserve-bash-history-in-multiple-terminal-windows<\/a><br><\/li>\n\n\n\n<li><em>Helpful commands:<\/em>\n<ul class=\"wp-block-list\">\n<li>alias&nbsp;<a href=\"https:\/\/askubuntu.com\/questions\/17536\/how-do-i-create-a-permanent-bash-alias\">https:\/\/askubuntu.com\/questions\/17536\/how-do-i-create-a-permanent-bash-alias<\/a><\/li>\n\n\n\n<li>history<\/li>\n\n\n\n<li>grep<\/li>\n\n\n\n<li>winpty<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>Windows PATH Tips\/Instructions:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Control Panel &gt; System &gt; Advanced &gt; Environment Variables<\/li>\n\n\n\n<li>Edit Path to add a folder or System Variable\n<ul class=\"wp-block-list\">\n<li>Add a folder: Point the resource you need by adding a folder path without the .exe<\/li>\n\n\n\n<li>Add a <strong>System <\/strong>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%; ).<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Windows Environment Variable added without restarting (ha):&nbsp;<a href=\"https:\/\/serverfault.com\/questions\/8855\/how-do-you-add-a-windows-environment-variable-without-rebooting\">https:\/\/serverfault.com\/questions\/8855\/how-do-you-add-a-windows-environment-variable-without-rebooting<\/a><br><em>Or you know, just fucking reboot<\/em><\/li>\n\n\n\n<li>Add things for convenience like c:\/eclipse\/ and then simply type eclipse to open the IDE<\/li>\n<\/ul>\n\n\n\n<p><strong>.bash_profile Examples:<\/strong><\/p>\n\n\n\n<p><a href=\"https:\/\/www.tldp.org\/LDP\/abs\/html\/sample-bashrc.html\">https:\/\/www.tldp.org\/LDP\/abs\/html\/sample-bashrc.html<\/a><\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/gist.github.com\/susanBuck\/ee3a0a53d72198c1a244\n<\/div><\/figure>\n\n\n\n<p><strong>My .bash_profile:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># go to the root directory of my development environment on startup\ncd 'C:\\dev'\n\n# set aliases for commonly used applications\nalias np='start notepad++'\nalias c='code .'\nalias dock='docker-compose up'\nalias dockb='docker-compose.exe run app --entrypoint run build:dev'\nalias histg='history | grep'\nalias g='git'\n\n# save history and persist across multiple bash windows\nexport HISTCONTROL=ignoredups:erasedups\nshopt -s histappend\nexport PROMPT_COMMAND=\"${PROMPT_COMMAND:+$PROMPT_COMMAND$'\\n'}history -a; history -c; history -r\"<\/code><\/pre>\n\n\n\n<p><em>SSH &#8211; I no longer use this (2023) as I now run the service via Windows<\/em>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n# ssh things\nenv=~\/.ssh\/agent.env\n\nagent_load_env () { test -f \"$env\" &amp;&amp; . \"$env\" &gt;| \/dev\/null ; }\n\nagent_start () {\n(umask 077; ssh-agent &gt;| \"$env\")\n. \"$env\" &gt;| \/dev\/null ; }\n\nagent_load_env\n\n# optional SSH key handling\n# agent_run_state: 0=agent running w\/ key; 1=agent w\/o key; 2= agent not running\n# agent_run_state=$(ssh-add -l &gt;| \/dev\/null 2&gt;&amp;1; echo $?)\n\nif &#91; ! \"$SSH_AUTH_SOCK\" ] || &#91; $agent_run_state = 2 ]; then\nagent_start\nssh-add\nelif &#91; \"$SSH_AUTH_SOCK\" ] &amp;&amp; &#91; $agent_run_state = 1 ]; then\nssh-add\nfi\n\nunset env<\/code><\/pre>\n\n\n\n<p><strong>My .gitconfig<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;color \"diff\"]\nmeta = yellow bold\n&#91;alias]\nst = status\nch = checkout\nco = commit\ns = status\np = pull\nd = diff<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This post serves as a convenience for me and possibly others (probably not because nobody develops on windows) 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 develop on Windows. (Updated for 11 in 2023!)<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-538","post","type-post","status-publish","format-standard","hentry","category-development"],"_links":{"self":[{"href":"http:\/\/alexanderramsey.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/538","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/alexanderramsey.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/alexanderramsey.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/alexanderramsey.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/alexanderramsey.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=538"}],"version-history":[{"count":21,"href":"http:\/\/alexanderramsey.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/538\/revisions"}],"predecessor-version":[{"id":974,"href":"http:\/\/alexanderramsey.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/538\/revisions\/974"}],"wp:attachment":[{"href":"http:\/\/alexanderramsey.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=538"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/alexanderramsey.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=538"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/alexanderramsey.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=538"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}