Browse Source

miaou-bash helper function

main
pvincent 2 weeks ago
parent
commit
842df43206
  1. 5
      bin/miaou-bash
  2. 14
      etc/bash.bashrc
  3. 2
      etc/bash_completion.d/miaou-bash.complete
  4. 7
      lib/initiate.bash
  5. 5
      lib/self-upgrade.bash
  6. 2
      lib/uninstall.bash

5
bin/miaou-bash

@ -608,7 +608,7 @@ function cleanup {
}
function usage {
echo "$(basename "$0") <SCRIPT> [...SCRIPT_ARGS] | --version | --help | --self-upgrade | --uninstall"
echo "$(basename "$0") <SCRIPT> [...SCRIPT_ARGS] | --help | --self-upgrade | --uninstall | --version"
}
function version {
@ -688,12 +688,11 @@ else
miaou_debug "<main file=$BASH_ARGV0 pid=${BASHPID}/>"
fi
# shellcheck source=/dev/null
if [[ "$HEREDOC" == true ]]; then
miaou_debug '<source heredoc/>'
# shellcheck source=/dev/stdin
source /dev/stdin
else
miaou_debug "<source script=$SCRIPT/>"
# shellcheck source=/dev/null
source "$SCRIPT"
fi

14
etc/bash.bashrc

@ -202,11 +202,21 @@ alias egrep='egrep $COLOR_OPTIONS '
alias transfer_cp='rsync -a --info=progress2 --no-inc-recursive'
alias ssu='ss -tupn'
# OVERRIDDEN ALIASES
# shellcheck disable=SC1090,SC1091
# shellcheck source=/dev/null
[[ -f "/etc/bash.aliases" ]] && source "/etc/bash.aliases"
# shellcheck disable=SC1090,SC1091
# shellcheck source=/dev/null
[[ -f "$HOME/.bash_aliases" ]] && source "$HOME/.bash_aliases"
# the miaou-bash helper function
function miaou-bash {
if "$MIAOU_BASH_DIR"/bin/miaou-bash "$@"; then
if [[ "${1:-}" =~ --self-upgrade|--uninstall ]]; then
echo 'reloading session now!'
exec bash -l
fi
fi
}
# BASH COMPLETIONS
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then

2
etc/bash_completion.d/miaou-bash.complete

@ -2,7 +2,7 @@ function _miaou_bash {
local cur="${COMP_WORDS[COMP_CWORD]}"
if ((COMP_CWORD == 1)); then
if [[ $cur =~ ^- ]]; then
compopt -o nospace
# compopt -o nospace
mapfile -t COMPREPLY < <(compgen -W "--self-upgrade --version --help --uninstall" -- "$cur")
else
compopt -o filenames

7
lib/initiate.bash

@ -227,12 +227,6 @@ function apply_mode {
fi
}
function reload {
[[ $- == *i* ]] && bind -f /etc/inputrc >/dev/null
# shellcheck source=/dev/null
source /etc/bash.bashrc
}
# MAIN
source "$MIAOU_BASH_DIR"/lib/functions.bash
@ -249,4 +243,3 @@ create_sudoers
fetch_mode
apply_mode
launch_hooks
reload

5
lib/self-upgrade.bash

@ -61,14 +61,11 @@ function perform_upgrade {
sudo miaou-bash "$MIAOU_BASH_DIR"/lib/initiate.bash
fi
sudo rm -rf "$backup"
cat <<EOF
To reset this session, you can run:
exec bash -l
EOF
else
echo "ERROR: trouble during self-upgrade: revert back"
sudo rm -rf "$MIAOU_BASH_DIR"
sudo mv "$backup" "$MIAOU_BASH_DIR"
builtin exit 99
fi
}

2
lib/uninstall.bash

@ -32,8 +32,6 @@ function uninstall {
cat <<EOF
MIAOU-BASH succesfully uninstalled.
Previous settings have been restored from original.
To reset this session, you can run:
exec bash -l
EOF
}

Loading…
Cancel
Save