Refactor copy_configs, improve sym-linking; vim configs fine for now

This commit is contained in:
david 2025-04-04 16:55:39 -05:00
parent 42f9167958
commit 90cab5380e
4 changed files with 42 additions and 27 deletions

View File

@ -3,18 +3,6 @@
execute() { log "execute $@" && "$@" }
log() { echo "$@" }
copy_dir() {
local from=$1
local to=$2
pushd $from > /dev/null
local dirs=(`find . -mindepth 1 -maxdepth 1 -type d`)
for dir in $dirs; do
[[ -d $to/$dir ]] && execute rm -rf $to/$dir
execute cp -rp $dir $to/$dir
done
popd > /dev/null
}
copy_file() {
local from=$1
local to=$2
@ -23,20 +11,42 @@ copy_file() {
execute cp -p $from $to/$filename
}
log "---------------- dotfiles ----------------"
copy_dir() {
local from=$1
local to=$2
pushd $from > /dev/null
local directories=(`find . -mindepth 1 -maxdepth 1 -type d`)
for dir in $directories; do
[[ -d $to/$dir ]] && execute rm -rf $to/$dir
execute cp -rp $dir $to/$dir
done
local files=(`find . -mindepth 1 -maxdepth 1 -type f`)
for file in $files; do
copy_file $file $to
done
popd > /dev/null
}
copy_dir src_files/.config $XDG_CONFIG_HOME
copy_dir src_files/.local $DIR_LOCAL
link_dir() {
local src_dir=$1
local link_dir=$2
log "deleting existing link/dir: $link_dir"
[[ -h "$link_dir" ]] && rm $link_dir
[[ -d "$link_dir" ]] && rm -rf $link_dir
log "sym-linking $link_dir -> $src_dir"
ln -s $src_dir $link_dir
}
log "---------------- dotfiles ----------------"
copy_file src_files/.config/zsh/.zshenv $HOME # duplicate, copy anyway, ensures $ZDOTDIR
# on macos, handle sim-linking to gimp config since gimp defaults to app-support
if [[ "$BOX_SETUP_OS" = "macos" ]]; then
local macos_gimp_dir="$HOME/Library/Application Support/GIMP"
log "deleting existing GIMP link/dir: $macos_gimp_dir"
[[ -h "$macos_gimp_dir" ]] && rm $macos_gimp_dir
[[ -d "$macos_gimp_dir" ]] && rm -rf $macos_gimp_dir
log "linking $macos_gimp_dir to \$XDG_CONFIG_HOME/GIMP"
ln -s $XDG_CONFIG_HOME/GIMP $macos_gimp_dir
fi
copy_dir src_files/.config $XDG_CONFIG_HOME
copy_dir src_files/.local/bin $DIR_BIN
copy_dir src_files/.local/scripts $DIR_SCRIPTS
# on macos, gimp defaults to app-support, so sym-link to actual config
[[ "$BOX_SETUP_OS" = "macos" ]] &&
link_dir "$XDG_CONFIG_HOME/GIMP" "$HOME/Library/Application Support/GIMP"
link_dir "$XDG_CONFIG_HOME/vim" "$HOME/.vim" # TODO: use vim wrapper or similar instead

View File

@ -1,3 +1,4 @@
plugins, git repos for ref, clone in this dir if needed
#/bin/zsh
git clone https://github.com/ghifarit53/tokyonight-vim.git
git clone https://github.com/leafgarland/typescript-vim.git

View File

@ -1,7 +1,12 @@
" base settings
set nocompatible
let mapleader=","
set runtimepath+=$XDG_CONFIG_HOME/vim
" xdg base directory settings/clean-up
set runtimepath^=$XDG_CONFIG_HOME/vim
" add other dirs to path as needed
" XDG_CONFIG_HOME, XDG_CACHE_HOME, XDG_DATA_HOME, XDG_STATE_HOME, XDG_DATA_DIRS
" set/override other filenames/paths/dirs as needed
" plugin config
let g:netrw_banner=0 " hide banner

View File

@ -4,7 +4,6 @@ set -o vi
# path updates
export PATH=$DIR_BIN:$DIR_SCRIPTS:$PATH
export PATH=$PATH:/opt/homebrew/opt/ccache/libexec:/opt/homebrew/bin
export PATH=$PATH:$HOME/bin/android-sdk-darwin/platform-tools
# shortcuts for common commands
alias 3e='echo;echo;echo'