lackadaisical/shrc

46 lines
1,000 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 [[ $LD_INTERNAL -ne 1 ]];
then
LD_INTERNAL=1 source $LD_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
shellname=$(basename $SHELL)
rc_name="."$shellname"rc"
rc_path="$HOME/$rc_name"
# Optional MD5 checks
has_changed=1
sum1=$(md5_opt "$rc_path")
# 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