From 336b20e3e2d70b6cc781b7171a3c9d86291d19f5 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Fri, 9 Feb 2024 09:32:28 -0500 Subject: [PATCH] Add undelete function for git to shell_aliases. Also add a little system info to sofi. --- fake_home/.shell_aliases | 20 ++++++++++++++++++++ fake_home/.sofi-preview.sh | 7 +++++++ fake_home/.sofi.sh | 8 ++++++++ 3 files changed, 35 insertions(+) diff --git a/fake_home/.shell_aliases b/fake_home/.shell_aliases index faffa6e..50ecf3d 100755 --- a/fake_home/.shell_aliases +++ b/fake_home/.shell_aliases @@ -74,6 +74,26 @@ function kubelog { kubectl logs -f "$pod" } +function undelete { + local filename="$1" + if test -f "$filename"; then + echo "File already exists!" + exit 1 + fi + + # Get all commit hashes for this file + # Presumably, the one that deleted it was the most recent one :D + local hashes="$(git log --all --format=format:%H -- "$filename" | head -n 2)" + if [[ "$(echo $hashes | wc -l)" != "2" ]]; then + echo "Expected at least two commits relating to this file!" + exit 1 + fi + + # Checkout the file from the commit before it was deleted + local hash="$(echo $hashes | tail -n 1)" + git checkout $hash -- $filename +} + alias j='journalctl -xefu' alias hsearch='hearch' alias d='docker' diff --git a/fake_home/.sofi-preview.sh b/fake_home/.sofi-preview.sh index b26cde4..7363e2b 100755 --- a/fake_home/.sofi-preview.sh +++ b/fake_home/.sofi-preview.sh @@ -37,6 +37,13 @@ case $choice in echo "" exit 0 ;; + inf*) + date + echo + free -h + echo + df -h | grep '/dev\|Filesystem' + ;; *) qarg="$(echo "$query_string" | cut -c 5-)" diff --git a/fake_home/.sofi.sh b/fake_home/.sofi.sh index a63923c..28420c4 100755 --- a/fake_home/.sofi.sh +++ b/fake_home/.sofi.sh @@ -88,8 +88,13 @@ paste_emoji() { nohup xclip -selection clipboard <(echo -n $emoji) &> /dev/null & } +system_info() { + echo "inf $(date)" +} + if [[ "$1" == "--print-only" ]]; then cat \ + <(system_info) \ <(windows) \ <($HOME/.rofi-list-git-repos.py --no-icon) \ <(read_apps) \ @@ -100,6 +105,7 @@ if [[ "$1" == "--print-only" ]]; then fi choice="$(cat \ + <(system_info) \ <(windows) \ <("$HOME/.rofi-list-git-repos.py") \ <(read_apps) \ @@ -161,6 +167,8 @@ case $choice in setsid xdg-open "$(echo $choice | cut -c 5- | sed "s@~@$HOME@")" &> /dev/null & ;; + time*) + ;; *) case $qstring in mvn*)