Git Bash Is My Preferred Windows Shell
Git Bash is a Windows command-line shell that emulates Unix-like bash, allowing Unix commands and Windows variable access. It offers easy installation, customization, and community support for users.
Read original articleGit Bash is a command-line shell for Windows that emulates the Unix-like bash shell, making it a preferred choice for users familiar with bash commands. It is packaged with Git for Windows and offers a range of features that enhance usability, such as the ability to pipe command outputs, access to Unix commands, and compatibility with Windows environment variables. Users appreciate its ease of installation, small footprint, and the convenience of launching it directly from Windows File Explorer. Git Bash supports scripting and allows users to create and edit bash profiles for customization. It also features Mintty as its default terminal emulator, which can be customized for color schemes and fonts. The article highlights the importance of community resources for learning and troubleshooting Git Bash, as well as tips for managing installations, updates, and customizations. Overall, Git Bash is favored for its functionality and user-friendly interface, especially for those who have a long history with Unix-like systems.
- Git Bash is a command-line shell for Windows that emulates the Unix bash shell.
- It allows users to run Unix commands and access Windows environment variables.
- The shell is easy to install and integrates well with Windows File Explorer.
- Customization options are available for the terminal emulator Mintty.
- Community resources are valuable for support and learning about Git Bash.
Related
FullBashGuide
The FullBashGuide on Greg's Wiki offers a comprehensive resource for beginners to learn BASH scripting. It covers commands, parameters, arrays, job control, and stresses testing code and proper quoting practices.
Free Introduction to Bash Scripting eBook
The GitHub guide on Bash scripting covers Bash structure, variables, loops, functions, and debugging. It offers downloads in dark mode, light mode, and ePub format. Additional resources include sponsors, a web page, video course, training, author details, PDF generation tool, and book cover creation tool. Links to the author's blog and other ebooks are provided for further exploration.
Bash-Oneliners: A collection of terminal tricks for Linux
The GitHub repository compiles Bash one-liners and commands for bioinformatics and cloud computing, covering terminal tricks, variable manipulation, text processing, networking commands, and system maintenance for improved command-line proficiency.
How to develop on Windows: comparing native, MinGW, Cygwin, WSL
Developing on Windows poses challenges due to Linux-oriented tools. Solutions include MSVC, MinGW-w64, Cygwin, and WSL, each offering different compatibility and functionality for C/C++ development.
Show HN: notesbash – A notes management TUI written in bash
notesbash is a Linux shell-based note-taking tool that allows users to manage notes via a terminal interface. It supports various file formats, customization, and is open-source under the GNU GPL 3+ license.
I still love bash and use it as well. But the hate powershell often gets is misguided.
> I’m more comfortable with bash commands than CMD or PowerShell commands (because I’ve been using Bourne shell (sh) and friends for more than 30 years).
This is the only argument I'm willing to accept, and honestly it's the only argument the writer needs, really: un-learning 30 years of experience to use something else even if the latter is objectively superior, would be a pain in the neck for anyone.
That being said I believe that seriously attempting to use the native tools would help the author understand Windows at a more fundamental level.
Also, this does raise a few questions, though—if the writer has been using UNIX shells for that long, why are they using Windows at all? As I commented elsewhere, why shoehorn the whole set of UNIX core utilities and binary utilities onto Windows when the latter comes with its own shell, command-line utilities, and management tools? More importantly, the author going by the rest of their posts (assuming it was the same author) doesn't strike me as the type (i.e. normie, for lack of a better word) to use Windows as a daily driver, but they seem to use it all the same. Therefore, why not an OS where these utilities feel more native and more useful, like Linux or one of the BSDs?
In contrast to the author I've been using and programming almost nothing but Windows (with a brief stint on Linux in university and now at work, but only for work), and on Windows I use PowerShell and if I really need to, CMD.exe (good riddance). As far as compilation goes, I use Visual Studio with MSVC and Clang-Cl, because they are the only complete development environment for Windows—all the others (MinGW, Cygwin, MSYS2) are incomplete or worse in some way, or make life harder than necessary in some way.
> I have experience using Windows PowerShell (powershell.exe), but do not yet have experience using the cross- platform PowerShell Core (pwsh).
For the record, functionality between powershell.exe and pwsh.exe is almost identical, with some minor differences[1]. Additionally they differ in the .NET runtime they were written against (.NET Framework 4.8 for powershell.exe, and .NET 7 and later for pwsh.exe).
[1]: https://learn.microsoft.com/en-gb/powershell/scripting/whats...
- Paths look much better: C:/Users/doctorpangloss == /Users/doctorpangloss == C:\Users\doctorpangloss.
- The coreutils are just there.
- Works flawlessly as an SSH or Dockerfile shell.
- Fast and tiny. So small you can check it into git.
- The maintainer is very responsive and fixes bugs quickly, even in upstream.
git-bash has problems because of paths, terminal weirdness, and it doesn’t use native Windows APIs for a variety of things where it should. /c/ this, /mnt/ that. It’s not really possible to write multi platform scripts with it. With Busybox for Windows you can.
Most of the windows-based programmers I interact with don't know powershell any better than I do. They use GUI tools for interacting with git and the filesystem.
So for me, git bash for git and filesystem interaction is a superpower in these places.
I could learn powershell, and I'm pretty sure it's much better than bash for scripting, but I'm almost never really scripting in bash anyway, I use tools like F# for that. Powershell seems fine, but it's less well supported on Linux and I don't really need a shell based language.
So in the end, git bash keeps on working and I can focus my learning elsewhere. It's stable, still works the same way 15+ years later, so no need to change.
Always beem 'forced' to use Windows as my workstation by a couple of specialty apps without Linux alternatives that need direct hardware access. But have always used linux on everything else (servers, even my media centre). Because I'm sometimes a late adopter of new tech, until recently I used cygwin as my normal command prompt. There were few downsides to that if you just need access to unix tools, except package management is a bit annoying. Well, discovered the MS Terminal and WSL this year, and happily moved off cygwin. More recently decided to switch over from WS1 to WSL2 but still evaluating the move.
Now I have a unix "more native" environment AND a linux distro I'm familiar with. I've been accessing the Windows filesystem under /mnt for two decades so this is normal for me, and if filesystem access is slower, it's not a dealbreaker. All my existing scripts were trivial to update. The integration of WSL and VSCode is also pretty cool. It means my vs code environment environment is also working natively in my WSL distro.
Overall can understand some lingering negativity about MS efforts in this dept but after years of rejecting all things linux and open source, in general the 180 from the top is much appreciated and it has kept me on Windows a while longer...so mission accomplished microsoft. Just gotta do something about those pesky apps I still need...
Another wonderful benefit of git bash, is that because it is so commonly installed, if you want scripting for a dev/build tool, you can 99% of the time just use bash for your scripts, on linux and windows.
I use this all the time for my build scripts. build/x86_64-linux-gnu-gcc.sh, build/x86_64-windows-msvc-cl.sh, etc. (These are generally simple single command line unity builds, parameterized only by debug, opt, etc.)
Then from pwsh I can run these scripts with `& "$env:GIT_INSTALL_ROOT\bin\bash.exe" .\build\x86_64-windows-msvc-cl.sh`, similarly from cmd.exe. (Looks like a ton of typing, but it's not, I always Ctrl-R search and get a hit by just typing "git_").
No need to write a bat script, or even a pwsh one, pretty much ever again. Even if all you want is logic to cd to the script directory, parse a single script argument, check it's valid, provide a default, make some directories if not present, etc., bash beats all the alternatives on many fronts.
I'm not looking to have the same environment everywhere, I'm fine to have windows stuff optimized for windows on windows, and vice versa on Linux.
By that reasoning, I think clink is a much better option.
I'd just started working for a client that is fully entrenched in Windows, but we're doing bare-metal and Linux-y work. When I'd discovered I couldn't use Linux as my daily driver due to security/policy(/tooling) reasons, one of my co-workers told me about Git Bash, and it's worked out so well that ... <looks left, looks right> ... when we were given the opportunity to use Linux but VM Windows, I kept the Windows machine.
GitBash has made Windows painless for my work's use-case. I should probably throw a few $$ at them ....
[1]: https://scoop.sh/
It doesn't occur to me to use it outside of that context. I use the command shell or Powershell depending on what I need to do.
WSL2 is great these days and can interact fine with Windows files (despite what this article says). But it's a lot more stuff, a full Linux install in a VM.
Edit: I know I can use aliases and .bat files and whatever to make one look like the other, sort of, but then I learn some patchwork system and will be unable to use any other computer's login.
1. I don’t understand how it relates to msys2 and where the boundary is, so I’m always reluctant to apply msys2 practices (documentation, advice, blog posts, etc.) to Git Bash.
2. I’ve been unable to figure out how to package scripts and other software for Git Bash so other users can install them.
I end up barely using it on my Windows 11 work machine because I'm allowed to have Linux VMs. Even with the VM overhead, and having fewer CPU cores and less RAM than the host, things still end up being way faster there.
I remember one time running a grep command on a large-ish (~ 1 GB) log file in Git Bash and waiting at least 5 minutes for it to complete. After getting impatient I did the same thing in a VM and it took about 30-45 seconds, at which point Git Bash still had not finished.
I mostly just use ubuntu under wsl2, though the file performance across the windows filesystem isn't the best.
Related
FullBashGuide
The FullBashGuide on Greg's Wiki offers a comprehensive resource for beginners to learn BASH scripting. It covers commands, parameters, arrays, job control, and stresses testing code and proper quoting practices.
Free Introduction to Bash Scripting eBook
The GitHub guide on Bash scripting covers Bash structure, variables, loops, functions, and debugging. It offers downloads in dark mode, light mode, and ePub format. Additional resources include sponsors, a web page, video course, training, author details, PDF generation tool, and book cover creation tool. Links to the author's blog and other ebooks are provided for further exploration.
Bash-Oneliners: A collection of terminal tricks for Linux
The GitHub repository compiles Bash one-liners and commands for bioinformatics and cloud computing, covering terminal tricks, variable manipulation, text processing, networking commands, and system maintenance for improved command-line proficiency.
How to develop on Windows: comparing native, MinGW, Cygwin, WSL
Developing on Windows poses challenges due to Linux-oriented tools. Solutions include MSVC, MinGW-w64, Cygwin, and WSL, each offering different compatibility and functionality for C/C++ development.
Show HN: notesbash – A notes management TUI written in bash
notesbash is a Linux shell-based note-taking tool that allows users to manage notes via a terminal interface. It supports various file formats, customization, and is open-source under the GNU GPL 3+ license.