Make dotfiles reversible
This commit is contained in:
+29
-11
@@ -5,6 +5,11 @@ apply_dotfile() {
|
|||||||
stow --adopt -S -t "${HOME}" "${directory_to_stow}"
|
stow --adopt -S -t "${HOME}" "${directory_to_stow}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
revert_dotfile() {
|
||||||
|
directory_to_stow="${1}"
|
||||||
|
stow -D -t "${HOME}" "${directory_to_stow}"
|
||||||
|
}
|
||||||
|
|
||||||
# Adopt will change the files in stow to match existing files.
|
# Adopt will change the files in stow to match existing files.
|
||||||
# We don't want this, we just want to handle existing files gracefully.
|
# We don't want this, we just want to handle existing files gracefully.
|
||||||
# We simply adopt all the files and then at the end restore our git repo to undo changes
|
# We simply adopt all the files and then at the end restore our git repo to undo changes
|
||||||
@@ -12,22 +17,35 @@ restore_from_adoption() {
|
|||||||
git restore .
|
git restore .
|
||||||
}
|
}
|
||||||
|
|
||||||
apply_dotfile bash
|
mode_command=${1:-apply}
|
||||||
apply_dotfile sh
|
if [ "${mode_command}" != "apply" ] && [ "${mode_command}" != "revert" ]; then
|
||||||
apply_dotfile readline
|
echo "$0: mode command ("'${1}'") must be apply or revert" 1>&2
|
||||||
apply_dotfile screen
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
apply_dotfile git
|
operation() {
|
||||||
apply_dotfile xdg
|
${mode_command}_dotfile ${1}
|
||||||
|
}
|
||||||
|
|
||||||
apply_dotfile vim
|
# Create .local/bin to prevent tree folding
|
||||||
|
mkdir -p ~/.local/bin
|
||||||
|
|
||||||
apply_dotfile ruby
|
operation bash
|
||||||
apply_dotfile python
|
operation sh
|
||||||
|
operation readline
|
||||||
|
operation screen
|
||||||
|
|
||||||
|
operation git
|
||||||
|
operation xdg
|
||||||
|
|
||||||
|
operation vim
|
||||||
|
|
||||||
|
operation ruby
|
||||||
|
operation python
|
||||||
|
|
||||||
# Only if inside a coder instance
|
# Only if inside a coder instance
|
||||||
if [ -n "${CODER}" ]; then
|
if [ -n "${CODER}" ]; then
|
||||||
apply_dotfile gnupg
|
operation gnupg
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check that SSH version is above 9.2 (where EnableEscapeCommandline was added) before conditionally adding
|
# Check that SSH version is above 9.2 (where EnableEscapeCommandline was added) before conditionally adding
|
||||||
@@ -38,6 +56,6 @@ cat <<CONFIG > ssh/.ssh/extra.conf
|
|||||||
EnableEscapeCommandline yes
|
EnableEscapeCommandline yes
|
||||||
CONFIG
|
CONFIG
|
||||||
fi
|
fi
|
||||||
apply_dotfile ssh
|
operation ssh
|
||||||
|
|
||||||
restore_from_adoption
|
restore_from_adoption
|
||||||
|
|||||||
Reference in New Issue
Block a user