Add system-type filters, add git-clone handling to main script

This commit is contained in:
2025-09-06 11:05:21 -05:00
parent 891b605dbe
commit 7f287b591e
23 changed files with 182 additions and 145 deletions

View File

@@ -1,20 +1,11 @@
# dotfiles plus scripts to copy them and also install stuff # dotfiles, plus scripts for box setup
### script run ### prereqs, linux distros
- fulfill prerequisites below
- git clone this repo
- from the repo's root directory, run `./box_setup <OS name>`
### prerequisites
- package manager is configured (i.e. source repos, mirrors, etc. configured)
- zsh is installed (scripts are written for zsh) - zsh is installed (scripts are written for zsh)
- sudo access is configured for current user (as of 2025-01-27, not needed on macos) - sudo access is configured for current user
- system-specific items below are fulfilled
##### prereqs, os specific, linux-placeholder ### prereqs, macos
- (currently none) - zsh is installed (scripts are written for zsh)
##### prereqs, os specific, macos
- install the package manager, [homebrew](https://brew.sh/) - install the package manager, [homebrew](https://brew.sh/)
- for yabai window manager (so as to not mess with SIP settings) - for yabai window manager (so as to not mess with SIP settings)
- create 9 spaces/desktops - create 9 spaces/desktops
@@ -27,18 +18,24 @@
- `displays have separate spaces`: enabled - `displays have separate spaces`: enabled
- `show files on desktop`: enabled - `show files on desktop`: enabled
### script run
- if repo present on system, run from the repo's root:
- ```
./box_setup.sh <OS-name>
```
- if repo not present, run:
- ```
curl -LO https://git.drinkingtea.net/david/box-setup/raw/branch/master/box_setup.sh
sh box_setup.sh <OS-name>
```
- then delete the script file afterwards (repo should have been copied to dev dir)
### todo items ### todo items
- add logic to the main run script to handle cloning of this repo - choose window manager for linux, then configure
- config for window manager for linux (first, decide which wm to use) - config for: terminal (ghostty); mpd, mpc, ncmpcpp; mpv
- config for terminal emulator (currently ghostty)
- config for mpd, mpc, ncmpcpp
- config for mpv
- config for gimp, `src_files/.config/GIMP` (dir) - config for gimp, `src_files/.config/GIMP` (dir)
- set things in gtkrc only? still need to nest that within a sub dir? - set things in gtkrc only? still need to nest that within a sub dir?
- or configure in gimp, copy resulting dir to `src_files/.config/GIMP`, call it a day - or configure in gimp, copy resulting dir to `src_files/.config/GIMP`, call it a day
- maybe build in flags/logic for skipping certain installs/builds (and maybe configs?)
on a given system (i.e. don't install on a company box, on a server, etc.)
- decide on and implement approach for languages and versioning - decide on and implement approach for languages and versioning
- asdf, or language-specific version managers? - asdf, or language-specific version managers?
- docker? or alternatives like podman? any license concerns? - docker? or alternatives like podman? any license concerns?
- hybrid of the above?

View File

@@ -1,42 +0,0 @@
#!/bin/zsh
[[ -z $1 ]] &&
echo "OS must be passed as an arg (options: arch, artix, debian, macos)" &&
echo "example: ./box_setup arch" &&
exit 1
# set env vars for installs
local install_cmd=''
local update_pkg_manager_and_defs_cmd=''
local update_pkgs_cmd=''
case $1 in
(arch | artix)
install_cmd="sudo pacman -S"
update_pkg_manager_and_defs_cmd='' # don't; update system instead?
update_pkgs_cmd='sudo pacman -Syu'
;;
(debian)
install_cmd="sudo apt install"
update_pkg_manager_and_defs_cmd='sudo apt update'
update_pkgs_cmd='sudo apt upgrade'
;;
(macos)
install_cmd="brew install"
update_pkg_manager_and_defs_cmd='brew update'
update_pkgs_cmd='brew upgrade'
;;
esac
export BOX_SETUP_INSTALL_COMMAND="$install_cmd"
export BOX_SETUP_UPDATE_PKG_MANAGER_AND_DEFS_CMD="$update_pkg_manager_and_defs_cmd"
export BOX_SETUP_UPDATE_PKGS_CMD="$update_pkgs_cmd"
# make dirs and copy configs/dotfiles
source ./src_files/.config/zsh/.zshenv
./make_dirs
./copy_configs
# install programs
source $ZDOTDIR/.zshenv
source $ZDOTDIR/.zshrc
./install_programs

67
box_setup.sh Executable file
View File

@@ -0,0 +1,67 @@
#!/bin/zsh
[[ -z $1 ]] && {
echo "OS must be passed as an arg, run \`./box_setup.sh --help\` for more info"
exit 1
}
[[ $1 = "--help" ]] && {
echo "usage: ./box_setup.sh <OS-name> [system-type]\n"
echo "OS-name options: arch, artix, debian, macos"
echo "system-type options: personal, studio-music, work-placeholder\n"
echo "examples:\n./box_setup.sh arch studio-music\n./box_setup.sh macos\n"
exit 0
}
# TODO: test this git stuff, see if it works
temp_placement_git_dir="no"
[[ ! -d ".git" && "$(basename $(pwd))" != "box-setup" ]] && {
temp_placement_git_dir="yes"
git clone "https://git.drinkingtea.net/david/box-setup.git" || {
echo "failed to clone box-setup git repo"
exit 1
}
pushd box-setup > /dev/null
}
# set env vars for installs
install_cmd=''
update_pkg_manager_and_defs_cmd=''
update_pkgs_cmd=''
case $1 in
(arch | artix)
install_cmd="sudo pacman -S"
update_pkg_manager_and_defs_cmd='' # don't; update system instead?
update_pkgs_cmd='sudo pacman -Syu'
;;
(debian)
install_cmd="sudo apt install"
update_pkg_manager_and_defs_cmd='sudo apt update'
update_pkgs_cmd='sudo apt upgrade'
;;
(macos)
install_cmd="brew install"
update_pkg_manager_and_defs_cmd='brew update'
update_pkgs_cmd='brew upgrade'
;;
esac
export BOX_SETUP_INSTALL_COMMAND="$install_cmd"
export BOX_SETUP_UPDATE_PKG_MANAGER_AND_DEFS_CMD="$update_pkg_manager_and_defs_cmd"
export BOX_SETUP_UPDATE_PKGS_CMD="$update_pkgs_cmd"
# make dirs and copy configs/dotfiles
source ./src_files/.config/zsh/.zshenv
./make_dirs.sh
./copy_configs.sh $2
# install programs
source $ZDOTDIR/.zshenv
source $ZDOTDIR/.zshrc
./install_programs.sh $2
[[ $temp_placement_git_dir == "yes" ]] && {
popd > /dev/null
mv "box-setup" "$DIR_GIT_PROJECTS/me/"
}

View File

@@ -35,7 +35,7 @@ link_dir() {
ln -s $src_dir $link_dir ln -s $src_dir $link_dir
} }
echo "---- copying dotfiles -------------------------" echo "---- copying dotfiles ------------------------------------------------"
copy_file src_files/.config/zsh/.zshenv $HOME # duplicate, copy anyway, ensures $ZDOTDIR copy_file src_files/.config/zsh/.zshenv $HOME # duplicate, copy anyway, ensures $ZDOTDIR
@@ -43,8 +43,12 @@ copy_dir src_files/.config $XDG_CONFIG_HOME
copy_dir src_files/.local/bin $DIR_BIN copy_dir src_files/.local/bin $DIR_BIN
copy_dir src_files/.local/scripts $DIR_SCRIPTS copy_dir src_files/.local/scripts $DIR_SCRIPTS
[[ "$BOX_SETUP_OS" = "macos" ]] && [[ "$BOX_SETUP_OS" = "macos" ]] && {
# link_dir "$XDG_CONFIG_HOME/REAPER" "$HOME/Library/Application Support/REAPER" && # TODO: get reaper config set up
copy_dir src_files/executable_wrappers_macos $DIR_BIN copy_dir src_files/executable_wrappers_macos $DIR_BIN
link_dir "$XDG_CONFIG_HOME/GIMP" "$HOME/Library/Application Support/GIMP" link_dir "$XDG_CONFIG_HOME/GIMP" "$HOME/Library/Application Support/GIMP"
}
# [[ $1 = "studio-music" ]] &&
# [[ "$BOX_SETUP_OS" = "macos" ]] &&
# link_dir "$XDG_CONFIG_HOME/REAPER" "$HOME/Library/Application Support/REAPER" && # TODO: get reaper config set up

View File

@@ -1,22 +0,0 @@
#!/bin/zsh
local single_script_filter=""
while [[ $# > 0 ]]; do
single_script_filter="$1" # if using param, export BOX_SETUP_OS first if needed
shift
done
echo "---- installing programs ----------------------"
local scripts=$(find ./installs_and_builds -maxdepth 1 -mindepth 1 -type f | sort)
for script in ${=scripts}; do
if [[ -x $script ]]; then
if echo "$script" | grep -qv "$single_script_filter"; then
continue # $single_script_filter set, ignore others
fi
echo "executing: $script"
./$script
fi
done

34
install_programs.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/zsh
find_scripts_in_dir() {
echo $(find $1 -maxdepth 1 -mindepth 1 -type f | sort)
}
install_scripts_from_list() {
for script in $@; do
if [[ -x $script ]]; then
echo "executing: $script"
./$script
fi
done
}
system_types_list="base"
scripts_from_dir=($(find_scripts_in_dir "./installs_and_builds"))
[[ $1 = "personal" ]] && {
system_types_list+=", personal"
scripts_from_dir+=($(find_scripts_in_dir "./installs_and_builds/personal"))
}
[[ $1 = "studio-music" ]] && {
system_types_list+=", studio-music"
scripts_from_dir+=($(find_scripts_in_dir "./installs_and_builds/studio_music"))
}
[[ $1 = "work-placeholder" ]] && {
system_types_list+=", work-placeholder"
scripts_from_dir+=($(find_scripts_in_dir "./installs_and_builds/work_placeholder"))
}
echo "---- installing programs ---------------------------------------------"
echo "-------- for system types: $system_types_list"
install_scripts_from_list "${scripts_from_dir[@]}"

View File

@@ -1,17 +1,17 @@
#!/bin/zsh #!/bin/zsh
local neovim_dir=$HOME/.local/build/neovim install_neovim_dir=$HOME/.local/build/neovim
local neovim_version="v0.10.3" install_neovim_version="v0.10.3"
[ ! -z $NVIM_VERSION ] && neovim_version="$NVIM_VERSION" [ ! -z $NVIM_VERSION ] && install_neovim_version="$NVIM_VERSION"
echo "neovim_version: \"$neovim_version\"" echo "install_neovim_version: \"$install_neovim_version\""
[ ! -d $neovim_dir ] && git clone https://github.com/neovim/neovim.git $neovim_dir [ ! -d $install_neovim_dir ] && git clone https://github.com/neovim/neovim.git $install_neovim_dir
git -C $neovim_dir fetch --all git -C $install_neovim_dir fetch --all
git -C $neovim_dir checkout $neovim_version git -C $install_neovim_dir checkout $install_neovim_version
make -C $neovim_dir clean make -C $install_neovim_dir clean
make -C $neovim_dir CMAKE_BUILD_TYPE=RelWithDebInfo make -C $install_neovim_dir CMAKE_BUILD_TYPE=RelWithDebInfo
sudo make -C $neovim_dir install sudo make -C $install_neovim_dir install
# from primeagen's dev repo, uncomment/edit as needed # from primeagen's dev repo, uncomment/edit as needed
# git clone https://github.com/ThePrimeagen/harpoon.git $HOME/personal/harpoon # git clone https://github.com/ThePrimeagen/harpoon.git $HOME/personal/harpoon

View File

@@ -1,6 +1,6 @@
#!/bin/zsh #!/bin/zsh
local option_prefix='' install_option_prefix=''
[[ "$BOX_SETUP_OS" = "macos" ]] && option_prefix='--cask' [[ "$BOX_SETUP_OS" = "macos" ]] && install_option_prefix='--cask'
# NOTE: ghostty not currently in debian repos, maybe build from source # NOTE: ghostty not currently in debian repos, maybe build from source
${=BOX_SETUP_INSTALL_COMMAND} "$option_prefix" ghostty ${=BOX_SETUP_INSTALL_COMMAND} "$install_option_prefix" ghostty

View File

@@ -1,11 +1,11 @@
#!/bin/zsh #!/bin/zsh
local linux_wm_and_utils() { linux_wm_and_utils() {
# TODO: pick wm for linux; options: dwm, i3, others? # TODO: pick wm for linux; options: dwm, i3, others?
echo "linux_wm_and_utils not yet implemented" echo "linux_wm_and_utils not yet implemented"
} }
local macos_wm_and_utils() { macos_wm_and_utils() {
brew install koekeishiya/formulae/yabai brew install koekeishiya/formulae/yabai
brew install koekeishiya/formulae/skhd brew install koekeishiya/formulae/skhd
skhd --start-service skhd --start-service

View File

@@ -1,8 +1,8 @@
#!/bin/zsh #!/bin/zsh
# TODO: replace firefox with brave or another browser # TODO: replace firefox with brave or another browser
# local option_prefix='' # install_option_prefix=''
# [[ "$BOX_SETUP_OS" = "macos" ]] && option_prefix='--cask' # [[ "$BOX_SETUP_OS" = "macos" ]] && install_option_prefix='--cask'
# local firefox_package_name='firefox' # firefox_package_name='firefox'
# [[ "$BOX_SETUP_OS" = "debian" ]] && firefox_package_name='firefox-esr' # [[ "$BOX_SETUP_OS" = "debian" ]] && firefox_package_name='firefox-esr'
# ${=BOX_SETUP_INSTALL_COMMAND} "$option_prefix" "$firefox_package_name" # ${=BOX_SETUP_INSTALL_COMMAND} "$install_option_prefix" "$firefox_package_name"

View File

@@ -1,6 +1,6 @@
#!/bin/zsh #!/bin/zsh
# only audio editor(s) in this file; daws are handled separately # only audio editor(s) in this file; daws are handled separately
local option_prefix='' install_option_prefix=''
[[ "$BOX_SETUP_OS" = "macos" ]] && option_prefix='--cask' [[ "$BOX_SETUP_OS" = "macos" ]] && install_option_prefix='--cask'
${=BOX_SETUP_INSTALL_COMMAND} "$option_prefix" audacity ${=BOX_SETUP_INSTALL_COMMAND} "$install_option_prefix" audacity

View File

@@ -1,7 +1,7 @@
#!/bin/zsh #!/bin/zsh
local option_prefix='' install_option_prefix=''
[[ "$BOX_SETUP_OS" = "macos" ]] && option_prefix='--cask' [[ "$BOX_SETUP_OS" = "macos" ]] && install_option_prefix='--cask'
${=BOX_SETUP_INSTALL_COMMAND} "$option_prefix" gimp ${=BOX_SETUP_INSTALL_COMMAND} "$install_option_prefix" gimp
# ${=BOX_SETUP_INSTALL_COMMAND} imagemagick # TODO: consider this program too # ${=BOX_SETUP_INSTALL_COMMAND} imagemagick # TODO: consider this program too

View File

@@ -2,10 +2,10 @@
# TODO: review and decide if the things below are needed # TODO: review and decide if the things below are needed
#local lua_package="lua5.1" # install_lua_package="lua5.1"
#[[ "$BOX_SETUP_OS" = "macos" ]] && lua_package="lua@5.1" #[[ "$BOX_SETUP_OS" = "macos" ]] && install_lua_package="lua@5.1"
#${=BOX_SETUP_INSTALL_COMMAND} "$lua_package" liblua5.1-0-dev #${=BOX_SETUP_INSTALL_COMMAND} "$install_lua_package" liblua5.1-0-dev
# TODO: do i want to install luarocks? lazy.nvim plugin manager currently expects it # TODO: do i want to install luarocks? lazy.nvim plugin manager currently expects it
#luarocks install luacheck #luarocks install luacheck

View File

@@ -2,4 +2,4 @@
defaultBranch = master defaultBranch = master
[user] [user]
name = david name = david
email = david@silverwolf.studio email = placeholder

View File

@@ -1,10 +1,10 @@
local omitted_dirs=( tmux_omitted_dirs=(
$HOME $HOME
$DIR_HOME_BOX $DIR_HOME_BOX
$DIR_DEV $DIR_DEV
$DIR_GIT_PROJECTS $DIR_GIT_PROJECTS
) )
[[ ! ${omitted_dirs[(re)$(pwd)]} ]] && [[ ! ${tmux_omitted_dirs[(re)$(pwd)]} ]] &&
tmux new-window -d -n cmd && tmux new-window -d -n cmd &&
tmux rename-window $EDITOR && tmux rename-window $EDITOR &&
$EDITOR . $EDITOR .

View File

@@ -7,8 +7,8 @@ export DIR_HOME_BOX="$HOME/dbox"
export DIR_MUSIC="$DIR_HOME_BOX/media/music" export DIR_MUSIC="$DIR_HOME_BOX/media/music"
export DIR_DEV="$HOME/dev" export DIR_DEV="$HOME/dev"
export DIR_GIT_PROJECTS="$DIR_DEV/git" export DIR_GIT_PROJECTS="$DIR_DEV/git"
export DIR_SCRATCH_NOTES="$DIR_HOME_BOX/life/scratchpad/notes" export DIR_SCRATCH_NOTES="$DIR_HOME_BOX/scratchpad/notes"
export DIR_SCRATCH_DRAWINGS="$DIR_HOME_BOX/life/scratchpad/drawings" export DIR_SCRATCH_DRAWINGS="$DIR_HOME_BOX/scratchpad/drawings"
# util dirs; do not change without checking impact on xdg base dirs # util dirs; do not change without checking impact on xdg base dirs
export DIR_LOCAL="$HOME/.local" export DIR_LOCAL="$HOME/.local"

View File

@@ -16,9 +16,8 @@ alias nv='nvim'
alias n='nvim' alias n='nvim'
alias tms='tmux-session-init' alias tms='tmux-session-init'
# executable name overrides # executable overrides
alias ls='ls -F' alias ls='ls -F'
alias yt-dlp='yt-dlp --write-info-json'
# misc commands # misc commands
alias cal='khal calendar' alias cal='khal calendar'

View File

@@ -11,7 +11,7 @@ alias gfo='git fetch origin'
alias git-push-to-temp='git branch -D temp; git checkout -b temp; git push origin temp -uf; git checkout -' alias git-push-to-temp='git branch -D temp; git checkout -b temp; git push origin temp -uf; git checkout -'
alias gpdev='git-push-to-temp' alias gpdev='git-push-to-temp'
alias gpo='git pull origin' alias gpo='git pull origin'
git config --global user.email "$EMAIL_PERSONAL_DEV" git config --global user.email "$EMAIL_PERSONAL_DEV" # TODO: maybe fit this into system-type filters?
# code/test/linter run and build commands # code/test/linter run and build commands
alias bel='bundle exec standardrb' alias bel='bundle exec standardrb'

View File

@@ -1,5 +1,5 @@
#!/bin/zsh #!/bin/zsh
local target_dir=$(dirname "${@: -1}") mvd_target_dir=$(dirname "${@: -1}")
[[ ! -d "$target_dir" ]] && mkdir -p "$target_dir" [[ ! -d "$mvd_target_dir" ]] && mkdir -p "$mvd_target_dir"
exec mv "$@" exec mv "$@"

View File

@@ -1,10 +1,10 @@
#!/bin/zsh #!/bin/zsh
switch_to() { tmux_switch_to() {
[[ -z $TMUX ]] && tmux attach-session -t $1 || tmux switch-client -t $1 [[ -z $TMUX ]] && tmux attach-session -t $1 || tmux switch-client -t $1
} }
hydrate() { tmux_hydrate() {
local tmux_hydrate_files_dir="$XDG_CONFIG_HOME/tmux/session-hydrate-files" local tmux_hydrate_files_dir="$XDG_CONFIG_HOME/tmux/session-hydrate-files"
local tmux_hydrate_path="$tmux_hydrate_files_dir/.tmux-session-hydrate-default" local tmux_hydrate_path="$tmux_hydrate_files_dir/.tmux-session-hydrate-default"
[[ $1 = "thinking" ]] && tmux_hydrate_path="$tmux_hydrate_files_dir/.tmux-session-hydrate-thinking" [[ $1 = "thinking" ]] && tmux_hydrate_path="$tmux_hydrate_files_dir/.tmux-session-hydrate-thinking"
@@ -13,28 +13,28 @@ hydrate() {
[[ -f $tmux_hydrate_path ]] && tmux send-keys -t $1 "source $tmux_hydrate_path" c-M [[ -f $tmux_hydrate_path ]] && tmux send-keys -t $1 "source $tmux_hydrate_path" c-M
} }
local existing_sessions=$([[ -n $(pgrep tmux) ]] && tmux list-sessions || echo '') tmux_existing_sessions=$([[ -n $(pgrep tmux) ]] && tmux list-sessions || echo '')
local search_dirs=( tmux_search_dirs=(
$DIR_HOME_BOX $DIR_HOME_BOX
$DIR_DEV $DIR_DEV
$DIR_GIT_PROJECTS/* $DIR_GIT_PROJECTS/*
) )
local target_name='' tmux_target_name=''
local target_path='' tmux_target_path=''
[[ $# -eq 1 ]] && target_path=$1 || [[ $# -eq 1 ]] && tmux_target_path=$1 ||
target_path=$(find $search_dirs -mindepth 1 -maxdepth 1 -type d | fzf) tmux_target_path=$(find $tmux_search_dirs -mindepth 1 -maxdepth 1 -type d | fzf)
if [[ $target_path = "." ]]; then target_name=$(basename $(pwd)) && target_path=$(pwd); if [[ $tmux_target_path = "." ]]; then tmux_target_name=$(basename $(pwd)) && tmux_target_path=$(pwd);
elif [[ $target_path = "hub" ]]; then target_name="hub" && target_path="$HOME"; elif [[ $tmux_target_path = "hub" ]]; then tmux_target_name="hub" && tmux_target_path="$HOME";
elif [[ $target_path = "thinking" ]]; then target_name="thinking" && target_path="$DIR_SCRATCH_NOTES"; elif [[ $tmux_target_path = "thinking" ]]; then tmux_target_name="thinking" && tmux_target_path="$DIR_SCRATCH_NOTES";
elif [[ $target_path = "listening" ]]; then target_name="listening" && target_path="$DIR_MUSIC"; elif [[ $tmux_target_path = "listening" ]]; then tmux_target_name="listening" && tmux_target_path="$DIR_MUSIC";
elif [[ -n $target_path ]]; then target_name=$(basename "$target_path" | tr . _); elif [[ -n $tmux_target_path ]]; then tmux_target_name=$(basename "$tmux_target_path" | tr . _);
fi fi
[[ -z $target_name ]] && exit 0 [[ -z $tmux_target_name ]] && exit 0
! (echo $existing_sessions | grep -q "$target_name") && ! (echo $tmux_existing_sessions | grep -q "$tmux_target_name") &&
tmux new-session -d -s $target_name -c $target_path && tmux new-session -d -s $tmux_target_name -c $tmux_target_path &&
hydrate $target_name $target_path tmux_hydrate $tmux_target_name $tmux_target_path
switch_to $target_name tmux_switch_to $tmux_target_name