diff --git a/install.sh b/install.sh index f75bda4..5bc4707 100644 --- a/install.sh +++ b/install.sh @@ -2,11 +2,38 @@ read -p "Do you want to install Qash? This will move your old .bashrc and replace it with Qash. y/N " -if [[ $REPLY -eq 'y' ]]; then +if [[ $REPLY == 'y' ]]; then + dir=~/qash/ + if [[ $# -gt 1 ]]; then + dir=$1 + fi + echo "Installing Qash in $dir..." + + echo "Copying files..." + if [[ -d $dir ]]; then + read -p "$dir already exists. Proceed to remove it including all of its contents? y/N " + if [[ $REPLY == 'y' ]]; then + rm -rf $dir + else + echo "Installation cancelled." + exit 1 + fi + fi + mkdir -p "$dir/hooks" + cp -r ./library/* $dir + cp -r ./library/hooks/* $dir/hooks/ + + echo "Backing up old .bashrc..." mv ~/.bashrc ~/.bashrc.old - dir=./library/getdir.sh + source ./library/load.sh echo "#!/bin/bash" >> ~/.bashrc - echo "$dir/load.sh" >> ~/.bashrc - ~/.bashrc - echo "Qash $QASH_VERSION successfully installed!" -fi \ No newline at end of file + echo "# Qash $QASH_VERSION" >> ~/.bashrc + echo "# Installed on $(date -u +'%02d.%02m.%Y %02H:%02M:%02S')" >> ~/.bashrc + echo "" >> ~/.bashrc + echo "source $QASH_LIBRARY_DIR/load.sh" >> ~/.bashrc + printf "\e[35mQash $QASH_VERSION successfully installed!\e[0m" + exit 1 +fi + +echo "Installation cancelled." +exit 1 \ No newline at end of file diff --git a/library/aliases.sh b/library/aliases.sh index 9f07b9b..a10607c 100644 --- a/library/aliases.sh +++ b/library/aliases.sh @@ -11,11 +11,11 @@ fi # helper functions isroot() { - if [[ "$EUID" -eq 0 ]]; then - echo 1 - elif - echo 0 - fi + if [[ "$EUID" -eq 0 ]]; then + echo 1 + else + echo 0 + fi } # conditional root aliases diff --git a/library/deadline.listen.sh b/library/deadline.listen.sh index aab4271..982068f 100644 --- a/library/deadline.listen.sh +++ b/library/deadline.listen.sh @@ -1,2 +1,2 @@ #!/bin/bash -export PROMPT_COMMAND="$QASH_LIBRARY_DIR/check_deadline; $PROMPT_COMMAND" \ No newline at end of file +export PROMPT_COMMAND="$QASH_LIBRARY_DIR/deadline.check.sh; $PROMPT_COMMAND" \ No newline at end of file diff --git a/library/getdir.sh b/library/getdir.sh deleted file mode 100644 index 15512e7..0000000 --- a/library/getdir.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -dir=$(cd "$(dirname "${BASH_SOURCE}")" && pwd) -echo "$dir" diff --git a/library/load.sh b/library/load.sh index 25f5755..8cfd0b6 100644 --- a/library/load.sh +++ b/library/load.sh @@ -1,5 +1,5 @@ #!/bin/bash -LIBRARY_DIR=$(./getdir.sh) +LIBRARY_DIR=$(cd "$(dirname "${BASH_SOURCE}")" && pwd) export QASH_VERSION='v0.2.1' export QASH_ENABLE_DEADLINE_CHECK=1 @@ -9,14 +9,14 @@ export QASH_LIBRARY_DIR="$LIBRARY_DIR" source "$LIBRARY_DIR/aliases.sh" source "$LIBRARY_DIR/qash.sh" -if [[ $QASH_ENABLE_DEADLINE_CHECK ]]; then - $LIBRARY_DIR/check_deadline.sh +if [[ $QASH_ENABLE_DEADLINE_CHECK == 1 ]]; then + $LIBRARY_DIR/deadline.listen.sh echo "Enabled deadline check." fi -if [[ -f "~/.bashrc.local" ]]; then +if [[ -f ~/.bashrc.local ]]; then source ~/.bashrc.local fi -echo "\e[22mUptime: $(uptime)" -echo "\e[16mQrakhen's QASH $QASH_VERSION loaded.\e[0m" \ No newline at end of file +printf "\e[34mUptime: $(uptime)\n" +printf "\e[32mQrakhen's QASH %s loaded.\e[0m\n" $QASH_VERSION \ No newline at end of file diff --git a/library/stressuser.sh b/library/stressuser.sh index 1cf6180..ac25b4a 100644 --- a/library/stressuser.sh +++ b/library/stressuser.sh @@ -1,11 +1,11 @@ #!/bin/bash -__cleanup_terminal() { +resetmods() { printf '\e[?5l' printf '\e[0m' return -1 } -trap "__cleanup_terminal; return 1" INT +trap "resetmods; return 1" INT text=${1:-"PANIC IS ADVISED"} color=${2:-33} delay=${3:-.48} @@ -17,5 +17,6 @@ do printf '\e[?5l'; read -s -n1 -t1 && break; done; -__cleanup_terminal + +resetmods