Compare commits

...

5 Commits

23 changed files with 107 additions and 79 deletions

View File

@ -1,6 +1,12 @@
### script run plan
- run `./pre_run*` scripts
- run `./run` to install/build/etc programs
- run `./copy_configs` to copy configs/scripts/executables into place
- run `./post_config*` scripts
# repo containing configs and scripts to set up a box
### prerequisites
- install git if not already installed
- clone this repo
- if on macOS, install [homebrew](https://brew.sh/)
- export the env var `BOX_SETUP_OS` to indicate the operating system
-- (options defined in `set_env_vars` file)
### script run
- from the repo's root directory, run `./setup_this_box`

View File

@ -17,11 +17,9 @@ while [[ $# > 0 ]]; do
shift
done
local script_dir=$(cd $(dirname "${ZSH_SOURCE[0]}") &> /dev/null && pwd)
log "run // script_dir: $script_dir -- args: $single_script_filter"
cd $script_dir
local scripts=(`find ./runs -maxdepth 1 -mindepth 1 -type f`)
for script in $scripts; do
log "install_programs // single_script_filter: $single_script_filter"
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
log "filter is $single_script_filter // ignoring: $script"

6
installs_and_builds/s01_libs Executable file
View File

@ -0,0 +1,6 @@
#!/bin/zsh
local lua_package="lua5.1"
[[ "$BOX_SETUP_OS" = "macos" ]] && lua_package="lua@5.1"
${=BOX_SETUP_INSTALL_COMMAND} cmake gettext "$lua_package" liblua5.1-0-dev

View File

@ -2,4 +2,4 @@
# likely on unix systems already: find xargs grep sed awk
brew install jq parallel
${=BOX_SETUP_INSTALL_COMMAND} jq parallel

2
installs_and_builds/s11_git Executable file
View File

@ -0,0 +1,2 @@
#!/bin/zsh
${=BOX_SETUP_INSTALL_COMMAND} git

3
installs_and_builds/s12_neovim Executable file
View File

@ -0,0 +1,3 @@
#!/bin/zsh
${=BOX_SETUP_INSTALL_COMMAND} neovim

2
installs_and_builds/s13_tmux Executable file
View File

@ -0,0 +1,2 @@
#!/bin/zsh
${=BOX_SETUP_INSTALL_COMMAND} tmux

2
installs_and_builds/s14_fzf Executable file
View File

@ -0,0 +1,2 @@
#!/bin/zsh
${=BOX_SETUP_INSTALL_COMMAND} fzf

View File

@ -1,22 +1,17 @@
#!/bin/zsh
local install_command="sudo apt install"
[[ -x $(which brew) ]] && install_command="brew install"
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\""
[ ! -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
$install_command cmake gettext lua@5.1 liblua5.1-0-dev
make -C $neovim_dir clean
make -C $neovim_dir CMAKE_BUILD_TYPE=RelWithDebInfo
sudo make -C $neovim_dir install
# 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\""
#
# [ ! -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
#
# make -C $neovim_dir clean
# make -C $neovim_dir CMAKE_BUILD_TYPE=RelWithDebInfo
# sudo make -C $neovim_dir install
# lines below from primeagen's dev repo, uncomment/edit as needed
# git clone https://github.com/ThePrimeagen/harpoon.git $HOME/personal/harpoon

7
make_config_dirs Executable file
View File

@ -0,0 +1,7 @@
#!/bin/zsh
[[ ! -d $HOME/.config ]] && mkdir $HOME/.config
[[ ! -d $HOME/.local ]] && mkdir $HOME/.local
[[ ! -d $HOME/.local/bin ]] && mkdir $HOME/.local/bin
[[ ! -d $HOME/.local/build ]] && mkdir $HOME/.local/build
[[ ! -d $HOME/.local/tmp ]] && mkdir $HOME/.local/tmp

4
make_desired_dirs Executable file
View File

@ -0,0 +1,4 @@
#!/bin/zsh
[[ ! -d $HOMEBOX ]] && mkdir $HOMEBOX
[[ ! -d $DEVDIR ]] && mkdir $DEVDIR

View File

@ -1,8 +0,0 @@
#!/bin/zsh
mkdirs_after_setting_shell_env_vars() {
[[ ! -d $HOMEBOX ]] && mkdir $HOMEBOX
[[ ! -d $DEVDIR ]] && mkdir $DEVDIR
}
mkdirs_after_setting_shell_env_vars

View File

@ -1,11 +0,0 @@
#!/bin/zsh
mkdirs_before_copying_config_files() {
[[ ! -d $HOME/.config ]] && mkdir $HOME/.config
[[ ! -d $HOME/.local ]] && mkdir $HOME/.local
[[ ! -d $HOME/.local/bin ]] && mkdir $HOME/.local/bin
[[ ! -d $HOME/.local/build ]] && mkdir $HOME/.local/build
[[ ! -d $HOME/.local/tmp ]] && mkdir $HOME/.local/tmp
}
mkdirs_before_copying_config_files

View File

@ -1,2 +0,0 @@
#!/bin/zsh
brew install fzf

View File

@ -1,2 +0,0 @@
#!/bin/zsh
brew install git

View File

@ -1,2 +0,0 @@
#!/bin/zsh
# brew install <placeholder>

View File

@ -1,2 +0,0 @@
#!/bin/zsh
brew install tmux

12
set_env_vars Normal file
View File

@ -0,0 +1,12 @@
[[ -z $BOX_SETUP_OS ]] &&
echo "BOX_SETUP_OS must be set; options: arch, artix, debian, macos" &&
exit 1
local install_cmd=''
case $BOX_SETUP_OS in
(arch | artix) install_cmd="sudo pacman -S" ;;
(debian) export install_cmd="sudo apt install" ;;
(macos) export install_cmd="brew install" ;;
esac
export BOX_SETUP_INSTALL_COMMAND="$install_cmd"

7
setup_this_box Executable file
View File

@ -0,0 +1,7 @@
#!/bin/zsh
source set_env_vars
./install_programs
./make_config_dirs
./copy_configs
./make_desired_dirs

View File

@ -21,10 +21,13 @@ bind -r l select-pane -R
bind r source-file "~/.config/tmux/tmux.conf" \; display-message "tmux.conf reloaded"
# kill the current session
bind Q rename-session zzzz-temp-kill\; switch-client -p\; kill-session -t zzzz-temp-kill
bind-key Q rename-session zzzz-temp-kill\; switch-client -p\; kill-session -t zzzz-temp-kill
bind-key W kill-session
# use tmux-sessionizer in place of f find
bind-key -r f run-shell "tmux neww ~/.local/bin/tmux-sessionizer"
# custom find using tmux-sessionizer
unbind-key f
bind-key f run-shell "tmux neww ~/.local/bin/tmux-sessionizer existing"
bind-key F run-shell "tmux neww ~/.local/bin/tmux-sessionizer"
# bind -r D neww -c "#{pane_current_path}" "[[ -e TODO.md ]] && $EDITOR TODO.md || $EDITOR ~/personal/dev/todo.md"

View File

@ -1,5 +1,3 @@
#!/bin/zsh
local omitted_dirs=(
$HOME
$HOMEBOX
@ -13,3 +11,11 @@ local omitted_dirs=(
clear
## example template for custom override
# tmux new-window -d -n cmd
# tmux send-keys -t :cmd "echo 'in cmd'" c-M
# tmux new-window -d -n another
# tmux send-keys -t :another "echo 'in another'" c-M
# tmux rename-window $EDITOR
# $EDITOR .
# clear

View File

@ -4,35 +4,33 @@ switch_to() {
[[ -z $TMUX ]] && tmux attach-session -t $1 || tmux switch-client -t $1
}
tmux_session_exists() {
[[ -n $(pgrep tmux) ]] && tmux list-sessions | grep -q "^$1:"
}
hydrate() {
local tmux_hydrate_path="$HOME/.local/bin/.tmux-session-hydrate"
[[ -f $2/.tmux-session-hydrate ]] && tmux_hydrate_path="$2/.tmux-session-hydrate"
[[ -f $tmux_hydrate_path ]] && tmux send-keys -t $1 "source $tmux_hydrate_path" c-M
}
local name_regex="^\([-_A-Za-z0-9]*\):.*$"
local existing_sessions=$([[ -n $(pgrep tmux) ]] && tmux list-sessions | sed "s/$name_regex/\1/" || echo '')
local search_dirs=(
$HOMEBOX
$DEVDIR
$DEVDIR/git/*
)
local selected_path=''
[[ $# -eq 1 ]] && selected_path=$1 ||
selected_path=$(
find $search_dirs -mindepth 1 -maxdepth 1 -type d |
(echo 'hub' && cat) |
fzf
)
[[ -z $selected_path ]] && exit 0
local target_name=''
local target_path=''
local selected_name=''
[[ "$selected_path" = "hub" ]] && selected_name="hub" && selected_path=$HOME ||
selected_name=$(basename "$selected_path" | tr . _)
[[ $# -eq 1 ]] && target_path=$1 ||
target_path=$(find $search_dirs -mindepth 1 -maxdepth 1 -type d | fzf)
! (tmux_session_exists $selected_name) &&
tmux new-session -d -s $selected_name -c $selected_path &&
hydrate $selected_name $selected_path
switch_to $selected_name
if [[ $target_path = "existing" ]]; then target_name=$(echo $existing_sessions | fzf);
elif [[ $target_path = "hub" ]]; then target_name="hub" && target_path="$HOME";
elif [[ -n $target_path ]]; then target_name=$(basename "$target_path" | tr . _);
fi
[[ -z $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

View File

@ -9,6 +9,7 @@ export DEVDIR=$HOME'/dev'
# path updates
export PATH=$HOME/.local/bin:$HOME/.local/scripts:$PATH
export PATH=$PATH:/opt/homebrew/opt/ccache/libexec
export PATH=$PATH:~/bin/android-sdk-darwin/platform-tools:/opt/homebrew/opt/ccache/libexec
# executable name overrides
alias ls='ls -F'
@ -45,3 +46,6 @@ alias shrug='echo "¯\\_(ツ)_/¯"'
alias lintjs='npx prettier --write'
export DEVKITARM=/opt/devkitpro/devkitARM
. /opt/homebrew/opt/asdf/libexec/asdf.sh # TODO: ensure not duplicated asdf logic