From 3e03f4a0d2680be01dd646c7a8d96d1c580a4080 Mon Sep 17 00:00:00 2001 From: Simon Let Date: Sun, 8 Jan 2023 21:35:52 +0100 Subject: [PATCH] Rebrand to 'REcycle SHell', show 'future' update messages, changes --- scripts/hooks.sh | 25 ++++++++++++++----------- scripts/install.sh | 27 +++++---------------------- 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/scripts/hooks.sh b/scripts/hooks.sh index e639838..4e8616a 100644 --- a/scripts/hooks.sh +++ b/scripts/hooks.sh @@ -1,7 +1,6 @@ #!/hint/sh -__resh_reload_shellrc() { - source ~/.resh/shellrc +__resh_reload_msg() { printf '\n' printf '+--------------------------------------------------------------+\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. # => 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 +# * `__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 # Backwards compatibilty: Please see notes above before making any changes here. __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 # 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. + # __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. - # User will most likely see error because of `resh-collect -requiredVersion`. - - __resh_reload_shellrc + source ~/.resh/shellrc + # Show reload message from the updated shell files + __resh_reload_msg # Rerun self but prevent another reload. Extra protection against infinite recursion. __RESH_NO_RELOAD=1 __resh_preexec "$@" 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. # 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. - __resh_reload_shellrc + source ~/.resh/shellrc + # Show reload message from the updated shell files + __resh_reload_msg return fi unset __RESH_COLLECT diff --git a/scripts/install.sh b/scripts/install.sh index 290b845..6b6b725 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -70,23 +70,6 @@ else 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 "Continue with installation? (Any key to CONTINUE / Ctrl+C to ABORT)" # # shellcheck disable=2034 @@ -96,7 +79,7 @@ echo "Creating directories ..." mkdir_if_not_exists() { if [ ! -d "$1" ]; then - mkdir "$1" + mkdir "$1" fi } @@ -153,14 +136,14 @@ if [ ! -f ~/.bashrc ]; then touch ~/.bashrc fi 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 ... 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 ... if [ -f ~/.zshrc ]; then 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 # Deleting zsh completion cache - for future use @@ -176,7 +159,7 @@ info="---- Scroll down using arrow keys ---- # | |_) | _| \___ \| |_| | # # | _ <| |___ ___) | _ | # # |_| \_\_____|____/|_| |_| # -# Rich Enhanced Shell History # +# REcycle SHell # ##################################### "