Add auto-detection of OS and distro to scripts
This commit is contained in:
@@ -14,9 +14,8 @@
|
||||
|
||||
### script run
|
||||
- (run these commands from repo's root dir)
|
||||
- to do the full setup, run: `./box_setup.sh <OS-name>`
|
||||
- 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)
|
||||
|
72
box_setup.sh
72
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 <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"
|
||||
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
|
||||
|
||||
|
@@ -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
|
||||
# }
|
||||
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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:
|
||||
|
@@ -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', '<leader>ft', tscBuiltin.live_grep, { desc = 'tscope find text, live_grep' })
|
||||
vim.keymap.set('n', '<leader>fT', custom_tscope_grep, { desc = 'tscope find text, custom grep' })
|
||||
vim.keymap.set('n', '<leader>fT', custom_grep_str_w_regex, { desc = 'tscope find text, static grep w/regex' })
|
||||
vim.keymap.set('n', '<leader>fg', tscBuiltin.git_files, { desc = 'tscope find git-tracked files' })
|
||||
vim.keymap.set('n', '<leader>ff', tscBuiltin.find_files, { desc = 'tscope find files' })
|
||||
vim.keymap.set('n', '<leader>fb', tscBuiltin.buffers, { desc = 'tscope buffers' })
|
||||
|
@@ -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/**",
|
||||
}
|
||||
},
|
||||
},
|
||||
|
Reference in New Issue
Block a user