Skip to content

Commit

Permalink
update: Update the tmux sessionizer.
Browse files Browse the repository at this point in the history
  • Loading branch information
SingularisArt committed Aug 27, 2023
1 parent bea5b7b commit 6897453
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 35 deletions.
14 changes: 1 addition & 13 deletions aspects/dotfiles/files/.config/tmux/tmux.conf
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ bind-key -r i run-shell 'tmux new-window -c "#{pane_current_path}" "tmux rename-

# Create commonly used tmux sessions.
bind-key -r C-t run-shell '~/.local/bin/tmux/tmux-sessionizer'
bind-key -r C-m run-shell '~/.local/bin/tmux/tmux-sessionizer ~/Documents/memory-trainer'
bind-key -r C-n run-shell '~/.local/bin/tmux/tmux-sessionizer ~/Documents/notes-manager'
bind-key -r C-s run-shell '~/.local/bin/tmux/tmux-sessionizer ~/Documents/school-notes'
bind-key -r C-e run-shell '~/.local/bin/tmux/tmux-sessionizer ~/Documents/school-setup'
bind-key -r C-c run-shell '~/.local/bin/tmux/tmux-sessionizer ~/Documents/encyclopedia'
bind-key -r C-y run-shell '~/.local/bin/tmux/tmux-sessionizer ~/.local/share/Singularis'

# Break current pane into its own window.
bind-key m break-pane -d
Expand Down Expand Up @@ -152,13 +146,7 @@ bind-key C-h display-menu -x C -y C \
"Break Pane to Session" M "break-pane -d" \
"Break Window to Session" W "break-pane -d" \
"" \
"Create Common Session" C-t "run-shell '~/.local/bin/tmux/tmux-sessionizer'" \
"Create Memory Trainer Session" C-\m "run-shell '~/.local/bin/tmux/tmux-sessionizer ~/Documents/memory-trainer'" \
"Create Notes Manager Session" C-n "run-shell '~/.local/bin/tmux/tmux-sessionizer ~/Documents/notes-manager'" \
"Create School Notes Session" C-s "run-shell '~/.local/bin/tmux/tmux-sessionizer ~/Documents/school-notes'" \
"Create School Setup Session" C-e "run-shell '~/.local/bin/tmux/tmux-sessionizer ~/Documents/school-setup'" \
"Create Encyclopedia Session" C-c "run-shell '~/.local/bin/tmux/tmux-sessionizer ~/Documents/encyclopedia'" \
"Create Singularis Session" C-y "run-shell '~/.local/bin/tmux/tmux-sessionizer ~/.local/share/Singularis'" \
"Create Commonly Used Session" C-t "run-shell '~/.local/bin/tmux/tmux-sessionizer'" \
"" \
"Join Panes Together" t "join-pane -s '#{pane_id}'" \
"Create New Session (Prompt)" B "new-session" \
Expand Down
33 changes: 11 additions & 22 deletions aspects/dotfiles/files/.local/bin/tmux/tmux-sessionizer
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
#!/usr/bin/env bash

# Check if the user passed a path by default
if [[ $# -eq 1 ]]; then
if [[ ! -d $1 ]]; then
echo "The path passed is not a directory"
exit 1
fi

cd "$1" || exit
source .tmux
exit
fi

declare -A sessions
while IFS= read -r line; do
formatted_session=$(basename "$line" | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) tolower(substr($i,2));}1')
sessions["$formatted_session"]=$line
done < <(find ~/Documents -maxdepth 2 -type f -name ".tmux" -exec dirname {} \;)
tmux_file="$line/.tmux"
session_name=$(grep -oP '(?<=SESSION_NAME=")[^"]*' "$tmux_file")
sessions["$session_name"]=$line
done < <(find ~/Documents ~/Desktop -maxdepth 2 -type f -name ".tmux" -exec dirname {} \;)

sessions["System Configuration"]="$HOME/.local/share/Singularis/"

if [[ $# -eq 1 ]]; then
selected=$1
else
selected=$(printf "%s\n" "${!sessions[@]}" | rofi -p "Select Session" -dmenu -no-fixed-num-lines)
rofi() {
/usr/bin/rofi -markup-rows -kb-row-down Down -kb-custom-1 Ctrl+n -no-fixed-num-lines "$@"
}

selected=$(printf "%s\n" "${!sessions[@]}" | rofi -i -dmenu -window-title "Select Session")

if [[ -z $selected ]]; then
exit 0
fi
if [[ -z $selected ]]; then
exit 0
fi

cd "${sessions[$selected]}" || exit
Expand Down
Binary file modified aspects/dotfiles/files/.local/share/autojump/autojump.txt
Binary file not shown.
Binary file modified aspects/dotfiles/files/.local/share/autojump/autojump.txt.bak
Binary file not shown.
Binary file modified aspects/dotfiles/files/.local/share/newsboat/cache.db
Binary file not shown.
Binary file modified aspects/dotfiles/files/.local/share/zathura/history
Binary file not shown.

0 comments on commit 6897453

Please sign in to comment.