diff --git a/README.md b/README.md index 92920e3..f16d1c0 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,11 @@ -# dotfiles plus scripts to copy them and also install stuff +# dotfiles, plus scripts for box setup -### script run -- fulfill prerequisites below -- git clone this repo -- from the repo's root directory, run `./box_setup ` - -### prerequisites -- package manager is configured (i.e. source repos, mirrors, etc. configured) +### prereqs, linux distros - zsh is installed (scripts are written for zsh) -- sudo access is configured for current user (as of 2025-01-27, not needed on macos) -- system-specific items below are fulfilled +- sudo access is configured for current user -##### prereqs, os specific, linux-placeholder -- (currently none) - -##### prereqs, os specific, macos +### prereqs, macos +- zsh is installed (scripts are written for zsh) - install the package manager, [homebrew](https://brew.sh/) - for yabai window manager (so as to not mess with SIP settings) - create 9 spaces/desktops @@ -27,18 +18,24 @@ - `displays have separate spaces`: enabled - `show files on desktop`: enabled +### script run +- if repo present on system, run from the repo's root: + - ``` + ./box_setup.sh + ``` +- if repo not present, run: + - ``` + curl -LO https://git.drinkingtea.net/david/box-setup/raw/branch/master/box_setup.sh + sh box_setup.sh + ``` + - then delete the script file afterwards (repo should have been copied to dev dir) + ### todo items -- add logic to the main run script to handle cloning of this repo -- config for window manager for linux (first, decide which wm to use) -- config for terminal emulator (currently ghostty) -- config for mpd, mpc, ncmpcpp -- config for mpv +- choose window manager for linux, then configure +- config for: terminal (ghostty); mpd, mpc, ncmpcpp; mpv - config for gimp, `src_files/.config/GIMP` (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 -- 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 - asdf, or language-specific version managers? - docker? or alternatives like podman? any license concerns? - - hybrid of the above? diff --git a/box_setup b/box_setup deleted file mode 100755 index b6f7c55..0000000 --- a/box_setup +++ /dev/null @@ -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 diff --git a/box_setup.sh b/box_setup.sh new file mode 100755 index 0000000..3160640 --- /dev/null +++ b/box_setup.sh @@ -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 [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/" +} diff --git a/copy_configs b/copy_configs.sh similarity index 83% rename from copy_configs rename to copy_configs.sh index c997961..438391d 100755 --- a/copy_configs +++ b/copy_configs.sh @@ -35,7 +35,7 @@ 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 @@ -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/scripts $DIR_SCRIPTS -[[ "$BOX_SETUP_OS" = "macos" ]] && - # link_dir "$XDG_CONFIG_HOME/REAPER" "$HOME/Library/Application Support/REAPER" && # TODO: get reaper config set up +[[ "$BOX_SETUP_OS" = "macos" ]] && { copy_dir src_files/executable_wrappers_macos $DIR_BIN 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 diff --git a/install_programs b/install_programs deleted file mode 100755 index 60bff91..0000000 --- a/install_programs +++ /dev/null @@ -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 - diff --git a/install_programs.sh b/install_programs.sh new file mode 100755 index 0000000..9b6bee2 --- /dev/null +++ b/install_programs.sh @@ -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[@]}" + diff --git a/installs_and_builds/manual_runs/s99_neovim_from_source b/installs_and_builds/manual_runs/s99_neovim_from_source index 270c0f2..9dc98b9 100755 --- a/installs_and_builds/manual_runs/s99_neovim_from_source +++ b/installs_and_builds/manual_runs/s99_neovim_from_source @@ -1,17 +1,17 @@ #!/bin/zsh -local neovim_dir=$HOME/.local/build/neovim -local neovim_version="v0.10.3" -[ ! -z $NVIM_VERSION ] && neovim_version="$NVIM_VERSION" -echo "neovim_version: \"$neovim_version\"" +install_neovim_dir=$HOME/.local/build/neovim +install_neovim_version="v0.10.3" +[ ! -z $NVIM_VERSION ] && install_neovim_version="$NVIM_VERSION" +echo "install_neovim_version: \"$install_neovim_version\"" -[ ! -d $neovim_dir ] && git clone https://github.com/neovim/neovim.git $neovim_dir -git -C $neovim_dir fetch --all -git -C $neovim_dir checkout $neovim_version +[ ! -d $install_neovim_dir ] && git clone https://github.com/neovim/neovim.git $install_neovim_dir +git -C $install_neovim_dir fetch --all +git -C $install_neovim_dir checkout $install_neovim_version -make -C $neovim_dir clean -make -C $neovim_dir CMAKE_BUILD_TYPE=RelWithDebInfo -sudo make -C $neovim_dir install +make -C $install_neovim_dir clean +make -C $install_neovim_dir CMAKE_BUILD_TYPE=RelWithDebInfo +sudo make -C $install_neovim_dir install # from primeagen's dev repo, uncomment/edit as needed # git clone https://github.com/ThePrimeagen/harpoon.git $HOME/personal/harpoon diff --git a/installs_and_builds/personal/placeholder-TODO b/installs_and_builds/personal/placeholder-TODO new file mode 100644 index 0000000..e69de29 diff --git a/installs_and_builds/s04_terminal b/installs_and_builds/s04_terminal index e5b07fc..55cc7ad 100755 --- a/installs_and_builds/s04_terminal +++ b/installs_and_builds/s04_terminal @@ -1,6 +1,6 @@ #!/bin/zsh -local option_prefix='' -[[ "$BOX_SETUP_OS" = "macos" ]] && option_prefix='--cask' +install_option_prefix='' +[[ "$BOX_SETUP_OS" = "macos" ]] && install_option_prefix='--cask' # 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 diff --git a/installs_and_builds/s06_window_manager b/installs_and_builds/s06_window_manager index c3f777e..f80c671 100755 --- a/installs_and_builds/s06_window_manager +++ b/installs_and_builds/s06_window_manager @@ -1,11 +1,11 @@ #!/bin/zsh -local linux_wm_and_utils() { +linux_wm_and_utils() { # TODO: pick wm for linux; options: dwm, i3, others? 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/skhd skhd --start-service diff --git a/installs_and_builds/s12_web_browser b/installs_and_builds/s12_web_browser index 63b7566..bb441c9 100755 --- a/installs_and_builds/s12_web_browser +++ b/installs_and_builds/s12_web_browser @@ -1,8 +1,8 @@ #!/bin/zsh # TODO: replace firefox with brave or another browser -# local option_prefix='' -# [[ "$BOX_SETUP_OS" = "macos" ]] && option_prefix='--cask' -# local firefox_package_name='firefox' +# install_option_prefix='' +# [[ "$BOX_SETUP_OS" = "macos" ]] && install_option_prefix='--cask' +# firefox_package_name='firefox' # [[ "$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" diff --git a/installs_and_builds/s20_audio_editor b/installs_and_builds/s20_audio_editor index 994d1bf..78e69be 100755 --- a/installs_and_builds/s20_audio_editor +++ b/installs_and_builds/s20_audio_editor @@ -1,6 +1,6 @@ #!/bin/zsh # only audio editor(s) in this file; daws are handled separately -local option_prefix='' -[[ "$BOX_SETUP_OS" = "macos" ]] && option_prefix='--cask' -${=BOX_SETUP_INSTALL_COMMAND} "$option_prefix" audacity +install_option_prefix='' +[[ "$BOX_SETUP_OS" = "macos" ]] && install_option_prefix='--cask' +${=BOX_SETUP_INSTALL_COMMAND} "$install_option_prefix" audacity diff --git a/installs_and_builds/s22_image_editor b/installs_and_builds/s22_image_editor index 9a5ee10..74e4e0d 100755 --- a/installs_and_builds/s22_image_editor +++ b/installs_and_builds/s22_image_editor @@ -1,7 +1,7 @@ #!/bin/zsh -local option_prefix='' -[[ "$BOX_SETUP_OS" = "macos" ]] && option_prefix='--cask' -${=BOX_SETUP_INSTALL_COMMAND} "$option_prefix" gimp +install_option_prefix='' +[[ "$BOX_SETUP_OS" = "macos" ]] && install_option_prefix='--cask' +${=BOX_SETUP_INSTALL_COMMAND} "$install_option_prefix" gimp # ${=BOX_SETUP_INSTALL_COMMAND} imagemagick # TODO: consider this program too diff --git a/installs_and_builds/s49_languages_general b/installs_and_builds/s49_languages_general index 6d29520..a40cf10 100755 --- a/installs_and_builds/s49_languages_general +++ b/installs_and_builds/s49_languages_general @@ -2,10 +2,10 @@ # TODO: review and decide if the things below are needed -#local lua_package="lua5.1" -#[[ "$BOX_SETUP_OS" = "macos" ]] && lua_package="lua@5.1" +# install_lua_package="lua5.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 #luarocks install luacheck diff --git a/installs_and_builds/studio_music/placeholder-TODO b/installs_and_builds/studio_music/placeholder-TODO new file mode 100644 index 0000000..e69de29 diff --git a/make_dirs b/make_dirs.sh similarity index 100% rename from make_dirs rename to make_dirs.sh diff --git a/src_files/.config/git/config b/src_files/.config/git/config index 88702b3..6b115bd 100644 --- a/src_files/.config/git/config +++ b/src_files/.config/git/config @@ -2,4 +2,4 @@ defaultBranch = master [user] name = david - email = david@silverwolf.studio + email = placeholder diff --git a/src_files/.config/tmux/session-hydrate-files/.tmux-session-hydrate-default b/src_files/.config/tmux/session-hydrate-files/.tmux-session-hydrate-default index 79cc297..8ab6ea1 100644 --- a/src_files/.config/tmux/session-hydrate-files/.tmux-session-hydrate-default +++ b/src_files/.config/tmux/session-hydrate-files/.tmux-session-hydrate-default @@ -1,10 +1,10 @@ -local omitted_dirs=( +tmux_omitted_dirs=( $HOME $DIR_HOME_BOX $DIR_DEV $DIR_GIT_PROJECTS ) -[[ ! ${omitted_dirs[(re)$(pwd)]} ]] && +[[ ! ${tmux_omitted_dirs[(re)$(pwd)]} ]] && tmux new-window -d -n cmd && tmux rename-window $EDITOR && $EDITOR . diff --git a/src_files/.config/zsh/.zshenv b/src_files/.config/zsh/.zshenv index 644967d..ac464ed 100644 --- a/src_files/.config/zsh/.zshenv +++ b/src_files/.config/zsh/.zshenv @@ -7,8 +7,8 @@ export DIR_HOME_BOX="$HOME/dbox" export DIR_MUSIC="$DIR_HOME_BOX/media/music" export DIR_DEV="$HOME/dev" export DIR_GIT_PROJECTS="$DIR_DEV/git" -export DIR_SCRATCH_NOTES="$DIR_HOME_BOX/life/scratchpad/notes" -export DIR_SCRATCH_DRAWINGS="$DIR_HOME_BOX/life/scratchpad/drawings" +export DIR_SCRATCH_NOTES="$DIR_HOME_BOX/scratchpad/notes" +export DIR_SCRATCH_DRAWINGS="$DIR_HOME_BOX/scratchpad/drawings" # util dirs; do not change without checking impact on xdg base dirs export DIR_LOCAL="$HOME/.local" diff --git a/src_files/.config/zsh/.zshrc b/src_files/.config/zsh/.zshrc index cb6ca6f..bcf6873 100644 --- a/src_files/.config/zsh/.zshrc +++ b/src_files/.config/zsh/.zshrc @@ -16,9 +16,8 @@ alias nv='nvim' alias n='nvim' alias tms='tmux-session-init' -# executable name overrides +# executable overrides alias ls='ls -F' -alias yt-dlp='yt-dlp --write-info-json' # misc commands alias cal='khal calendar' diff --git a/src_files/.config/zsh/zsh-general-dev b/src_files/.config/zsh/zsh-general-dev index 7d7ec29..2989880 100644 --- a/src_files/.config/zsh/zsh-general-dev +++ b/src_files/.config/zsh/zsh-general-dev @@ -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 gpdev='git-push-to-temp' 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 alias bel='bundle exec standardrb' diff --git a/src_files/.local/bin/mvd b/src_files/.local/bin/mvd index 6e04ec8..195bd8d 100755 --- a/src_files/.local/bin/mvd +++ b/src_files/.local/bin/mvd @@ -1,5 +1,5 @@ #!/bin/zsh -local target_dir=$(dirname "${@: -1}") -[[ ! -d "$target_dir" ]] && mkdir -p "$target_dir" +mvd_target_dir=$(dirname "${@: -1}") +[[ ! -d "$mvd_target_dir" ]] && mkdir -p "$mvd_target_dir" exec mv "$@" diff --git a/src_files/.local/scripts/tmux-session-init b/src_files/.local/scripts/tmux-session-init index 41b1b9f..8ef99eb 100755 --- a/src_files/.local/scripts/tmux-session-init +++ b/src_files/.local/scripts/tmux-session-init @@ -1,10 +1,10 @@ #!/bin/zsh -switch_to() { +tmux_switch_to() { [[ -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_path="$tmux_hydrate_files_dir/.tmux-session-hydrate-default" [[ $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 } -local existing_sessions=$([[ -n $(pgrep tmux) ]] && tmux list-sessions || echo '') -local search_dirs=( +tmux_existing_sessions=$([[ -n $(pgrep tmux) ]] && tmux list-sessions || echo '') +tmux_search_dirs=( $DIR_HOME_BOX $DIR_DEV $DIR_GIT_PROJECTS/* ) -local target_name='' -local target_path='' +tmux_target_name='' +tmux_target_path='' -[[ $# -eq 1 ]] && target_path=$1 || - target_path=$(find $search_dirs -mindepth 1 -maxdepth 1 -type d | fzf) +[[ $# -eq 1 ]] && tmux_target_path=$1 || + 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); -elif [[ $target_path = "hub" ]]; then target_name="hub" && target_path="$HOME"; -elif [[ $target_path = "thinking" ]]; then target_name="thinking" && target_path="$DIR_SCRATCH_NOTES"; -elif [[ $target_path = "listening" ]]; then target_name="listening" && target_path="$DIR_MUSIC"; -elif [[ -n $target_path ]]; then target_name=$(basename "$target_path" | tr . _); +if [[ $tmux_target_path = "." ]]; then tmux_target_name=$(basename $(pwd)) && tmux_target_path=$(pwd); +elif [[ $tmux_target_path = "hub" ]]; then tmux_target_name="hub" && tmux_target_path="$HOME"; +elif [[ $tmux_target_path = "thinking" ]]; then tmux_target_name="thinking" && tmux_target_path="$DIR_SCRATCH_NOTES"; +elif [[ $tmux_target_path = "listening" ]]; then tmux_target_name="listening" && tmux_target_path="$DIR_MUSIC"; +elif [[ -n $tmux_target_path ]]; then tmux_target_name=$(basename "$tmux_target_path" | tr . _); fi -[[ -z $target_name ]] && exit 0 +[[ -z $tmux_target_name ]] && exit 0 -! (echo $existing_sessions | grep -q "$target_name") && - tmux new-session -d -s $target_name -c $target_path && - hydrate $target_name $target_path -switch_to $target_name +! (echo $tmux_existing_sessions | grep -q "$tmux_target_name") && + tmux new-session -d -s $tmux_target_name -c $tmux_target_path && + tmux_hydrate $tmux_target_name $tmux_target_path +tmux_switch_to $tmux_target_name