From d70ce29d7d49df9abce3998f5993eaf4d6160183 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sun, 21 Jul 2024 11:49:28 -0400 Subject: [PATCH 01/10] Fewer hard-coded paths. Disable nvm in bashrc for now. --- fake_home/.bashrc | 6 ++-- .../Roaming/Balatro/Mods/EscapeExitButton.lua | 31 ------------------- fake_home/.shell_aliases | 12 +++++-- fake_home/.zshrc | 7 +++-- 4 files changed, 18 insertions(+), 38 deletions(-) delete mode 100644 fake_home/.local/share/Steam/steamapps/compatdata/2379780/pfx/drive_c/users/steamuser/AppData/Roaming/Balatro/Mods/EscapeExitButton.lua diff --git a/fake_home/.bashrc b/fake_home/.bashrc index 7e755db..badb4f4 100644 --- a/fake_home/.bashrc +++ b/fake_home/.bashrc @@ -142,6 +142,6 @@ ex () source ~/.shell_aliases . "$HOME/.cargo/env" -export NVM_DIR="$HOME/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm -[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion +# export NVM_DIR="$HOME/.nvm" +# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +# [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion diff --git a/fake_home/.local/share/Steam/steamapps/compatdata/2379780/pfx/drive_c/users/steamuser/AppData/Roaming/Balatro/Mods/EscapeExitButton.lua b/fake_home/.local/share/Steam/steamapps/compatdata/2379780/pfx/drive_c/users/steamuser/AppData/Roaming/Balatro/Mods/EscapeExitButton.lua deleted file mode 100644 index 558a695..0000000 --- a/fake_home/.local/share/Steam/steamapps/compatdata/2379780/pfx/drive_c/users/steamuser/AppData/Roaming/Balatro/Mods/EscapeExitButton.lua +++ /dev/null @@ -1,31 +0,0 @@ ---- STEAMODDED HEADER ---- MOD_NAME: Escape Exit Button ---- MOD_ID: EscapeExitButton ---- MOD_AUTHOR: [Steamo] ---- MOD_DESCRIPTION: Add an "Exit" button into the "Escape" menu - ----------------------------------------------- -------------MOD CODE ------------------------- - -function G.FUNCS.exit_button(arg_736_0) - G.SETTINGS.paused = true - - love.event.quit() -end - -local createOptionsRef = create_UIBox_options -function create_UIBox_options() - contents = createOptionsRef() - local exit_button = UIBox_button({ - minw = 5, - button = "exit_button", - label = { - "Exit Game" - } - }) - table.insert(contents.nodes[1].nodes[1].nodes[1].nodes, #contents.nodes[1].nodes[1].nodes[1].nodes + 1, exit_button) - return contents -end - ----------------------------------------------- -------------MOD CODE END---------------------- diff --git a/fake_home/.shell_aliases b/fake_home/.shell_aliases index 99cfb2b..6e0aec0 100755 --- a/fake_home/.shell_aliases +++ b/fake_home/.shell_aliases @@ -206,7 +206,11 @@ function wf { if [[ "$@" != "" ]]; then local fzf_args="-q $@" fi - echo ~/wiki/"$(rg --with-filename --no-heading . ~/wiki | sed 's@/home/sage/wiki/@@' | fzf -i $fzf_args -1 --preview='bat ~/wiki/$(echo {} | sed "s/:.*//")' | sed 's/:.*//')" + local wiki_dir="$HOME/wiki/" + if [[ "$WIKI_DIR" != "" ]]; then + wiki_dir="$WIKI_DIR" + fi + echo $wiki_dir/"$(rg --with-filename --no-heading . "$wiki_dir" | sed "s@$wiki_dir@@" | fzf -i $fzf_args -1 --preview="bat $wiki_dir/\$(echo {} | sed 's/:.*//')" | sed 's/:.*//')" } function ws { @@ -217,7 +221,11 @@ function ws { } function ww { - ws $(rg --no-line-number --no-filename . ~/wiki | sed 's/[^a-zA-Z0-9]\+/\n/g' | grep -v "^$" | sort -f | uniq -ci | sort -hr | fzf -i | cut -c 9-) + local wiki_dir="$HOME/wiki/" + if [[ "$WIKI_DIR" != "" ]]; then + wiki_dir="$WIKI_DIR" + fi + ws $(rg --no-line-number --no-filename . "$wiki_dir" | sed 's/[^a-zA-Z0-9]\+/\n/g' | grep -v "^$" | sort -f | uniq -ci | sort -hr | fzf -i | cut -c 9-) } if command -v bat &> /dev/null; then diff --git a/fake_home/.zshrc b/fake_home/.zshrc index 5555443..8f84b1f 100644 --- a/fake_home/.zshrc +++ b/fake_home/.zshrc @@ -148,15 +148,18 @@ function merge-hist { } function sync-history { + echo "Downloading shared history..." if ! scp -P 11275 'sage@sagev.space:~/histfile' "$HOME/.tmp/.histfile"; then + echo "Shared history download failed!" scp -P 11275 "$HOME/.histfile" 'sage@sagev.space:~/histfile' return fi fc -W # Write to history file merge-hist "$HOME/.histfile" "$HOME/.tmp/.histfile" > "$HOME/.tmp/$(whoami).histfile" mv "$HOME/.tmp/$(whoami).histfile" "$HOME/.histfile" - scp -P 11275 "$HOME/.histfile" 'sage@sagev.space:~/histfile' fc -R # Read from new history file + echo "Uploading new shared history..." + scp -P 11275 "$HOME/.histfile" 'sage@sagev.space:~/histfile' } function install-extension { @@ -294,7 +297,7 @@ test -f "$HOME/.asdf/asdf.sh" && . "$HOME/.asdf/asdf.sh" test -f ~/.cargo/env && source ~/.cargo/env # bun completions -[ -s "/home/sage/.bun/_bun" ] && source "/home/sage/.bun/_bun" +[ -s "$HOME/.bun/_bun" ] && source "$HOME/.bun/_bun" # bun export BUN_INSTALL="$HOME/.bun" From 68dce8e4192780c019a1dcd4ed53a63a9362e3ad Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sun, 21 Jul 2024 11:58:03 -0400 Subject: [PATCH 02/10] Only dotsync on the first login of the day --- fake_home/.zlogin | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fake_home/.zlogin b/fake_home/.zlogin index 17ae67d..c88cf04 100644 --- a/fake_home/.zlogin +++ b/fake_home/.zlogin @@ -1,3 +1,11 @@ date >> "$HOME/.tmp/getdot-log" echo "~/zlogin, babyyy" >> "$HOME/.tmp/getdot-log" -RUN_GETDOT="true" GETDOT_ARGS="--skip-dconf" source "$HOME/.zshrc" + +LOGIN_SYNC_DATE="$HOME/.bin/.login-dot-sync" + +touch $LOGIN_SYNC_DATE +current_date="$(date '+%D')" +if [[ "$current_date" != "$(cat "$LOGIN_SYNC_DATE")" ]]; then + RUN_GETDOT="true" GETDOT_ARGS="--skip-dconf" source "$HOME/.zshrc" +fi +echo "$current_date" > "$LOGIN_SYNC_DATE" From 04614599f5fd91eca54e458acb674d86723080c6 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sun, 21 Jul 2024 12:17:17 -0400 Subject: [PATCH 03/10] Correct full-pull-only-once login logic Problem was that $current_date was overridden during the `source .zshrc` call. --- fake_home/.zlogin | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/fake_home/.zlogin b/fake_home/.zlogin index c88cf04..08e5ac7 100644 --- a/fake_home/.zlogin +++ b/fake_home/.zlogin @@ -1,11 +1,17 @@ -date >> "$HOME/.tmp/getdot-log" -echo "~/zlogin, babyyy" >> "$HOME/.tmp/getdot-log" +logfile="$HOME/.tmp/getdot-log" +# date >> "$logfile" +# echo "~/zlogin, babyyy" >> "$logfile" LOGIN_SYNC_DATE="$HOME/.bin/.login-dot-sync" touch $LOGIN_SYNC_DATE -current_date="$(date '+%D')" -if [[ "$current_date" != "$(cat "$LOGIN_SYNC_DATE")" ]]; then +login_sync_date="$(date '+%D')" +logged_date="$(cat "$LOGIN_SYNC_DATE")" + +if [[ "$login_sync_date" == "$logged_date" ]]; then + GETDOT_ARGS="--skip-dconf" source "$HOME/.zshrc" +else RUN_GETDOT="true" GETDOT_ARGS="--skip-dconf" source "$HOME/.zshrc" fi -echo "$current_date" > "$LOGIN_SYNC_DATE" + +echo "$login_sync_date" > "$LOGIN_SYNC_DATE" From dd6caf8f53fbde452429b27b52cbe0caa6796862 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sun, 21 Jul 2024 12:19:10 -0400 Subject: [PATCH 04/10] History merge note --- fake_home/.zshrc | 1 + 1 file changed, 1 insertion(+) diff --git a/fake_home/.zshrc b/fake_home/.zshrc index 8f84b1f..c74f5e0 100644 --- a/fake_home/.zshrc +++ b/fake_home/.zshrc @@ -154,6 +154,7 @@ function sync-history { scp -P 11275 "$HOME/.histfile" 'sage@sagev.space:~/histfile' return fi + echo "Merging history files..." fc -W # Write to history file merge-hist "$HOME/.histfile" "$HOME/.tmp/.histfile" > "$HOME/.tmp/$(whoami).histfile" mv "$HOME/.tmp/$(whoami).histfile" "$HOME/.histfile" From cb2185ab3eccf866422a384928e86b4519c36a8f Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sun, 21 Jul 2024 12:24:26 -0400 Subject: [PATCH 05/10] Add a little lockfile for pushdot --- fake_home/.zshrc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/fake_home/.zshrc b/fake_home/.zshrc index c74f5e0..6197d64 100644 --- a/fake_home/.zshrc +++ b/fake_home/.zshrc @@ -75,6 +75,8 @@ fi source ~/.shell_aliases source ~/.zsh_local +SYNC_LOCK_FILE="$HOME/.sync-lock" + # Ignores certain values/sections that shouldn't be synced function dconf-clean { local current_section="" @@ -203,6 +205,17 @@ function load-extensions { function pushdot { cd "$DOT_DIR" || return 1 + if test -f "$SYNC_LOCK_FILE"; then + echo "Sync lockfile present at '$SYNC_LOCK_FILE'" + echo "Waiting for ongoing sync to finish" + for i in {0..60}; do + sleep 1 + if ! test -f "$SYNC_LOCK_FILE"; then + break + fi + done + fi + touch "$SYNC_LOCK_FILE" local res if ! git diff --quiet; then if [ $# -eq 0 ]; then @@ -220,6 +233,7 @@ function pushdot { sync-history push-dconf cd - + rm "$SYNC_LOCK_FILE" return $res } From 82e05fc3338f50fb4bf5a116c369e60e9bc9bd95 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sun, 21 Jul 2024 12:28:35 -0400 Subject: [PATCH 06/10] Share lock with getdot --- fake_home/.zshrc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fake_home/.zshrc b/fake_home/.zshrc index 6197d64..b5e030b 100644 --- a/fake_home/.zshrc +++ b/fake_home/.zshrc @@ -203,8 +203,7 @@ function load-extensions { done } -function pushdot { - cd "$DOT_DIR" || return 1 +function dot-lock-wait { if test -f "$SYNC_LOCK_FILE"; then echo "Sync lockfile present at '$SYNC_LOCK_FILE'" echo "Waiting for ongoing sync to finish" @@ -215,7 +214,12 @@ function pushdot { fi done fi - touch "$SYNC_LOCK_FILE" +} + +function pushdot { + cd "$DOT_DIR" || return 1 + dot-lock-wait + echo "$$" > "$SYNC_LOCK_FILE" local res if ! git diff --quiet; then if [ $# -eq 0 ]; then @@ -264,6 +268,7 @@ function getdot { echo "An alias for scpace has not been defined on this device!" return 1 fi + dot-lock-wait cd "$DOT_DIR" || return 1 git pull && ./copy.sh From 01b5af233fb3365dde2cd11f7fb138de1539d3a2 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sun, 21 Jul 2024 12:53:33 -0400 Subject: [PATCH 07/10] More generic "lockfor" system --- fake_home/.zshrc | 53 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/fake_home/.zshrc b/fake_home/.zshrc index b5e030b..7336871 100644 --- a/fake_home/.zshrc +++ b/fake_home/.zshrc @@ -203,23 +203,47 @@ function load-extensions { done } -function dot-lock-wait { - if test -f "$SYNC_LOCK_FILE"; then - echo "Sync lockfile present at '$SYNC_LOCK_FILE'" - echo "Waiting for ongoing sync to finish" - for i in {0..60}; do +function lock-wait { + local file="$1" + local seconds="$2" + local action="$3" + + if test -f "$file"; then + echo "Sync lockfile present at '$file'" + echo "Watching its output:" + tail -f "$file" & + tail_pid=$! + [[ "$action" == "" ]] || echo "Waiting for $action to finish" + for i in {0..$seconds}; do sleep 1 - if ! test -f "$SYNC_LOCK_FILE"; then + if ! test -f "$file"; then + kill $tail_pid &> /dev/null + echo + echo "Lock file at '$file' freed." + echo break fi done fi } -function pushdot { +function lockfor { + local file="$1" + local seconds="$2" + + lock-wait "$file" "$seconds" + touch "$file" + $3 $4 $5 $6 $7 $8 $9 $10 | tee -a "$file" + rm "$file" +} + + +function dot-lock-wait { + lock-wait "$SYNC_LOCK_FILE" 90 "Waiting for ongoing sync to finish" +} + +function _pushdot { cd "$DOT_DIR" || return 1 - dot-lock-wait - echo "$$" > "$SYNC_LOCK_FILE" local res if ! git diff --quiet; then if [ $# -eq 0 ]; then @@ -237,10 +261,13 @@ function pushdot { sync-history push-dconf cd - - rm "$SYNC_LOCK_FILE" return $res } +function pushdot { + lockfor "$SYNC_LOCK_FILE" 90 _pushdot $@ +} + function sync-dconf { if ! command -v dconf &> /dev/null; then echo "System does not use dconf" @@ -263,7 +290,7 @@ function sync-dconf { push-dconf } -function getdot { +function _getdot { if ! command -v scpace &> /dev/null; then echo "An alias for scpace has not been defined on this device!" return 1 @@ -279,6 +306,10 @@ function getdot { cd - > /dev/null } +function getdot { + lockfor "$SYNC_LOCK_FILE" 90 _getdot $@ +} + if which starship &> /dev/null; then eval "$(starship init zsh)" fi From 8fb076931d30c88e99d52870df946b29b32f78d8 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sun, 21 Jul 2024 12:59:33 -0400 Subject: [PATCH 08/10] Don't tee *everything* It gets real sloppy when vim or similarly noisy outputs are captured --- fake_home/.zshrc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fake_home/.zshrc b/fake_home/.zshrc index 7336871..0b25377 100644 --- a/fake_home/.zshrc +++ b/fake_home/.zshrc @@ -233,7 +233,7 @@ function lockfor { lock-wait "$file" "$seconds" touch "$file" - $3 $4 $5 $6 $7 $8 $9 $10 | tee -a "$file" + $3 $4 $5 $6 $7 $8 $9 $10 rm "$file" } @@ -257,9 +257,9 @@ function _pushdot { git push -u origin main fi fi - push-extensions - sync-history - push-dconf + push-extensions | tee -a "$SYNC_LOCK_FILE" + sync-history | tee -a "$SYNC_LOCK_FILE" + push-dconf | tee -a "$SYNC_LOCK_FILE" cd - return $res } @@ -297,11 +297,11 @@ function _getdot { fi dot-lock-wait cd "$DOT_DIR" || return 1 - git pull && ./copy.sh + git pull && ./copy.sh | tee -a "$SYNC_LOCK_FILE" - sync-history - load-extensions - [[ "$1" != "--skip-dconf" ]] && sync-dconf + sync-history | tee -a "$SYNC_LOCK_FILE" + load-extensions | tee -a "$SYNC_LOCK_FILE" + [[ "$1" != "--skip-dconf" ]] && sync-dconf | tee -a "$SYNC_LOCK_FILE" cd - > /dev/null } From 1567a6328fc8931a3873c9fbc05b9377a55d155a Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sun, 21 Jul 2024 13:01:59 -0400 Subject: [PATCH 09/10] Message cleanup --- fake_home/.zshrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fake_home/.zshrc b/fake_home/.zshrc index 0b25377..3a08ad7 100644 --- a/fake_home/.zshrc +++ b/fake_home/.zshrc @@ -239,7 +239,7 @@ function lockfor { function dot-lock-wait { - lock-wait "$SYNC_LOCK_FILE" 90 "Waiting for ongoing sync to finish" + lock-wait "$SYNC_LOCK_FILE" 90 "ongoing sync" } function _pushdot { From fbe73364804b65667298e93551597a68ce8ef134 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Sun, 21 Jul 2024 13:03:19 -0400 Subject: [PATCH 10/10] Remove double spinlock --- fake_home/.zshrc | 1 - 1 file changed, 1 deletion(-) diff --git a/fake_home/.zshrc b/fake_home/.zshrc index 3a08ad7..00b5580 100644 --- a/fake_home/.zshrc +++ b/fake_home/.zshrc @@ -295,7 +295,6 @@ function _getdot { echo "An alias for scpace has not been defined on this device!" return 1 fi - dot-lock-wait cd "$DOT_DIR" || return 1 git pull && ./copy.sh | tee -a "$SYNC_LOCK_FILE"