Move copy targets into directory; add tmux sessionizer

This commit is contained in:
david pickle 2025-01-15 00:44:24 -06:00
parent 04048d4fe4
commit cb8f07a711
10 changed files with 81 additions and 13 deletions

View File

@ -38,6 +38,6 @@ copy_file() {
execute cp -p $from $to/$filename execute cp -p $from $to/$filename
} }
copy_dir .config $HOME/.config copy_dir src_files/.config $HOME/.config
copy_dir .local $HOME/.local copy_dir src_files/.local $HOME/.local
copy_file .zshrc $HOME copy_file src_files/.zshrc $HOME

View File

@ -1,10 +1,17 @@
#!/bin/zsh #!/bin/zsh
[[ ! -d $HOME/.config ]] && mkdir $HOME/.config mkdirs_before_copying_config_files() {
[[ ! -d $HOME/.local ]] && mkdir $HOME/.local [[ ! -d $HOME/.config ]] && mkdir $HOME/.config
[[ ! -d $HOME/.local/bin ]] && mkdir $HOME/.local/bin [[ ! -d $HOME/.local ]] && mkdir $HOME/.local
[[ ! -d $HOME/.local/build ]] && mkdir $HOME/.local/build [[ ! -d $HOME/.local/bin ]] && mkdir $HOME/.local/bin
[[ ! -d $HOME/.local/tmp ]] && mkdir $HOME/.local/tmp [[ ! -d $HOME/.local/build ]] && mkdir $HOME/.local/build
[[ ! -d $HOME/.local/tmp ]] && mkdir $HOME/.local/tmp
}
# [[ ! -d $HOME/dbox ]] && mkdir $HOME/dbox mkdirs_after_setting_shell_env_vars() {
[[ ! -d $HOME/dev ]] && mkdir $HOME/dev [[ ! -d $HOMEBOX ]] && mkdir $HOMEBOX
[[ ! -d $DEVDIR ]] && mkdir $DEVDIR
}
mkdirs_before_copying_config_files
mkdirs_after_setting_shell_env_vars

View File

@ -17,9 +17,11 @@ bind -r j select-pane -D
bind -r h select-pane -L bind -r h select-pane -L
bind -r l select-pane -R bind -r l select-pane -R
# reload tmux.conf
bind r source-file "~/.config/tmux/tmux.conf" \; display-message "tmux.conf reloaded" bind r source-file "~/.config/tmux/tmux.conf" \; display-message "tmux.conf reloaded"
# use tmux-sessionizer in place of f find
bind-key -r f run-shell "tmux neww ~/.local/bin/tmux-sessionizer"
# bind -r D neww -c "#{pane_current_path}" "[[ -e TODO.md ]] && nvim TODO.md || nvim ~/personal/dev/todo.md" # bind -r D neww -c "#{pane_current_path}" "[[ -e TODO.md ]] && nvim TODO.md || nvim ~/personal/dev/todo.md"
# bind-key -r f run-shell "tmux neww ~/.local/bin/tmux-sessionizer"

View File

@ -0,0 +1,10 @@
#!/bin/zsh
if [[ "$(pwd)" == $HOME || "$(pwd)" == $HOMEBOX ]]; then
clear
return
fi
tmux new-window -dn scratch
vim .
clear

View File

@ -0,0 +1,49 @@
#!/bin/zsh
switch_to() {
if [[ -z $TMUX ]]; then
tmux attach-session -t $1
else
tmux switch-client -t $1
fi
}
has_session() {
tmux list-sessions | grep -q "^$1:"
}
hydrate() {
if [ -f $2/.tmux-sessionizer ]; then
tmux send-keys -t $1 "source $2/.tmux-session-setup" c-M
elif [ -f $HOME/.tmux-sessionizer ]; then
tmux send-keys -t $1 "source $HOME/.tmux-session-setup" c-M
fi
}
if [[ $# -eq 1 ]]; then
selected=$1
else
# If someone wants to make this extensible, i'll accept
# PR
selected=$(find ~/ ~/personal ~/personal/dev/env/.config -mindepth 1 -maxdepth 1 -type d | fzf)
fi
if [[ -z $selected ]]; then
exit 0
fi
selected_name=$(basename "$selected" | tr . _)
tmux_running=$(pgrep tmux)
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
tmux new-session -s $selected_name -c $selected
hydrate $selected_name $selected
exit 0
fi
if ! has_session $selected_name; then
tmux new-session -ds $selected_name -c $selected
hydrate $selected_name $selected
fi
switch_to $selected_name

View File

@ -11,12 +11,12 @@ export PATH=$HOME/.local/bin:$HOME/.local/scripts:$PATH
export PATH=$PATH:/opt/homebrew/opt/ccache/libexec export PATH=$PATH:/opt/homebrew/opt/ccache/libexec
# executable name overrides # executable name overrides
alias ls='ls -F'
alias vim='nvim' alias vim='nvim'
# 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'
alias ls='ls -F'
alias cl='clear; ' alias cl='clear; '
alias cls='clear;ls' alias cls='clear;ls'