* Use curl to retrieve the raw install script from github
* Execute payload directly with bash -c without requiring file write
* Detect bash execution (as apposed to terminal or script file execution) and assume that this is a direct install
* On direct install
* * purge ~/.bash_it if present
* * git clone repo to ~/.bash_it
* * continue installation as normal
We get an error from cp
We still respond that we made a backup
Instead if .bas_profile exists and cp is a success then prompt informing the user that we made a backup
or inform them that no .bash_profile was found so no need to make a back up at this point.
It's nice that we make a backup but…
* what if a back-up already exists?
* what if this is the 2nd, 3rd or 4th time I'm executing the script?
We backup to .bash_profile.bak or .bash_plofile.bak.{count} if .bash_plofile.bak already exists.
iow
.bash_plofile.bak if not exist
.bash_plofile.bak.1 if exists
.bash_plofile.bak.2 if 2 exists
.bash_plofile.bak.3 if 3 exists etc…
Newest backup with the highest number.
At least a general conformance to the same style if nothing else
Based on what appeared to be the most used or most sensible conventions which lead to the following
Braces around variables
Preserve quotes and quote paths
statements begin on the same line
No trailing white space
Respect 120 chars page width at least
Use brackets instead of back-ticks
Two space indent 4 space continuation
No logic was harmed in the making of this commit.
I have a repo with many other branches that contain the string `main`,
but our default branch is still master. This grep was seeing those other branches
and deciding that my default branch was `main`. This tighter regex
fixes that behavior for me.
By setting `__bp_delay_install`, we avoid any immediate initialization at all. We then override two troublesome functions before calling `__bp_install_after_session_init()`.
The `__bp_install_after_session_init()` function doesn't enable the DEBUG trap, just sets `$PROMPT_COMMAND` to include `__bp_install()`, so the actual final `$PROMPT_COMMAND` is not finished, and DEBUG trap set, until after the first prompt is displayed.
The existing function `_bash-it-grep()` is weird. New function `_bash-it-egrep()` just does the thing without requiring two subshells and manual invocation.
Use $XDG_CACHE_HOME environment constant instead of placing a tmp/cache folder inside the bash-it data repo. If not defined, fall back to current behavior.
This resolvesBash-It/Bash-It#1904.
No need to `rm` when we overwrite the file the line after next. Alsö, use `>|` in case the user sets `noclobber`; we do expressly intend to overwrite the file in this case.
The tilde should not have been escaped, and in fact I did not have it escaped in my main branch, but the PR I submitted did have it escaped and...now it shows up in the prompt line for all the PowerLine themes... oops.