Rebrand to 'REcycle SHell', show 'future' update messages, changes

pull/184/head
Simon Let 3 years ago
parent acbf463942
commit 3e03f4a0d2
  1. 25
      scripts/hooks.sh
  2. 27
      scripts/install.sh

@ -1,7 +1,6 @@
#!/hint/sh #!/hint/sh
__resh_reload_shellrc() { __resh_reload_msg() {
source ~/.resh/shellrc
printf '\n' printf '\n'
printf '+--------------------------------------------------------------+\n' printf '+--------------------------------------------------------------+\n'
printf '| New version of RESH shell files was loaded in this terminal. |\n' printf '| New version of RESH shell files was loaded in this terminal. |\n'
@ -21,23 +20,25 @@ __resh_reload_shellrc() {
# => The `__resh_preexec` function needs to exist in all future versions. # => The `__resh_preexec` function needs to exist in all future versions.
# => Make sure that `__RESH_NO_RELOAD` behavior is not broken in any future version. # => Make sure that `__RESH_NO_RELOAD` behavior is not broken in any future version.
# => Prefer only testing `__RESH_NO_RELOAD` for emptyness instead of specific value # => Prefer only testing `__RESH_NO_RELOAD` for emptyness instead of specific value
# * `__resh_reload_msg` is called *after* shell files reload
# => The function shows a message from the already updated shell files
# => We can drop this function at any time - the old version will be used
# (pre)collect # (pre)collect
# Backwards compatibilty: Please see notes above before making any changes here. # Backwards compatibilty: Please see notes above before making any changes here.
__resh_preexec() { __resh_preexec() {
# $1 is command line
# $2 can be --no-reload opt
# Backwards compatibity: Do not change -version opt.
# It is called by new shell files to detect version mismatch.
if [ "$(resh-collect -version)" != "$__RESH_VERSION" ] && [ -z "${__RESH_NO_RELOAD-}" ]; then if [ "$(resh-collect -version)" != "$__RESH_VERSION" ] && [ -z "${__RESH_NO_RELOAD-}" ]; then
# Reload shell files and restart __resh_preexec - i.e. the full command will be recorded only with a slight delay. # Reload shell files and restart __resh_preexec - i.e. the full command will be recorded only with a slight delay.
# This should happens in every already open terminal after resh update. # This should happens in every already open terminal after resh update.
# __RESH_NO_RELOAD prevents recursive reloads
# We never repeatadly reload the shell files to prevent potentially infinite recursion.
# If the version is still wrong then error will be raised by `resh-collect -requiredVersion`.
# If for any reason the __RESH_VERSION is still wrong we don't reload again to prevent potentially infinite recursion. source ~/.resh/shellrc
# User will most likely see error because of `resh-collect -requiredVersion`. # Show reload message from the updated shell files
__resh_reload_msg
__resh_reload_shellrc
# Rerun self but prevent another reload. Extra protection against infinite recursion. # Rerun self but prevent another reload. Extra protection against infinite recursion.
__RESH_NO_RELOAD=1 __resh_preexec "$@" __RESH_NO_RELOAD=1 __resh_preexec "$@"
return $? return $?
@ -76,7 +77,9 @@ __resh_precmd() {
# We don't call __resh_precmd because the new __resh_preexec might not be backwards compatible with variables set by old __resh_preexec. # We don't call __resh_precmd because the new __resh_preexec might not be backwards compatible with variables set by old __resh_preexec.
# This should happen only in the one terminal where resh update was executed. # This should happen only in the one terminal where resh update was executed.
# And the resh-daemon was likely restarted so we likely don't even have the matching part1 of the comand in the resh-daemon memory. # And the resh-daemon was likely restarted so we likely don't even have the matching part1 of the comand in the resh-daemon memory.
__resh_reload_shellrc source ~/.resh/shellrc
# Show reload message from the updated shell files
__resh_reload_msg
return return
fi fi
unset __RESH_COLLECT unset __RESH_COLLECT

@ -70,23 +70,6 @@ else
fi fi
fi fi
if [ "$(uname)" = Darwin ] && gnohup --version >/dev/null 2>&1; then
echo " * Nohup installed: OK"
elif nohup --version >/dev/null 2>&1; then
echo " * Nohup installed: OK"
else
echo " * Nohup installed: NOT INSTALLED!"
echo " > You don't have nohup"
echo " > Please install GNU coreutils"
echo
if [ "$(uname)" = Darwin ]; then
echo " $ brew install coreutils"
echo
fi
exit 1
fi
# echo # echo
# echo "Continue with installation? (Any key to CONTINUE / Ctrl+C to ABORT)" # echo "Continue with installation? (Any key to CONTINUE / Ctrl+C to ABORT)"
# # shellcheck disable=2034 # # shellcheck disable=2034
@ -96,7 +79,7 @@ echo "Creating directories ..."
mkdir_if_not_exists() { mkdir_if_not_exists() {
if [ ! -d "$1" ]; then if [ ! -d "$1" ]; then
mkdir "$1" mkdir "$1"
fi fi
} }
@ -153,14 +136,14 @@ if [ ! -f ~/.bashrc ]; then
touch ~/.bashrc touch ~/.bashrc
fi fi
grep -q '[[ -f ~/.resh/shellrc ]] && source ~/.resh/shellrc' ~/.bashrc ||\ grep -q '[[ -f ~/.resh/shellrc ]] && source ~/.resh/shellrc' ~/.bashrc ||\
echo -e '\n[[ -f ~/.resh/shellrc ]] && source ~/.resh/shellrc # this line was added by RESH (Rich Enhanced Shell History)' >> ~/.bashrc echo -e '\n[[ -f ~/.resh/shellrc ]] && source ~/.resh/shellrc # this line was added by RESH (REcycle SHell)' >> ~/.bashrc
# Adding bash-preexec to .bashrc ... # Adding bash-preexec to .bashrc ...
grep -q '[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh' ~/.bashrc ||\ grep -q '[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh' ~/.bashrc ||\
echo -e '\n[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh # this line was added by RESH (Rich Enhanced Shell History)' >> ~/.bashrc echo -e '\n[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh # this line was added by RESH (REcycle SHell)' >> ~/.bashrc
# Adding resh shellrc to .zshrc ... # Adding resh shellrc to .zshrc ...
if [ -f ~/.zshrc ]; then if [ -f ~/.zshrc ]; then
grep -q '[ -f ~/.resh/shellrc ] && source ~/.resh/shellrc' ~/.zshrc ||\ grep -q '[ -f ~/.resh/shellrc ] && source ~/.resh/shellrc' ~/.zshrc ||\
echo -e '\n[ -f ~/.resh/shellrc ] && source ~/.resh/shellrc # this line was added by RESH (Rich Enhanced Shell History)' >> ~/.zshrc echo -e '\n[ -f ~/.resh/shellrc ] && source ~/.resh/shellrc # this line was added by RESH (REcycle SHell)' >> ~/.zshrc
fi fi
# Deleting zsh completion cache - for future use # Deleting zsh completion cache - for future use
@ -176,7 +159,7 @@ info="---- Scroll down using arrow keys ----
# | |_) | _| \___ \| |_| | # # | |_) | _| \___ \| |_| | #
# | _ <| |___ ___) | _ | # # | _ <| |___ ___) | _ | #
# |_| \_\_____|____/|_| |_| # # |_| \_\_____|____/|_| |_| #
# Rich Enhanced Shell History # # REcycle SHell #
##################################### #####################################
" "

Loading…
Cancel
Save