mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 06:12:34 +00:00
Updated setup script for the git directory
This commit is contained in:
103
scripts/setup
103
scripts/setup
@@ -1,7 +1,104 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
mkdir "${HOME}/.local" >/dev/null 2>&1
|
set -e
|
||||||
mkdir "${HOME}/.local/bin" >/dev/null 2>&1
|
|
||||||
|
|
||||||
ln -sfv "${PWD}/scripts" "${HOME}/.local"
|
scripts="${HOME}/.local/scripts"
|
||||||
|
uninstall=1
|
||||||
|
remove=1
|
||||||
|
copy=1
|
||||||
|
link=0
|
||||||
|
|
||||||
|
_usage() {
|
||||||
|
printf "\n" >&2
|
||||||
|
printf "Usage: setup [OPTIONS]\n" >&2
|
||||||
|
printf "\n" >&2
|
||||||
|
printf "Installs or Uninstalls zsh configuration files.\n" >&2
|
||||||
|
printf "\n" >&2
|
||||||
|
printf "Options:\n" >&2
|
||||||
|
printf "\t-c | --copy : Copy the configuration files, instead of creating symlinks.\n" >&2
|
||||||
|
printf "\t-h | --help : Print usage information.\n" >&2
|
||||||
|
printf "\t-l | --link : Create symlinks to the configuration files (Default).\n" >&2
|
||||||
|
printf "\t-r | --remove : Removes the entire ~/.config/zsh directory.\n" >&2
|
||||||
|
printf "\t-u | --uninstall : Uninstalls configuration files.\n" >&2
|
||||||
|
printf "\n" >&2
|
||||||
|
printf "If called without the uninstall option then it will install the configuration files.\n" >&2
|
||||||
|
printf "The copy and link options are ignored if called with the uninstall or remove option.\n" >&2
|
||||||
|
printf "\n" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
_parse_options() {
|
||||||
|
arg=
|
||||||
|
while ! test -z "$1"; do
|
||||||
|
arg="$1"
|
||||||
|
case $arg in
|
||||||
|
-c | --copy)
|
||||||
|
copy=0
|
||||||
|
link=1
|
||||||
|
shift;;
|
||||||
|
-h | --help)
|
||||||
|
_usage
|
||||||
|
exit;;
|
||||||
|
-l | --link)
|
||||||
|
copy=1
|
||||||
|
link=0
|
||||||
|
shift;;
|
||||||
|
-r | --remove)
|
||||||
|
remove=0
|
||||||
|
shift;;
|
||||||
|
-u | --uninstall)
|
||||||
|
uninstall=0
|
||||||
|
shift;;
|
||||||
|
*)
|
||||||
|
echo "Unknown option $arg" >&2
|
||||||
|
shift;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_make_dirs() {
|
||||||
|
if ! test -d "${HOME}/.local"; then
|
||||||
|
mkdir "${HOME}/.local"
|
||||||
|
fi
|
||||||
|
if ! test -d "${HOME}/.local/bin"; then
|
||||||
|
mkdir "${HOME}/.local/bin"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_remove_scripts() {
|
||||||
|
echo "Removing scripts..."
|
||||||
|
test -e "${scripts}" && rm "${scripts}"
|
||||||
|
}
|
||||||
|
|
||||||
|
_link_scripts() {
|
||||||
|
echo "Linking scripts..."
|
||||||
|
ln -sfv "${PWD}/scripts" "${scripts}"
|
||||||
|
}
|
||||||
|
|
||||||
|
_copy_scripts() {
|
||||||
|
echo "Copying scripts..."
|
||||||
|
cp -r "${PWD}/scripts" "${scripts}"
|
||||||
|
}
|
||||||
|
|
||||||
|
_install() {
|
||||||
|
|
||||||
|
_make_dirs
|
||||||
|
|
||||||
|
test "$copy" -eq 0 && _copy_scripts && return "$?"
|
||||||
|
test "$link" -eq 0 && _link_scripts && return "$?"
|
||||||
|
|
||||||
|
echo "Neither link nor copy was passed, see --help for usage"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
#--------------- main ---------------
|
||||||
|
main() {
|
||||||
|
_parse_options "$@"
|
||||||
|
|
||||||
|
test "$remove" -eq 0 && _remove_scripts && exit "$?"
|
||||||
|
test "$uninstall" -eq 0 && _remove_scripts && exit "$?"
|
||||||
|
|
||||||
|
_install
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export EDITOR_PREFIX=vi
|
|||||||
export GIT_DISCOVERY_ACROSS_FILESYSTEM=1
|
export GIT_DISCOVERY_ACROSS_FILESYSTEM=1
|
||||||
export VIMINIT='source $MYVIMRC'
|
export VIMINIT='source $MYVIMRC'
|
||||||
export MYVIMRC="$HOME/.vim/vimrc"
|
export MYVIMRC="$HOME/.vim/vimrc"
|
||||||
|
export MYZSHRC="$ZDOTDIR/.zshrc"
|
||||||
|
|
||||||
autoload -U up-line-or-beginning-search
|
autoload -U up-line-or-beginning-search
|
||||||
autoload -U down-line-or-beginning-search
|
autoload -U down-line-or-beginning-search
|
||||||
@@ -177,6 +178,7 @@ alias gcm='git commit -m'
|
|||||||
#alias gp() { git push }
|
#alias gp() { git push }
|
||||||
alias gp='git push'
|
alias gp='git push'
|
||||||
alias gs='git status'
|
alias gs='git status'
|
||||||
|
alias l='ls -lah --color=auto'
|
||||||
alias vi='vim'
|
alias vi='vim'
|
||||||
alias nvim='unset VIMINIT && unset MYVIMRC && nvim'
|
alias nvim='unset VIMINIT && unset MYVIMRC && nvim'
|
||||||
|
|
||||||
@@ -184,4 +186,4 @@ alias nvim='unset VIMINIT && unset MYVIMRC && nvim'
|
|||||||
_source_if "$ZDOTDIR/.zshrc-local"
|
_source_if "$ZDOTDIR/.zshrc-local"
|
||||||
|
|
||||||
|
|
||||||
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
# [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
||||||
|
|||||||
Reference in New Issue
Block a user