lackadaisical/shrc
Sam Hardeman 0912f2d3d4 - Many fixes to sourcing, now will always resolve to base dir.
- All scripts are again `sh` compatible.
- Binbox overhaul, symlinks finally work just like `busybox`.
- Error checking to some files like `sw` and `own`.
TODO: Make it pretty and make `short` already.
2025-09-22 08:34:50 +02:00

47 lines
1,002 B
Text
Executable file

#!/bin/echo Please run this program with: ". shrc" or include
# `FROM_RC=1 source shrc` in your RC file to set up an alias.
# Just opens your .rc file easily, for your current shell
# and sources the .rc afterwards!
# Source standard setup
if [[ $DAISY_INTERNAL -ne 1 ]];
then
DAISY_INTERNAL=1 source $DAISY_SOURCE_FILE
fi
function md5_opt()
{
if [[ $DAISY_HAS_md5sum -eq 1 ]];
then
echo $(md5sum "$1" | awk '{print $1}')
fi
}
if [[ $FROM_RC -eq 1 ]]; then
alias shrc=". shrc"
else
BASENAME=$(basename $SHELL)
RC_NAME="."$BASENAME"rc"
RC_PATH="$HOME/$RC_NAME"
# Optional MD5 checks
HAS_CHANGED=1
SUM1=$(md5_opt "$RC_PATH")
SUM2=
# This sets a default if the variable does not exist.
EDITOR=${EDITOR:-$(ched)}
$EDITOR "$RC_PATH"
wait_for_editor $EDITOR "$RC_PATH"
SUM2=$(md5_opt "$RC_PATH")
if [[ $DAISY_HAS_md5sum -eq 1 && "$SUM1" == "$SUM2" ]];
then
echo "The RC-file $RC_NAME has not changed on disk. Not sourcing."
return
fi
source "$RC_PATH"
fi