-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_restore.sh
More file actions
executable file
·42 lines (35 loc) · 1.36 KB
/
Copy path_restore.sh
File metadata and controls
executable file
·42 lines (35 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
# shellcheck disable=SC1004
set -euo pipefail
ASCII_STOW='
___ ___ ___ ___
/\ \ /\ \ /\ \ /\__\
/::\ \ \:\ \ /::\ \ /:/ _/_
/:/\ \ \ \:\ \ /:/\:\ \ /:/ /\__\
_\:\~\ \ \ /::\ \ /:/ \:\ \ /:/ /:/ _/_
/\ \:\ \ \__\ /:/\:\__\ /:/__/ \:\__\ /:/_/:/ /\__\
\:\ \:\ \/__/ /:/ \/__/ \:\ \ /:/ / \:\/:/ /:/ /
\:\ \:\__\ /:/ / \:\ /:/ / \::/_/:/ /
\:\/:/ / \/__/ \:\/:/ / \:\/:/ /
\::/ / \::/ / \::/ /
\/__/ \/__/ \/__/
'
echo "$ASCII_STOW"
if ! command -v stow >/dev/null 2>&1; then
echo "[ERROR] GNU Stow is required. Run ./_install.sh first."
exit 1
fi
for file in *; do
# Top-level directories prefixed with '_' are archival and not stow targets.
if [[ "$file" == _* ]]; then
continue
fi
if [ -d "$file" ]; then
read -r -e -p "[y/N] - Restore ${file}? " response
if [[ "$response" == [Yy]* ]]; then
# Keep failures local to this package instead of letting `set -e` stop the restore.
stow -v -t "$HOME" "$file" || echo "[ERROR] Stow failed for ${file}; skipping."
fi
fi
done
# NOTE: to un-stow a directory, run `stow -t "$HOME" -D tmux`