Added dotfiles management script
This commit is contained in:
parent
62cf7af099
commit
acecc996e4
2 changed files with 114 additions and 0 deletions
68
bin/dotfiles
Executable file
68
bin/dotfiles
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
#!/bin/bash
|
||||
|
||||
##
|
||||
## binaryDiv's dotfiles management script
|
||||
##
|
||||
|
||||
# Define root dir for dotfiles management (defaults to $HOME, can be overridden
|
||||
# with environment variables for debugging)
|
||||
if [ -z "$DOTFILESROOT" ]; then
|
||||
DOTFILESROOT="$HOME"
|
||||
fi
|
||||
|
||||
# Set variables
|
||||
homedir="$DOTFILESROOT"
|
||||
dotfilesdir="$DOTFILESROOT/.dotfiles"
|
||||
|
||||
|
||||
# Check for command
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "no command given"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Fetch command
|
||||
cmd=$1
|
||||
shift
|
||||
|
||||
|
||||
# Parse command
|
||||
case "$cmd" in
|
||||
help)
|
||||
# help: print usage help
|
||||
echo "help: not implemented yet, sorry /o\\"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
ls)
|
||||
# ls: list dotfiles via ls
|
||||
echo "$dotfilesdir:"
|
||||
ls -lAh --color=auto "$dotfilesdir/"
|
||||
;;
|
||||
|
||||
git)
|
||||
# git: do git commands (forwards all arguments)
|
||||
git -C "$dotfilesdir" "$@"
|
||||
;;
|
||||
|
||||
createlinks)
|
||||
# createlinks: create or update links for dotfiles in home dir
|
||||
|
||||
# (Use an extra script for this to separate the management script from
|
||||
# user specific dotfiles)
|
||||
if [ -f "$dotfilesdir/createlinks.sh" ]; then
|
||||
# arguments: home dir and .dotfiles dir
|
||||
bash "$dotfilesdir/createlinks.sh" "$homedir" "$dotfilesdir"
|
||||
else
|
||||
echo "no createlinks.sh found in $dotfilesdir"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
# unknown command
|
||||
echo "unknown command '$cmd'"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue