This commit is contained in:
Sage Vaillancourt 2024-07-24 09:43:42 -04:00
commit 2859a8daa5
5 changed files with 94 additions and 50 deletions

View File

@ -142,6 +142,6 @@ ex ()
source ~/.shell_aliases source ~/.shell_aliases
. "$HOME/.cargo/env" . "$HOME/.cargo/env"
export NVM_DIR="$HOME/.nvm" # export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads 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 # [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

View File

@ -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----------------------

View File

@ -219,7 +219,11 @@ function wf {
if [[ "$@" != "" ]]; then if [[ "$@" != "" ]]; then
local fzf_args="-q $@" local fzf_args="-q $@"
fi 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 { function ws {
@ -230,7 +234,11 @@ function ws {
} }
function ww { 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 if command -v bat &> /dev/null; then

View File

@ -1,3 +1,17 @@
date >> "$HOME/.tmp/getdot-log" logfile="$HOME/.tmp/getdot-log"
echo "~/zlogin, babyyy" >> "$HOME/.tmp/getdot-log" # date >> "$logfile"
RUN_GETDOT="true" GETDOT_ARGS="--skip-dconf" source "$HOME/.zshrc" # echo "~/zlogin, babyyy" >> "$logfile"
LOGIN_SYNC_DATE="$HOME/.bin/.login-dot-sync"
touch $LOGIN_SYNC_DATE
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 "$login_sync_date" > "$LOGIN_SYNC_DATE"

View File

@ -75,6 +75,8 @@ fi
source ~/.shell_aliases source ~/.shell_aliases
source ~/.zsh_local source ~/.zsh_local
SYNC_LOCK_FILE="$HOME/.sync-lock"
# Ignores certain values/sections that shouldn't be synced # Ignores certain values/sections that shouldn't be synced
function dconf-clean { function dconf-clean {
local current_section="" local current_section=""
@ -148,15 +150,19 @@ function merge-hist {
} }
function sync-history { function sync-history {
echo "Downloading shared history..."
if ! scp -P 11275 'sage@sagev.space:~/histfile' "$HOME/.tmp/.histfile"; then 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' scp -P 11275 "$HOME/.histfile" 'sage@sagev.space:~/histfile'
return return
fi fi
echo "Merging history files..."
fc -W # Write to history file fc -W # Write to history file
merge-hist "$HOME/.histfile" "$HOME/.tmp/.histfile" > "$HOME/.tmp/$(whoami).histfile" merge-hist "$HOME/.histfile" "$HOME/.tmp/.histfile" > "$HOME/.tmp/$(whoami).histfile"
mv "$HOME/.tmp/$(whoami).histfile" "$HOME/.histfile" mv "$HOME/.tmp/$(whoami).histfile" "$HOME/.histfile"
scp -P 11275 "$HOME/.histfile" 'sage@sagev.space:~/histfile'
fc -R # Read from new history file fc -R # Read from new history file
echo "Uploading new shared history..."
scp -P 11275 "$HOME/.histfile" 'sage@sagev.space:~/histfile'
} }
function install-extension { function install-extension {
@ -197,7 +203,46 @@ function load-extensions {
done done
} }
function pushdot { 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 "$file"; then
kill $tail_pid &> /dev/null
echo
echo "Lock file at '$file' freed."
echo
break
fi
done
fi
}
function lockfor {
local file="$1"
local seconds="$2"
lock-wait "$file" "$seconds"
touch "$file"
$3 $4 $5 $6 $7 $8 $9 $10
rm "$file"
}
function dot-lock-wait {
lock-wait "$SYNC_LOCK_FILE" 90 "ongoing sync"
}
function _pushdot {
cd "$DOT_DIR" || return 1 cd "$DOT_DIR" || return 1
local res local res
if ! git diff --quiet; then if ! git diff --quiet; then
@ -212,13 +257,17 @@ function pushdot {
git push -u origin main git push -u origin main
fi fi
fi fi
push-extensions push-extensions | tee -a "$SYNC_LOCK_FILE"
sync-history sync-history | tee -a "$SYNC_LOCK_FILE"
push-dconf push-dconf | tee -a "$SYNC_LOCK_FILE"
cd - cd -
return $res return $res
} }
function pushdot {
lockfor "$SYNC_LOCK_FILE" 90 _pushdot $@
}
function sync-dconf { function sync-dconf {
if ! command -v dconf &> /dev/null; then if ! command -v dconf &> /dev/null; then
echo "System does not use dconf" echo "System does not use dconf"
@ -241,21 +290,25 @@ function sync-dconf {
push-dconf push-dconf
} }
function getdot { function _getdot {
if ! command -v scpace &> /dev/null; then if ! command -v scpace &> /dev/null; then
echo "An alias for scpace has not been defined on this device!" echo "An alias for scpace has not been defined on this device!"
return 1 return 1
fi fi
cd "$DOT_DIR" || return 1 cd "$DOT_DIR" || return 1
git pull && ./copy.sh git pull && ./copy.sh | tee -a "$SYNC_LOCK_FILE"
sync-history sync-history | tee -a "$SYNC_LOCK_FILE"
load-extensions load-extensions | tee -a "$SYNC_LOCK_FILE"
[[ "$1" != "--skip-dconf" ]] && sync-dconf [[ "$1" != "--skip-dconf" ]] && sync-dconf | tee -a "$SYNC_LOCK_FILE"
cd - > /dev/null cd - > /dev/null
} }
function getdot {
lockfor "$SYNC_LOCK_FILE" 90 _getdot $@
}
if which starship &> /dev/null; then if which starship &> /dev/null; then
eval "$(starship init zsh)" eval "$(starship init zsh)"
fi fi
@ -294,7 +347,7 @@ test -f "$HOME/.asdf/asdf.sh" && . "$HOME/.asdf/asdf.sh"
test -f ~/.cargo/env && source ~/.cargo/env test -f ~/.cargo/env && source ~/.cargo/env
# bun completions # bun completions
[ -s "/home/sage/.bun/_bun" ] && source "/home/sage/.bun/_bun" [ -s "$HOME/.bun/_bun" ] && source "$HOME/.bun/_bun"
# bun # bun
export BUN_INSTALL="$HOME/.bun" export BUN_INSTALL="$HOME/.bun"