Add updated bash startup files.
This commit is contained in:
parent
1e3ead5c74
commit
ee8f5f528a
11 changed files with 633 additions and 593 deletions
25
.bashrc.d/nanorc
Executable file
25
.bashrc.d/nanorc
Executable file
|
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash - not strictly necessary, but helps nano with syntax highlighting.
|
||||
|
||||
__nanorc_prompt_command() {
|
||||
# Dynamically handle .nanorc file versions.
|
||||
|
||||
hash nano >/dev/null 2>&1 && {
|
||||
# Darwin specifc .nanorc version.
|
||||
[[ "$PLATFORM" == "Darwin" ]] && [[ "$(hash -t nano)" == "/usr/bin/nano" ]] && local NANO_VER="darwin"
|
||||
# shellcheck disable=SC2155
|
||||
[[ -v NANO_VER ]] || local NANO_VER="$(command nano --version | awk '/version/ { print $4 }' | cut -d. -f1)"
|
||||
|
||||
# Set the .nanorc symlink if it doesn't already point to the correct versioned file.
|
||||
if [[ -f "$HOME/.nanorc-$NANO_VER" ]]; then
|
||||
[[ "$(readlink "$HOME/.nanorc")" != ".nanorc-$NANO_VER" ]] && (cd "$HOME" && ln -sf ".nanorc-$NANO_VER" ".nanorc")
|
||||
else
|
||||
[[ -L "$HOME/.nanorc" ]] && rm -f "$HOME/.nanorc"
|
||||
printf "\\033[1;31m%s\\033[0m\\n" "No .nanorc for version '$NANO_VER'." >&2
|
||||
fi
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Add the nanorc prompt function call to PROMPT_COMMAND.
|
||||
PROMPT_COMMAND+="__nanorc_prompt_command;"
|
||||
Loading…
Add table
Add a link
Reference in a new issue