Compare commits

...

2 commits

2 changed files with 41 additions and 0 deletions

38
.local/bin/scripts/shutdown.sh Executable file
View file

@ -0,0 +1,38 @@
#!/bin/bash
# Confirm that we want to shutdown without https://git.vlw.se/pastebin/history
if [ ! -d "$XDG_DATA_HOME/history" ] ; then
read -p "No history directory found at '$XDG_DATA_HOME/history'. Command history will not be saved. Answer 'y' to shutdown anyways: " confirm
if [ "$confirm" != "y" ]; then
echo "Shutdown aborted"
exit
fi
# Shut down the system
sudo poweroff
exit
fi
if [ ! -f "$HOME/.bash_history" ]; then
echo "No '.bash_history' file found"
exit 1
fi
file="$(date +"%Y-%m-%dT%H-%M-%S")-$(hostname).zip"
# Move into history directory
cd $XDG_DATA_HOME/history
# Zip .bash_history file with maximum compression
zip -9 $file $HOME/.bash_history
# Add the file to git and upload to remote
git add $file
git -c commit.gpgsign=false commit -m "add($(hostname)): '$file'"
git push origin master
# Empty the .bash_history file for next session
: > $HOME/.bash_history
# Shut down the system
sudo poweroff

View file

@ -15,3 +15,6 @@ code-extensions:
# Install dev programs and configuration files
programs:
~/.local/bin/scripts/install_programs.sh
shutdown:
~/.local/bin/scripts/shutdown.sh