stuff
This commit is contained in:
parent
1eca13960a
commit
1073e803f7
|
|
@ -0,0 +1 @@
|
||||||
|
*.local
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
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
|
||||||
|
mv ~/.bashrc ~/.bashrc.old
|
||||||
|
dir=./library/getdir.sh
|
||||||
|
echo "#!/bin/bash" >> ~/.bashrc
|
||||||
|
echo "$dir/load.sh" >> ~/.bashrc
|
||||||
|
~/.bashrc
|
||||||
|
echo "Qash $QASH_VERSION successfully installed!"
|
||||||
|
fi
|
||||||
|
|
@ -1,16 +1,25 @@
|
||||||
echo "Uptime: $(uptime)"
|
|
||||||
|
|
||||||
# use bash completion
|
# use bash completion
|
||||||
if ! shopt -oq posix; then
|
if [[ $QASH_USE_BASH_COMPLETION ]]; then
|
||||||
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
if ! shopt -oq posix; then
|
||||||
. /usr/share/bash-completion/bash_completion
|
if [ -f /usr/share/bash-completion/bash_completion ]; then
|
||||||
elif [ -f /etc/bash_completion ]; then
|
. /usr/share/bash-completion/bash_completion
|
||||||
. /etc/bash_completion
|
elif [ -f /etc/bash_completion ]; then
|
||||||
|
. /etc/bash_completion
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# helper functions
|
||||||
|
isroot() {
|
||||||
|
if [[ "$EUID" -eq 0 ]]; then
|
||||||
|
echo 1
|
||||||
|
elif
|
||||||
|
echo 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# conditional root aliases
|
# conditional root aliases
|
||||||
if [ "$EUID" -eq 0 ]; then
|
if [[ $isroot ]]; then
|
||||||
alias rm='rm -i'
|
alias rm='rm -i'
|
||||||
alias cp='cp -i'
|
alias cp='cp -i'
|
||||||
alias mv='mv -i'
|
alias mv='mv -i'
|
||||||
|
|
@ -31,6 +40,7 @@ alias gc='git checkout'
|
||||||
alias gp='git push'
|
alias gp='git push'
|
||||||
alias gpr='git pull origin --rebase'
|
alias gpr='git pull origin --rebase'
|
||||||
alias cmt='git commit -m'
|
alias cmt='git commit -m'
|
||||||
|
alias gap="git add -p"
|
||||||
|
|
||||||
# docker compose
|
# docker compose
|
||||||
alias dc='docker compose'
|
alias dc='docker compose'
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
#!/bin/bash
|
||||||
|
if [[ "$PWD" != "$__QASH_LAST_DEADLINE_DIR" ]]; then
|
||||||
|
if [[ -f ".deadline" ]]; then
|
||||||
|
deadline=$(cat .deadline)
|
||||||
|
now=$(date)
|
||||||
|
left=$(getdt $deadline $now)
|
||||||
|
echo -e "\e[5;33mDEADLINE:\e[0m $(cat .deadline), left: $left"
|
||||||
|
fi
|
||||||
|
export __QASH_LAST_DEADLINE_DIR="$PWD"
|
||||||
|
fi
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/bash
|
||||||
|
export PROMPT_COMMAND="$QASH_LIBRARY_DIR/check_deadline; $PROMPT_COMMAND"
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
#!/bin/bash
|
||||||
|
if [[ $# -lt 2 ]]; then
|
||||||
|
echo "Usage: deadline <name> <date> <flash_below>"
|
||||||
|
return -1
|
||||||
|
fi
|
||||||
|
deadline_name=${1:-"THE DEADLINE"}
|
||||||
|
target_date=${2:-"2048-01-01 00:08:00"}
|
||||||
|
stress_below=${3:-14}
|
||||||
|
target_epoch=$(date -d "$target_date" +%s)
|
||||||
|
now_epoch=$(date +%s)
|
||||||
|
remaining_seconds=$((target_epoch - now_epoch))
|
||||||
|
|
||||||
|
if [[ $remaining_seconds -lt 0 ]]; then
|
||||||
|
echo "\033[33mDeadline has passed. Rest in peace.\033[0m"
|
||||||
|
else
|
||||||
|
days=$((remaining_seconds / 86400))
|
||||||
|
hours=$(((remaining_seconds % 86400) / 3600))
|
||||||
|
minutes=$(((remaining_seconds % 3600) / 60))
|
||||||
|
seconds=$((remaining_seconds % 60))
|
||||||
|
|
||||||
|
color="33"
|
||||||
|
if [[ $days -le $stress_below ]]; then
|
||||||
|
color="31"
|
||||||
|
#flash=$((100 - ((days * 100 + 1) / $stress_below)))
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ days -le $stress_below ]]; then
|
||||||
|
printf "\e[${color}m ! DEADLINE SET FOR <%s> (%s)\e[0m\n" "$deadline_name" "$target_date"
|
||||||
|
$QASH_LIBRARY_DIR/stressuser.sh "\e[${color}m ! --- $days:$hours:$minutes:$seconds REMAINING --- \n" $color .48
|
||||||
|
else
|
||||||
|
printf "\e[${color}m\e[5m ! DEADLINE SET FOR <%s> (%s)\e[0m\n" "$deadline_name" "$target_date"
|
||||||
|
printf "\e[0m ! --- roughly $days days remaining, no biggie --- \e[0m\n"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
dir=$(cd "$(dirname "${BASH_SOURCE}")" && pwd)
|
||||||
|
echo "$dir"
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/bash
|
||||||
|
if [[ $# -lt 3 ]]; then
|
||||||
|
echo "Usage: getdt <from> <to> (format)"
|
||||||
|
return -1
|
||||||
|
fi
|
||||||
|
from_date=$1
|
||||||
|
to_date=$2
|
||||||
|
format="%02d days, %02d:%02d:%02d"
|
||||||
|
if [[ $# -gt 3 ]]; then
|
||||||
|
format=$3
|
||||||
|
fi
|
||||||
|
target_epoch=$(date -d "$from_date" +%s)
|
||||||
|
now_epoch=$(date -d "$to_date" +%s)
|
||||||
|
remaining_seconds=$((target_epoch - now_epoch))
|
||||||
|
|
||||||
|
days=$((remaining_seconds / 86400))
|
||||||
|
hours=$(((remaining_seconds % 86400) / 3600))
|
||||||
|
minutes=$(((remaining_seconds % 3600) / 60))
|
||||||
|
seconds=$((remaining_seconds % 60))
|
||||||
|
|
||||||
|
printf "%02d days, %02d:%02d:%02d" $days $hours $minutes $seconds
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/bash
|
||||||
|
$QASH_LIBRARY_DIR/deadline.sh "$(cat $PWD/.git/description)" "$(cat "$PWD"/.deadline)"
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/bash
|
||||||
|
LIBRARY_DIR=$(./getdir.sh)
|
||||||
|
|
||||||
|
export QASH_VERSION='v0.2.1'
|
||||||
|
export QASH_ENABLE_DEADLINE_CHECK=1
|
||||||
|
export QASH_USE_BASH_COMPLETION=1
|
||||||
|
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
|
||||||
|
echo "Enabled deadline check."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -f "~/.bashrc.local" ]]; then
|
||||||
|
source ~/.bashrc.local
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "\e[22mUptime: $(uptime)"
|
||||||
|
echo "\e[16mQrakhen's QASH $QASH_VERSION loaded.\e[0m"
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/bash
|
||||||
|
qash() {
|
||||||
|
if [[ " $@ " == *" --help "* ]]; then
|
||||||
|
echo "There is no helping you."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/bash
|
||||||
|
__cleanup_terminal() {
|
||||||
|
printf '\e[?5l'
|
||||||
|
printf '\e[0m'
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
trap "__cleanup_terminal; return 1" INT
|
||||||
|
text=${1:-"PANIC IS ADVISED"}
|
||||||
|
color=${2:-33}
|
||||||
|
delay=${3:-.48}
|
||||||
|
printf "\e[${color}m$text";
|
||||||
|
while true;
|
||||||
|
do
|
||||||
|
printf '\e[?5h';
|
||||||
|
sleep $delay;
|
||||||
|
printf '\e[?5l';
|
||||||
|
read -s -n1 -t1 && break;
|
||||||
|
done;
|
||||||
|
__cleanup_terminal
|
||||||
|
|
||||||
Loading…
Reference in New Issue