Make copy_dotfiles POSIX, simplify zsh files, minor nvim changes
This commit is contained in:
@@ -1,36 +1,37 @@
|
|||||||
#!/bin/zsh
|
#!/bin/sh
|
||||||
|
|
||||||
echo_and_execute() { echo "executing: $@" && "$@" }
|
echo_and_execute() {
|
||||||
|
echo "executing: $@" && "$@"
|
||||||
|
}
|
||||||
|
|
||||||
copy_file() {
|
copy_file() {
|
||||||
local from=$1
|
from=$1
|
||||||
local to=$2
|
to=$2
|
||||||
local filename=$(basename $from)
|
filename=$(basename "$from")
|
||||||
[[ -e $to/$filename ]] && rm $to/$filename
|
[ -e "$to/$filename" ] && rm "$to/$filename"
|
||||||
echo_and_execute cp -RPp $from $to/$filename
|
echo_and_execute cp -RPp "$from" "$to/$filename"
|
||||||
}
|
}
|
||||||
|
|
||||||
copy_dir() {
|
copy_dir() {
|
||||||
local from=$1
|
from=$1
|
||||||
local to=$2
|
to=$2
|
||||||
pushd $from > /dev/null
|
prev_dir=$(pwd)
|
||||||
local directories=(`find . -mindepth 1 -maxdepth 1 -type d`)
|
cd "$from" || return 1
|
||||||
for dir in $directories; do
|
find . -mindepth 1 -maxdepth 1 -type d | while read -r dir; do
|
||||||
[[ -d $to/$dir ]] && rm -rf $to/$dir
|
[ -d "$to/$dir" ] && rm -rf "$to/$dir"
|
||||||
echo_and_execute cp -RPp $dir $to/$dir
|
echo_and_execute cp -RPp "$dir" "$to/$dir"
|
||||||
done
|
done
|
||||||
local files=(`find . -mindepth 1 -maxdepth 1 -type f`)
|
find . -mindepth 1 -maxdepth 1 -type f | while read -r file; do
|
||||||
for file in $files; do
|
copy_file "$file" "$to"
|
||||||
copy_file $file $to
|
|
||||||
done
|
done
|
||||||
popd > /dev/null
|
cd "$prev_dir" || return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
sym_link() {
|
sym_link() {
|
||||||
[[ ! -e "$1" ]] && echo "skipping link, target does not exist: $1" && return
|
! [ -e "$1" ] && echo "skipping link, target does not exist: $1" && return
|
||||||
[[ -h "$2" ]] && rm $2
|
[ -h "$2" ] && rm "$2"
|
||||||
[[ -f "$2" || -d "$2" ]] && rm -rf $2
|
test -f "$2" -o -d "$2" && rm -rf "$2"
|
||||||
echo_and_execute ln -s $1 $2
|
echo_and_execute ln -s "$1" "$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "---- copying dotfiles ------------------"
|
echo "---- copying dotfiles ------------------"
|
||||||
@@ -47,12 +48,12 @@ copy_dir src_files/.local/bin $DIR_BIN
|
|||||||
copy_dir src_files/.local/scripts $DIR_SCRIPTS
|
copy_dir src_files/.local/scripts $DIR_SCRIPTS
|
||||||
|
|
||||||
# macOS overrides as needed
|
# macOS overrides as needed
|
||||||
[[ "$OSTYPE" = *"darwin"* ]] && copy_dir src_files/bin_overrides_macos $DIR_BIN
|
case "$OSTYPE" in *darwin*) copy_dir src_files/bin_overrides_macos $DIR_BIN;; esac
|
||||||
|
|
||||||
# obsidian uses a per-vault config model, so copy to all target vaults/dirs
|
# obsidian uses a per-vault config model, so copy to all target vaults/dirs
|
||||||
for obs_dir in "${OBSIDIAN_WORKSPACES_TO_CONFIGURE[@]}"; do
|
IFS=","; for obs_dir in $OBSIDIAN_WORKSPACES_TO_CONFIGURE; do
|
||||||
[[ ! -d "$obs_dir/.obsidian" ]] && mkdir "$obs_dir/.obsidian"
|
! [ -d "$obs_dir/.obsidian" ] && mkdir "$obs_dir/.obsidian"
|
||||||
copy_dir $XDG_CONFIG_HOME/obsidian "$obs_dir/.obsidian"
|
copy_dir "$XDG_CONFIG_HOME/obsidian" "$obs_dir/.obsidian"
|
||||||
done
|
done
|
||||||
|
|
||||||
# TODO: get reaper config set up
|
# TODO: get reaper config set up
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
- shell
|
- shell
|
||||||
- check user's shell using `echo $SHELL` or otherwise
|
- check user's shell using `echo $SHELL` or otherwise
|
||||||
- if not the desired shell:
|
- if not the desired shell:
|
||||||
- `chsh -l` to see options; if target shell isn't listed, then add it
|
- `cat /etc/shells` (or `chsh -l` if supported) to see options
|
||||||
to `/etc/shells`
|
- if target shell isn't listed, add it to `/etc/shells`
|
||||||
- then change the shell with `chsh -s <path to target shell>`
|
- then change the shell with `chsh -s <path to target shell>`
|
||||||
|
|
||||||
## macOS
|
## macOS
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ vim.keymap.set("n", "N", "Nzv")
|
|||||||
-- maintain cursor position after paragraph formatting
|
-- maintain cursor position after paragraph formatting
|
||||||
vim.keymap.set("n", "=ap", "mF=ap'F")
|
vim.keymap.set("n", "=ap", "mF=ap'F")
|
||||||
|
|
||||||
-- shortcuts for deleting into the void register
|
-- replace selected text, keep main register
|
||||||
vim.keymap.set({ "n", "v" }, "<leader>d", [["_d]])
|
vim.keymap.set("x", "<leader>P", [["_dP]])
|
||||||
vim.keymap.set("x", "<leader>P", [["_dP]]) -- replace selected text, keep main register
|
|
||||||
|
|
||||||
-- shortcuts for using + register (system clipboard)
|
-- shortcuts for using + register (system clipboard)
|
||||||
vim.keymap.set({ "n", "v" }, "<leader>y", [["+y]])
|
vim.keymap.set({ "n", "v" }, "<leader>y", [["+y]])
|
||||||
vim.keymap.set("n", "<leader>Y", [["+Y]])
|
vim.keymap.set("n", "<leader>Y", [["+Y]])
|
||||||
|
vim.keymap.set({ "n", "v" }, "<leader>d", [["+d]])
|
||||||
vim.keymap.set("n", "<leader>D", [["+D]])
|
vim.keymap.set("n", "<leader>D", [["+D]])
|
||||||
vim.keymap.set("n", "<leader>p", [["+p]])
|
vim.keymap.set("n", "<leader>p", [["+p]])
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ function ToggleWritingMode()
|
|||||||
vim.opt_local.relativenumber = true
|
vim.opt_local.relativenumber = true
|
||||||
vim.opt_local.signcolumn = "yes"
|
vim.opt_local.signcolumn = "yes"
|
||||||
vim.opt_local.cursorline = true
|
vim.opt_local.cursorline = true
|
||||||
|
vim.api.nvim_set_hl(0, 'SpellCap', vim.g.wrmode_prev_hl_spellcap or {})
|
||||||
vim.opt_local.spell = false
|
vim.opt_local.spell = false
|
||||||
-- vim.opt_local.wrap = true -- TODO: needed?
|
-- vim.opt_local.wrap = true -- TODO: needed?
|
||||||
vim.opt_local.textwidth = 0
|
vim.opt_local.textwidth = 0
|
||||||
@@ -98,6 +99,8 @@ function ToggleWritingMode()
|
|||||||
local writing_pane = vim.api.nvim_get_current_win()
|
local writing_pane = vim.api.nvim_get_current_win()
|
||||||
EnableWritingModeUiForCurrentWindow()
|
EnableWritingModeUiForCurrentWindow()
|
||||||
vim.opt_local.spell = true
|
vim.opt_local.spell = true
|
||||||
|
vim.g.wrmode_prev_hl_spellcap = vim.api.nvim_get_hl(0, { name = 'SpellCap' })
|
||||||
|
vim.api.nvim_set_hl(0, 'SpellCap', {})
|
||||||
vim.opt_local.textwidth = window_width
|
vim.opt_local.textwidth = window_width
|
||||||
vim.opt_local.scrolloff = 14
|
vim.opt_local.scrolloff = 14
|
||||||
vim.opt_local.formatoptions:append('t')
|
vim.opt_local.formatoptions:append('t')
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ set -o vi
|
|||||||
export PATH=$DIR_BIN:$DIR_SCRIPTS:$PATH:$XDG_DATA_HOME
|
export PATH=$DIR_BIN:$DIR_SCRIPTS:$PATH:$XDG_DATA_HOME
|
||||||
export PATH=$PATH:/opt/homebrew/opt/ccache/libexec:/opt/homebrew/bin
|
export PATH=$PATH:/opt/homebrew/opt/ccache/libexec:/opt/homebrew/bin
|
||||||
|
|
||||||
|
# set env vars specific to this box, if any
|
||||||
|
[ -r "$HOME/.local-box-vars" ] && . $HOME/.local-box-vars
|
||||||
|
|
||||||
# shortcuts for common commands
|
# shortcuts for common commands
|
||||||
alias 3e='echo;echo;echo'
|
alias 3e='echo;echo;echo'
|
||||||
alias 12e='3e;3e;3e;3e'
|
alias 12e='3e;3e;3e;3e'
|
||||||
@@ -28,15 +31,36 @@ alias note="cd $DIR_NOTES/inbox; $EDITOR"
|
|||||||
alias todo="cd $DIR_NOTES/rhythm; $EDITOR todo.md"
|
alias todo="cd $DIR_NOTES/rhythm; $EDITOR todo.md"
|
||||||
alias budget="open $DIR_HOME_BOX/finance/budget/.current"
|
alias budget="open $DIR_HOME_BOX/finance/budget/.current"
|
||||||
|
|
||||||
|
# login shortcuts
|
||||||
|
alias assume="source assume"
|
||||||
|
alias login-aws='aws sso login --profile'
|
||||||
|
alias login-aws-id-list="grep sso_account_id $HOME/.aws/config"
|
||||||
|
|
||||||
|
# git stuff
|
||||||
|
alias gfo='git fetch origin'
|
||||||
|
alias gfl='git fetch origin; git log'
|
||||||
|
alias gpo='git pull origin'
|
||||||
|
alias gppo='git push origin'
|
||||||
|
alias gst='git status'
|
||||||
|
alias git-push-to-temp='git branch -D temp; git checkout -b temp; git push origin temp -uf; git checkout -'
|
||||||
|
alias gptemp='git-push-to-temp'
|
||||||
|
|
||||||
|
# code/test/linter run and build commands
|
||||||
|
alias bel='bundle exec standardrb'
|
||||||
|
alias bet='bundle exec rspec'
|
||||||
|
alias lintjs='npx prettier --write'
|
||||||
|
alias prl='poetry run black'
|
||||||
|
alias prt='poetry run pytest'
|
||||||
|
|
||||||
|
# containerization
|
||||||
|
alias docker=podman
|
||||||
|
|
||||||
# misc commands
|
# misc commands
|
||||||
alias pdt='ping -c 2 drinkingtea.net'
|
alias pdt='ping -c 2 drinkingtea.net'
|
||||||
alias ppw='ping -c 2 pinewoods.xyz'
|
alias ppw='ping -c 2 pinewoods.xyz'
|
||||||
alias weather='curl "wttr.in/dfw?2&F"'
|
alias weather='curl "wttr.in/dfw?2&F"'
|
||||||
alias shrug='echo "¯\\_(ツ)_/¯"'
|
alias shrug='echo "¯\\_(ツ)_/¯"'
|
||||||
|
|
||||||
# source extensions and system-specific files
|
|
||||||
[[ -a "$ZDOTDIR/zsh-general-dev" ]] && . "$ZDOTDIR/zsh-general-dev"
|
|
||||||
|
|
||||||
# programming and language setup
|
# programming and language setup
|
||||||
[[ -n $(command -v mise) ]] && eval "$(mise activate zsh)"
|
[[ -n $(command -v mise) ]] && eval "$(mise activate zsh)"
|
||||||
export DEVKITARM=/opt/devkitpro/devkitARM
|
export DEVKITARM=/opt/devkitpro/devkitARM
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
# set env vars, path updates, etc
|
|
||||||
[[ -a $HOME/.local-box-vars ]] && . $HOME/.local-box-vars
|
|
||||||
|
|
||||||
# login shortcuts
|
|
||||||
alias assume="source assume"
|
|
||||||
alias login-aws='aws sso login --profile'
|
|
||||||
alias login-aws-id-list="grep sso_account_id $HOME/.aws/config"
|
|
||||||
|
|
||||||
# git stuff
|
|
||||||
alias gfo='git fetch origin'
|
|
||||||
alias gfl='git fetch origin; git log'
|
|
||||||
alias gpo='git pull origin'
|
|
||||||
alias gppo='git push origin'
|
|
||||||
alias gst='git status'
|
|
||||||
alias git-push-to-temp='git branch -D temp; git checkout -b temp; git push origin temp -uf; git checkout -'
|
|
||||||
alias gptemp='git-push-to-temp'
|
|
||||||
|
|
||||||
# code/test/linter run and build commands
|
|
||||||
alias bel='bundle exec standardrb'
|
|
||||||
alias bet='bundle exec rspec'
|
|
||||||
alias lintjs='npx prettier --write'
|
|
||||||
alias prl='poetry run black'
|
|
||||||
alias prt='poetry run pytest'
|
|
||||||
|
|
||||||
# containerization
|
|
||||||
alias docker=podman
|
|
||||||
@@ -39,7 +39,7 @@ export ZDOTDIR="$XDG_CONFIG_HOME/zsh" # may already be set, set anyway
|
|||||||
export GIT_EDITOR="$EDITOR"
|
export GIT_EDITOR="$EDITOR"
|
||||||
|
|
||||||
# obsidian
|
# obsidian
|
||||||
export OBSIDIAN_WORKSPACES_TO_CONFIGURE=("$DIR_NOTES")
|
export OBSIDIAN_WORKSPACES_TO_CONFIGURE="$DIR_NOTES," # ,-delimitted list of dirs
|
||||||
|
|
||||||
# reaper
|
# reaper
|
||||||
export DIR_REAPER_PORTABLE_SHARED="$DIR_USER_OPT/reaper-portable/shared"
|
export DIR_REAPER_PORTABLE_SHARED="$DIR_USER_OPT/reaper-portable/shared"
|
||||||
|
|||||||
Reference in New Issue
Block a user