Can you use colors to show the changes being made to your files? Yes definitely.
Category: Programming Language
In Bash—Pass Arguments From Function To Another
When I’m good about using and re-using functions in Bash I always end up passing arguments through from one function to another. For example:
function pie { open /Applications/Emacs.app --args --debug-init "$@" } function pienthm { EMACSNOTHEME=t pie --reverse-video "$@" }
Horrible to admit but I keep forgetting the syntax even are taking copious notes on the GNU Bash manual.
BTW: hear, hear to including Bash-isms in every shell script!
Lock And Unlock Your Files From The Command Line Using Finder
If you want to lock and unlock your files from the command line using Finder instead of using chmod
there here are two aliases to do it:
alias flock=’chflags -R uchg’
alias funlock=’chflags -R nouchg’
Map And Track Wi-Fi Networks You’re Not Connected To
Ever wonder how wifi devices talk to each other when they don’t know that you are listening?
Continue reading “Map And Track Wi-Fi Networks You’re Not Connected To”
Find All Locations Of A Binary Using `type’ not `which’
I can’t find the git
2.10 binary so I run
which git
/usr/local/bin/git
Excellent, found it.
And then I check it’s version to verify I am looking at the right version
/usr/local/bin/git –version
git version 2.21.0
Oops that isn’t what I wanted.
There must be another git
getting loaded earlier in the search path.
Here is how to find out where all copies of git
live
type -a git
git is /usr/local/bin/git git is /usr/local/bin/git git is /usr/bin/git
Look for the right git
at version 2.10
/usr/local/bin/git –version
/usr/bin/git –version
git version 2.21.0 git version 2.14.3 (Apple Git-98)
I want the second one.
That is how to track down the location of a binary file on macOS that appears multiple times in the search path.
Avoid Most Bash Errors Pretty Much By Quoting Everything, And More Best Practices
This page shows common errors that Bash programmers make. These examples are all flawed in some way.
You will save yourself from many of these pitfalls if you simply always use quotes and never use WordSplitting for any reason! Word splitting is a broken legacy misfeature inherited from the Bourne shell that’s stuck on by default if you don’t quote expansions. The vast majority of pitfalls are in some way related to unquoted expansions, and the ensuing word splitting and globbing that result.
All of us have fallen into one of these pits.
Why not use Python instead? 🙂
Oh yea, non-interactive shells
😠.
More on Quotes and Word Splitting.
ShellCheck, A Static Analysis Tool For Shell Scripts
- Bash Programming Rules
- Don’t
- If you must then frequently run ShellCheck
Here are my questionable credentials to make this claim.
Fix For When Bash Can’t Find Its Debugger On macOS
Sometimes Bash needs its debugger but it can’t find it. It looks like this:
/usr/share/bashdb/bashdb-main.inc: No such file or directory -bash: warning: cannot start debugger
For example when you start bashdb
yourself with bash --debugger
or set shopt -s extdebug
. Another example is when your terminal turns it on.
Here is the fix that worked on my box:
brew install bashdb
bashhome=$(brew –prefix bash)
bdbhome=$(brew –prefix bashdb)
ln -s $bdbhome/share/bashdb $bashhome/share/bashdb
unset bashhome
unset bdbhome
Bash 4.4 Is Released
See here.
macOS people maybe update now.
Update macOS 10.9 to use Bash Version 4
http://buddylindsey.com/upgrade-bash-to-4-on-os-x/” but I can’t get the page to load anymore 😮😢.
: The steps for this post were “