Reorganize packages and simplify bootstrap
This commit is contained in:
parent
8100eb287d
commit
fffb78e27e
48 changed files with 96 additions and 2959 deletions
2
.gitattributes
vendored
2
.gitattributes
vendored
|
@ -1,2 +1,2 @@
|
|||
ssh/ssh_config filter=git-crypt diff=git-crypt
|
||||
ssh/.ssh/config filter=git-crypt diff=git-crypt
|
||||
|
||||
|
|
1
git/.local/etc/git/.keep
Normal file
1
git/.local/etc/git/.keep
Normal file
|
@ -0,0 +1 @@
|
|||
directory for extra git configurations
|
252
install.sh
252
install.sh
|
@ -5,7 +5,7 @@ export DOTFILES="$(dirname "$(realpath "$0")")"
|
|||
export DEFAULT_GIT_USER="Fernando Schauenburg"
|
||||
export DEFAULT_GIT_EMAIL="fernando@schauenburg.me"
|
||||
|
||||
. "$DOTFILES/zsh/zshenv"
|
||||
. "$DOTFILES/zsh/.zshenv"
|
||||
[ -f "$DOTFILES/config" ] && . "$DOTFILES/config"
|
||||
|
||||
main() {
|
||||
|
@ -17,19 +17,71 @@ main() {
|
|||
esac done
|
||||
|
||||
greeting
|
||||
deploy_alacritty
|
||||
deploy_bin
|
||||
deploy_git
|
||||
deploy_jupyter
|
||||
deploy_mintty
|
||||
deploy_misc
|
||||
deploy_nvim
|
||||
deploy_python
|
||||
deploy_readline
|
||||
deploy_ssh
|
||||
deploy_tmux
|
||||
deploy_x11
|
||||
deploy_zsh
|
||||
deploy_packages
|
||||
bin_extras
|
||||
git_extras
|
||||
nvim_extras
|
||||
}
|
||||
|
||||
greeting() {
|
||||
dry_run && {
|
||||
warn "Performing dry run (use -f to actually make changes)."
|
||||
warn ""
|
||||
}
|
||||
|
||||
git_info="${GIT_USER:-$DEFAULT_GIT_USER} <${GIT_EMAIL:-$DEFAULT_GIT_EMAIL}>"
|
||||
info "Deploying with git user $cyan$git_info$rst"
|
||||
|
||||
[ -t 0 ] && {
|
||||
info "Press ENTER to continue (CTRL-C to cancel)..."
|
||||
read k
|
||||
}
|
||||
}
|
||||
|
||||
deploy_packages() {
|
||||
for f in *; do
|
||||
[ -d "$f" ] && {
|
||||
heading "$f"
|
||||
deploy "$f"
|
||||
}
|
||||
done
|
||||
}
|
||||
|
||||
bin_extras() {
|
||||
heading 'stale ~/.local/bin commands'
|
||||
for cmd in $HOME/.local/bin/*; do prune_cmd "$cmd"; done;
|
||||
}
|
||||
|
||||
|
||||
git_extras() {
|
||||
heading 'git user configuration'
|
||||
temp_git="$(mktemp)"
|
||||
cat >"$temp_git" <<EOF
|
||||
# *************************************
|
||||
# * DO NOT EDIT THIS FILE *
|
||||
# *************************************
|
||||
#
|
||||
# This file was generated by the bootstrap script and any changes will be
|
||||
# overwritten the next time it is run. For local settings, use this instead:
|
||||
#
|
||||
# ~/.local/etc/git/config
|
||||
#
|
||||
EOF
|
||||
git config -f "$temp_git" user.name "${GIT_USER:-$DEFAULT_GIT_USER}"
|
||||
git config -f "$temp_git" user.email "${GIT_EMAIL:-$DEFAULT_GIT_EMAIL}"
|
||||
equal_content "$HOME/.local/etc/git/config.user" "$temp_git"
|
||||
}
|
||||
|
||||
nvim_extras() {
|
||||
heading 'nvim plugins'
|
||||
if command -v nvim >/dev/null 2>&1; then
|
||||
dry_run || {
|
||||
change "installing neovim plugins..."
|
||||
nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'
|
||||
}
|
||||
else
|
||||
error "neovim is not installed; skipping plugin installation..."
|
||||
fi
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
|
@ -66,39 +118,17 @@ usage() {
|
|||
heading() { printf '%s\n' "${blue}===== $1 ==========${rst}"; }
|
||||
info() { printf '%s ' "$@"; printf '\n'; }
|
||||
ok() { printf '%s ' "${green}OK:${rst}" "$@"; printf '\n'; }
|
||||
change() { printf '%s ' "${yellow}CHANGE:${rst}" "$@"; printf '\n'; }
|
||||
warn() { printf '%s ' "${yellow}$@${rst}"; printf '\n'; }
|
||||
error() { printf '%s ' "${red}$@${rst}"; printf '\n'; }
|
||||
|
||||
greeting() {
|
||||
dry_run && info "Dry run: no changes will be made to filesytem (use -f to override)."
|
||||
info "Deploying with git user $yellow${GIT_USER:-$DEFAULT_GIT_USER} <${GIT_EMAIL:-$DEFAULT_GIT_EMAIL}>$rst"
|
||||
[ -t 0 ] && {
|
||||
info "Press ENTER to continue (CTRL-C to cancel)..."
|
||||
read k
|
||||
}
|
||||
}
|
||||
|
||||
# Make sure directory $1 exists.
|
||||
ensure_directory() {
|
||||
[ -d "$1" ] && { ok "$1/"; return; }
|
||||
warn "creating $1/"
|
||||
[ -d "$1" ] && return
|
||||
change "MKDIR $1/"
|
||||
dry_run || mkdir -p "$1/"
|
||||
}
|
||||
|
||||
# Make sure file $1 does not exist.
|
||||
remove_file() {
|
||||
[ ! -f "$1" ] && { ok "$1"; return; }
|
||||
warn "removing $1"
|
||||
dry_run || rm "$1"
|
||||
}
|
||||
|
||||
# Make sure file $1 exists (content is irrelevant).
|
||||
touch_file() {
|
||||
[ -f "$1" ] && { ok "$1"; return; }
|
||||
warn "creating $1"
|
||||
dry_run || touch "$1"
|
||||
}
|
||||
|
||||
# Remove $1 if it's a broken link to a dotfile script.
|
||||
prune_cmd() {
|
||||
if [ -h "$1" ]; then # it's a symbolic link...
|
||||
|
@ -106,7 +136,7 @@ prune_cmd() {
|
|||
case "$target" in
|
||||
"$DOTFILES/bin/"*) # ... pointing into dotfiles bin
|
||||
if [ ! -e "$1" ]; then # target of the link missing
|
||||
warn "removing stale link $1 -> $target"
|
||||
change "UNLINK (stale) $1 -> $target"
|
||||
dry_run || rm -f "$1"
|
||||
fi
|
||||
;;
|
||||
|
@ -118,145 +148,35 @@ prune_cmd() {
|
|||
link() {
|
||||
target="$(realpath -s "$1")"
|
||||
[ "$(readlink "$2")" = "$target" ] && { ok "$2"; return; }
|
||||
warn "linking $2 -> $target"
|
||||
change "LINK $2 -> $target"
|
||||
dry_run || ln -sf "$target" "$2"
|
||||
}
|
||||
|
||||
# Ensure $1 and $2 contents are equal, updating $1 if needed.
|
||||
equal_content() {
|
||||
diff "$1" "$2" >/dev/null 2>&1 && { ok "$1"; return; }
|
||||
warn "overwriting $1 with $2:"
|
||||
change "OVERWRITE $1 with $2:"
|
||||
echo "$cyan"
|
||||
cat "$2"
|
||||
echo "$rst"
|
||||
dry_run || cp -f "$2" "$1"
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# Configuration Deployments
|
||||
###############################################################################
|
||||
|
||||
deploy_alacritty() {
|
||||
heading 'alacritty'
|
||||
ensure_directory "$XDG_CONFIG_HOME/alacritty"
|
||||
link "$DOTFILES/alacritty/alacritty.yml" "$XDG_CONFIG_HOME/alacritty/alacritty.yml"
|
||||
relative_path() {
|
||||
python -c "import os.path; print os.path.relpath('$1','${2:-$PWD}')"
|
||||
}
|
||||
|
||||
deploy_bin() {
|
||||
heading 'bin'
|
||||
ensure_directory "$HOME/.local/bin"
|
||||
for cmd in $HOME/.local/bin/*; do prune_cmd "$cmd"; done
|
||||
for cmd in "$DOTFILES/bin/"*; do
|
||||
link "$cmd" "$HOME/.local/bin/$(basename "$cmd")"
|
||||
deploy() {
|
||||
find "$1" -type f -print0 | while read -d $'\0' src; do
|
||||
src_dir="$(dirname "$src")"
|
||||
dest_dir="$HOME${src_dir##"$1"}"
|
||||
ensure_directory "$dest_dir"
|
||||
|
||||
filename="$(basename "$src")"
|
||||
[ "$filename" = '.keep' ] && continue
|
||||
|
||||
link "$src" "$dest_dir/$filename"
|
||||
done
|
||||
}
|
||||
|
||||
deploy_git() {
|
||||
heading 'git'
|
||||
ensure_directory "$XDG_CONFIG_HOME/git"
|
||||
ensure_directory "${HOME}/.local/etc/git"
|
||||
link "$DOTFILES/git/gitconfig" "$XDG_CONFIG_HOME/git/config"
|
||||
link "$DOTFILES/git/gitignore" "$XDG_CONFIG_HOME/git/ignore"
|
||||
|
||||
temp_git="$(mktemp)"
|
||||
cat >"$temp_git" <<EOF
|
||||
# *************************************
|
||||
# * DO NOT EDIT THIS FILE *
|
||||
# *************************************
|
||||
#
|
||||
# This file was generated by the bootstrap script and any changes will be
|
||||
# overwritten the next time it is run. For local settings, use this instead:
|
||||
#
|
||||
# ~/.local/etc/git/config
|
||||
#
|
||||
EOF
|
||||
git config -f "$temp_git" user.name "${GIT_USER:-$DEFAULT_GIT_USER}"
|
||||
git config -f "$temp_git" user.email "${GIT_EMAIL:-$DEFAULT_GIT_EMAIL}"
|
||||
equal_content "$HOME/.local/etc/git/config.user" "$temp_git"
|
||||
}
|
||||
|
||||
deploy_jupyter() {
|
||||
heading 'jupyter'
|
||||
ensure_directory "${HOME}/.jupyter/custom"
|
||||
ensure_directory "${HOME}/.jupyter/nbconfig"
|
||||
link "$DOTFILES/jupyter/custom.js" "${HOME}/.jupyter/custom/custom.js"
|
||||
link "$DOTFILES/jupyter/notebook.json" "${HOME}/.jupyter/nbconfig/notebook.json"
|
||||
}
|
||||
|
||||
deploy_mintty() {
|
||||
heading 'mintty'
|
||||
ensure_directory "$XDG_CONFIG_HOME/mintty"
|
||||
ensure_directory "$XDG_CONFIG_HOME/mintty/themes"
|
||||
link "$DOTFILES/mintty/minttyrc" "$XDG_CONFIG_HOME/mintty/config"
|
||||
link "$DOTFILES/mintty/solarized-dark" "$XDG_CONFIG_HOME/mintty/themes/solarized-dark"
|
||||
link "$DOTFILES/mintty/solarized-light" "$XDG_CONFIG_HOME/mintty/themes/solarized-light"
|
||||
}
|
||||
|
||||
deploy_misc() {
|
||||
heading 'miscelaneous'
|
||||
ensure_directory "$XDG_DATA_HOME/less" # for history
|
||||
touch_file "$HOME/.hushlogin"
|
||||
}
|
||||
|
||||
deploy_nvim() {
|
||||
heading 'nvim'
|
||||
remove_file "$XDG_CONFIG_HOME/nvim/init.vim"
|
||||
ensure_directory "$XDG_DATA_HOME/nvim/shada"
|
||||
link "$DOTFILES/nvim/init.lua" "$XDG_CONFIG_HOME/nvim/init.lua"
|
||||
|
||||
ensure_directory "$XDG_CONFIG_HOME/nvim/lua/fs"
|
||||
for f in nvim/lua/fs/*; do link "$DOTFILES/$f" "$XDG_CONFIG_HOME/$f"; done
|
||||
unset f
|
||||
|
||||
ensure_directory "$XDG_CONFIG_HOME/nvim/after/plugin"
|
||||
for f in nvim/after/plugin/*; do link "$DOTFILES/$f" "$XDG_CONFIG_HOME/$f"; done
|
||||
unset f
|
||||
|
||||
if command -v nvim >/dev/null 2>&1; then
|
||||
warn "installing neovim plugins..."
|
||||
dry_run || nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'
|
||||
else
|
||||
error "neovim is not installed; skipping plugin installation..."
|
||||
fi
|
||||
}
|
||||
|
||||
deploy_python() {
|
||||
heading 'python'
|
||||
ensure_directory "$XDG_CONFIG_HOME/python"
|
||||
ensure_directory "$XDG_DATA_HOME/python" # for history
|
||||
link "$DOTFILES/python/startup.py" "$XDG_CONFIG_HOME/python/startup.py"
|
||||
}
|
||||
|
||||
deploy_readline() {
|
||||
heading 'readline'
|
||||
ensure_directory "$XDG_CONFIG_HOME/readline"
|
||||
link "$DOTFILES/readline/inputrc" "$XDG_CONFIG_HOME/readline/inputrc"
|
||||
}
|
||||
|
||||
deploy_ssh() {
|
||||
heading 'ssh'
|
||||
ensure_directory "${HOME}/.ssh"
|
||||
link "$DOTFILES/ssh/ssh_config" "${HOME}/.ssh/config"
|
||||
}
|
||||
|
||||
deploy_tmux() {
|
||||
ensure_directory "$XDG_CONFIG_HOME/tmux"
|
||||
link "$DOTFILES/tmux/tmux.conf" "$XDG_CONFIG_HOME/tmux/tmux.conf"
|
||||
}
|
||||
|
||||
deploy_x11() {
|
||||
heading 'X11'
|
||||
link "$DOTFILES/x11/xcompose" ${HOME}/.XCompose
|
||||
}
|
||||
|
||||
deploy_zsh() {
|
||||
heading 'zsh'
|
||||
ensure_directory "$ZDOTDIR"
|
||||
ensure_directory "$XDG_DATA_HOME/zsh" # for history
|
||||
link "$DOTFILES/zsh/zshenv" "$HOME/.zshenv"
|
||||
link "$DOTFILES/zsh/zshrc" "$ZDOTDIR/.zshrc"
|
||||
link "$DOTFILES/zsh/aliases" "$ZDOTDIR/aliases"
|
||||
link "$DOTFILES/zsh/prompt" "$ZDOTDIR/prompt"
|
||||
link "$DOTFILES/zsh/vi-mode" "$ZDOTDIR/vi-mode"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
|
|
0
misc/.hushlogin
Normal file
0
misc/.hushlogin
Normal file
1
misc/.local/share/less/.keep
Normal file
1
misc/.local/share/less/.keep
Normal file
|
@ -0,0 +1 @@
|
|||
directory for less(1) history
|
1
nvim/.local/share/nvim/shada/.keep
Normal file
1
nvim/.local/share/nvim/shada/.keep
Normal file
|
@ -0,0 +1 @@
|
|||
nvim SHAred DAta directory
|
2788
nvim/plug.vim
2788
nvim/plug.vim
File diff suppressed because it is too large
Load diff
1
python/.local/share/python/.keep
Normal file
1
python/.local/share/python/.keep
Normal file
|
@ -0,0 +1 @@
|
|||
directory for python REPL history
|
1
zsh/.local/share/zsh/.keep
Normal file
1
zsh/.local/share/zsh/.keep
Normal file
|
@ -0,0 +1 @@
|
|||
directory for zsh history
|
Loading…
Add table
Reference in a new issue