3 Commits

4 changed files with 27 additions and 23 deletions

View File

@@ -169,6 +169,7 @@ alias d='docker' # run docker commands quickly
alias dc='docker compose' # run docker-compose commands quickly alias dc='docker compose' # run docker-compose commands quickly
alias dv='dirs -v' # list directory info alias dv='dirs -v' # list directory info
alias essh='edit-ssh-config' # edit ssh config quickly alias essh='edit-ssh-config' # edit ssh config quickly
alias email='tmux-sessionator --email' # Open email tmux session.
alias fl='find-latest' # Find the last modified file in a directory. alias fl='find-latest' # Find the last modified file in a directory.
alias g='git' # access git commands quickly alias g='git' # access git commands quickly
alias ga='git add' # add files to git quickly alias ga='git add' # add files to git quickly

View File

@@ -8,11 +8,13 @@ debug="${DEBUG}"
declare -a paths=() declare -a paths=()
declare chooseOpt= declare chooseOpt=
declare emailOpt=
declare -a directory=() declare -a directory=()
zparseopts -D -- \ zparseopts -D -- \
{c,-choose}=chooseOpt \ {c,-choose}=chooseOpt \
{d,-directory}:=directory {d,-directory}:=directory \
{e,-email}=emailOpt
#################### Helpers #################### #################### Helpers ####################
@@ -46,23 +48,30 @@ function create_session() {
local selected=$2 local selected=$2
tmux new-session -ds "$selected_name" -c "$selected" -n "editor" tmux new-session -ds "$selected_name" -c "$selected" -n "editor"
tmux send-keys -t editor 'n' Enter tmux send-keys -t "$selected_name.1" 'n' Enter
tmux new-window -d -n "terminal" -c "$selected" tmux new-window -t "$selected_name" -d -n "terminal" -c "$selected"
tmux new-window -d -n 'files' -c "$selected"
tmux send-keys -t files 'yazi' Enter
} }
#################### MAIN #################### function create_email_session() {
tmux new-session -ds email -n work neomutt
tmux new-window -t email -d -n personal neomutt
tmux send-keys -t email.1 'i2'
}
############################## MAIN ##############################
declare choose="${chooseOpt[-1]}" declare choose="${chooseOpt[-1]}"
declare selected= declare selected=
if [[ -n $choose ]]; then if [[ -n $choose ]] && [[ $# -eq 0 ]]; then
debug_print "Choose from existing." debug_print "Choose from existing."
selected=$( selected=$(
tmux list-sessions -F \#S | gum filter \ tmux list-sessions -F \#S | gum filter \
--placeholder "Pick a session..." --placeholder "Pick a session..."
) )
elif [[ -n $emailOpt ]]; then
debug_print "Email option."
selected="email"
elif [ ${#directory} -gt 0 ]; then elif [ ${#directory} -gt 0 ]; then
debug_print "Using directory option." debug_print "Using directory option."
selected=${directory[-1]} selected=${directory[-1]}
@@ -70,7 +79,6 @@ elif [ ${#directory} -gt 0 ]; then
selected="${PWD}" selected="${PWD}"
fi fi
debug_print "Directory: $selected" debug_print "Directory: $selected"
elif [[ "$#" -eq 1 ]]; then elif [[ "$#" -eq 1 ]]; then
debug_print "Using existing session: $1" debug_print "Using existing session: $1"
selected=$1 selected=$1
@@ -93,20 +101,13 @@ fi
selected_name=$(basename "$selected" | tr . _) selected_name=$(basename "$selected" | tr . _)
tmux_running=$(pgrep tmux) tmux_running=$(pgrep tmux)
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then if [[ -z $TMUX ]] && [[ -z $tmux_running ]] || ! tmux has-session -t "$selected_name" &>/dev/null; then
create_session "$selected_name" "$selected" if [[ -n $emailOpt ]]; then
# tmux new-session -s "$selected_name" -c "$selected" create_email_session
# exit 0 else
elif ! tmux has-session -t "$selected_name" 2> /dev/null; then
create_session "$selected_name" "$selected" create_session "$selected_name" "$selected"
fi
fi fi
# Create a session if it doesn't exist.
# if ! tmux has-session -t "$selected_name" 2> /dev/null; then
# tmux new-session -ds "$selected_name" -c "$selected" -n "editor"
# tmux send-keys -t editor 'n' Enter
# tmux new-window -d -n "terminal" -c "$selected"
# fi
[ -z $TMUX ] && tmux attach -t "$selected_name" \ [ -z $TMUX ] && tmux attach -t "$selected_name" \
|| tmux switch-client -t "$selected_name" || tmux switch-client -t "$selected_name"

3
env/.tmux.conf vendored
View File

@@ -74,8 +74,9 @@ bind l next-window
bind -n C-M-h previous-window bind -n C-M-h previous-window
bind -n C-M-l next-window bind -n C-M-l next-window
bind e run-shell "tmux-sessionator --email"
bind f run-shell "tmux display-popup -E -w 80% -h 80% $SCRIPTS/tmux-sessionator" bind f run-shell "tmux display-popup -E -w 80% -h 80% $SCRIPTS/tmux-sessionator"
bind-key -r C run-shell -b "~/.local/share/scripts/tmux-sessionator ~/.dotfiles" bind-key -r C run-shell -b "$SCRIPTS/tmux-sessionator $DOTFILES"
unbind s unbind s
bind s run-shell -b "~/.tmux/plugins/tmux-fzf/scripts/session.sh switch" bind s run-shell -b "~/.tmux/plugins/tmux-fzf/scripts/session.sh switch"

View File

@@ -13,4 +13,5 @@ yay ${1:-"-S --noconfirm"} neomutt \
msmtp \ msmtp \
pass \ pass \
ca-certificates \ ca-certificates \
gettext gettext \
cyrus-sasl-xoauth2-git