diff --git a/README.md b/README.md index 6856155..b37aa21 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,8 @@ ### script run - (run these commands from repo's root dir) -- to do the full setup, run: `./box_setup.sh ` +- to do the full setup, run: `./box_setup.sh` - to copy dotfiles only, run: `./copy_dotfiles.sh` - - NOTE: the `copy_dotfiles.sh` script may not work if ENV vars are not set as expected ### after script run - complete manual actions specified in [ref/post-run-manual](ref/post-run-manual.md) diff --git a/box_setup.sh b/box_setup.sh index 34d2d3e..c06cfb6 100755 --- a/box_setup.sh +++ b/box_setup.sh @@ -1,41 +1,47 @@ #!/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" + echo "\nusage: ./box_setup.sh [system-type]" + echo "\nsystem-type options: personal, studio-music, work-placeholder" + echo "\nexamples:\n ./box_setup.sh\n ./box_setup.sh studio-music\n" exit 0 } -# 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 +# determine OS and, if linux, distro +[[ "$OSTYPE" = *"darwin"* ]] && setup_os="macos" || { + [[ "$OSTYPE" = *"linux"* ]] && setup_os="linux" && { + [[ -f /etc/os-release ]] && . /etc/os-release + setup_distro=$(echo "${NAME%% *}" | tr '[:upper:]' '[:lower:]') + [[ -z "$setup_distro" ]] && echo "OS: linux; distro not detected" && exit 1 + } +} +[[ -z "$setup_os" ]] && echo "OS not detected" && exit 1 -export BOX_SETUP_OS=$1 +# set package manager commands for installs +[[ "$setup_os" = "macos" ]] && { + install_cmd="brew install" + update_pkg_manager_and_defs_cmd='brew update' + update_pkgs_cmd='brew upgrade' +} || { + [[ "$setup_os" = "linux" ]] && { + case $setup_distro 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' + ;; + esac + } +} + +# export vars for scripts +export BOX_SETUP_OS="$setup_os" +export BOX_SETUP_DISTRO="$setup_distro" 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" @@ -43,10 +49,10 @@ 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_dotfiles.sh $2 +./copy_dotfiles.sh $1 # install programs source $ZDOTDIR/.zshenv source $ZDOTDIR/.zshrc -./install_programs.sh $2 +./install_programs.sh $1 diff --git a/copy_dotfiles.sh b/copy_dotfiles.sh index d45b6fc..df7dc5c 100755 --- a/copy_dotfiles.sh +++ b/copy_dotfiles.sh @@ -40,7 +40,7 @@ copy_file src_files/.config/zsh/.zshenv $HOME # duplicate, copy anyway, ensures copy_dir src_files/.config $XDG_CONFIG_HOME copy_dir src_files/.local/bin $DIR_BIN -[[ "$BOX_SETUP_OS" = "macos" ]] && copy_dir src_files/bin_overrides_macos $DIR_BIN +[[ "$OSTYPE" = *"darwin"* ]] && copy_dir src_files/bin_overrides_macos $DIR_BIN copy_dir src_files/.local/scripts $DIR_SCRIPTS for obs_dir in "${OBSIDIAN_WORKSPACES_TO_CONFIGURE[@]}"; do @@ -49,7 +49,7 @@ for obs_dir in "${OBSIDIAN_WORKSPACES_TO_CONFIGURE[@]}"; do done # [[ $1 = "studio-music" ]] { -# [[ "$BOX_SETUP_OS" = "macos" ]] && +# [[ "$OSTYPE" = *"darwin"* ]] && # link_dir "$XDG_CONFIG_HOME/REAPER" "$HOME/Library/Application Support/REAPER" # TODO: get reaper config set up # } diff --git a/installs_and_builds/s31_docker b/installs_and_builds/s31_docker index 6e9e34b..25f5375 100755 --- a/installs_and_builds/s31_docker +++ b/installs_and_builds/s31_docker @@ -7,15 +7,7 @@ setup_docker_on_debian() { echo "setup_docker_on_debian function not implemented" } -# TODO: decide on docker vs others; below is included just for reference -# case $BOX_SETUP_OS in -# (arch | artix) -# ${=BOX_SETUP_INSTALL_COMMAND} docker -# ;; -# (debian) -# setup_docker_on_debian -# ;; -# (macos) -# ${=BOX_SETUP_INSTALL_COMMAND} docker -# ;; -# esac +# TODO: decide on docker vs others +[[ "$BOX_SETUP_DISTRO" = "debian" ]] && setup_docker_on_debian || { + ${=BOX_SETUP_INSTALL_COMMAND} docker +} diff --git a/ref/macos-system-settings.txt b/ref/macos-system-settings.txt index 536a9ba..27bf6b3 100644 --- a/ref/macos-system-settings.txt +++ b/ref/macos-system-settings.txt @@ -1,4 +1,4 @@ -// settings for manual configuration in macos system settings app +// settings for manual configuration in macOS system settings app // NOTE: some of these could be scripted, but for now i'm okay with this manual list - desktop/dock/mission-control: diff --git a/src_files/.config/nvim/lua/key_mappings.lua b/src_files/.config/nvim/lua/key_mappings.lua index 35fef2a..5d7e747 100644 --- a/src_files/.config/nvim/lua/key_mappings.lua +++ b/src_files/.config/nvim/lua/key_mappings.lua @@ -116,11 +116,11 @@ kmgAutocmd('LspAttach', { -- telescope local tscBuiltin = require('telescope.builtin') -local custom_tscope_grep = function() - tscBuiltin.grep_string({ search = vim.fn.input("grep > ")}) +local custom_grep_str_w_regex = function() + tscBuiltin.grep_string({ search = vim.fn.input("grep > "), use_regex = true, additional_args = "-i", }) end vim.keymap.set('n', 'ft', tscBuiltin.live_grep, { desc = 'tscope find text, live_grep' }) -vim.keymap.set('n', 'fT', custom_tscope_grep, { desc = 'tscope find text, custom grep' }) +vim.keymap.set('n', 'fT', custom_grep_str_w_regex, { desc = 'tscope find text, static grep w/regex' }) vim.keymap.set('n', 'fg', tscBuiltin.git_files, { desc = 'tscope find git-tracked files' }) vim.keymap.set('n', 'ff', tscBuiltin.find_files, { desc = 'tscope find files' }) vim.keymap.set('n', 'fb', tscBuiltin.buffers, { desc = 'tscope buffers' }) diff --git a/src_files/.config/nvim/lua/plugins_lazy/telescope.lua b/src_files/.config/nvim/lua/plugins_lazy/telescope.lua index 10e0c94..9ca45e0 100644 --- a/src_files/.config/nvim/lua/plugins_lazy/telescope.lua +++ b/src_files/.config/nvim/lua/plugins_lazy/telescope.lua @@ -1,12 +1,3 @@ -local glob_patterns_find_files = { - "-g", "!**/.git/**", - "-g", "!**/build/**", - "-g", "!**/node_modules/**", -} -local glob_patterns_live_grep = { - unpack(glob_patterns_find_files), -- same for now -} - return { "nvim-telescope/telescope.nvim", tag = "0.1.8", @@ -27,13 +18,17 @@ return { find_files = { find_command = { "rg", "--no-ignore", "--hidden", "--files", - unpack(glob_patterns_find_files), + "-g", "!**/.git/**", + "-g", "!**/build/**", + "-g", "!**/node_modules/**", }, }, live_grep = { additional_args = { "--no-ignore", "--hidden", - unpack(glob_patterns_live_grep), + "-g", "!**/.git/**", + "-g", "!**/build/**", + "-g", "!**/node_modules/**", } }, },