finally made it so tmux auto starts and formats on a hook
This commit is contained in:
parent
5062ae7d36
commit
2d3132e870
55
bin/startup/lay_doormat.sh
Executable file
55
bin/startup/lay_doormat.sh
Executable file
@ -0,0 +1,55 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set_greeting() {
|
||||||
|
# sets the TOD variable based on time of calling
|
||||||
|
cur_time=$(date +%H) # hour
|
||||||
|
# this control flow will be scuffed because I need to deal with early AM = evening
|
||||||
|
if [[ $cur_time -lt 4 || $cur_time -gt 17 ]] ; then
|
||||||
|
# between 5:00 pm and 4:00 am
|
||||||
|
Greeting="Evening"
|
||||||
|
elif [[ $cur_time -lt 12 ]] ; then
|
||||||
|
# between 4:00 am and 12:00 pm
|
||||||
|
Greeting="Morning"
|
||||||
|
else
|
||||||
|
Greeting="Afternoon"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
format_doormat() {
|
||||||
|
# formats doormat on entry
|
||||||
|
|
||||||
|
set_greeting # set $Greeting based on TOD
|
||||||
|
window="Good $Greeting"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
tmux select-window -t "$SESSION:0"
|
||||||
|
# creating a weather view on right quater
|
||||||
|
tmux split-window -h -p 25
|
||||||
|
# creating quote area
|
||||||
|
tmux split-window -v -p 20
|
||||||
|
# weather
|
||||||
|
tmux select-pane -t 1
|
||||||
|
tmux send-keys 'c && curl --silent -fL https://wttr.in?Fn' C-m
|
||||||
|
# quote
|
||||||
|
tmux select-pane -t 2
|
||||||
|
tmux send-keys 'c && quote.sh' C-m
|
||||||
|
|
||||||
|
# creating a central vim pane taking up half the screen and a little box on the top left
|
||||||
|
tmux select-pane -t 0
|
||||||
|
tmux split-window -h -p 66
|
||||||
|
# opening vim
|
||||||
|
tmux select-pane -t 1
|
||||||
|
tmux send-keys 'c && vim' C-m
|
||||||
|
# renaming based on TOD
|
||||||
|
tmux rename-window -t "$SESSION:0" "$window"
|
||||||
|
tmux set-hook -u -t $SESSION client-attached
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
eval "$(tmux_start.sh -s)"
|
||||||
|
|
||||||
|
if [[ ! -z $SESSION ]] ; then
|
||||||
|
# session is set
|
||||||
|
format_doormat
|
||||||
|
fi
|
@ -24,5 +24,4 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
get_qotd # sets quote and author
|
get_qotd # sets quote and author
|
||||||
printf '\n"%s"\n - %s\n' "$quote" "$author" | fold -s
|
printf '"%s"\n - %s\n' "$quote" "$author" | fold -s
|
||||||
|
|
||||||
|
42
bin/startup/tmux_start.sh
Executable file
42
bin/startup/tmux_start.sh
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
print_output=false
|
||||||
|
|
||||||
|
while getopts "s" arg; do
|
||||||
|
case $arg in
|
||||||
|
s)
|
||||||
|
print_output=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
SESSION="doormat" # welcom session name
|
||||||
|
START_SERVER=false
|
||||||
|
|
||||||
|
set_session() {
|
||||||
|
# sets $SESSION variable to doormat
|
||||||
|
active_sessions=$(tmux list-sessions 2>/dev/null)
|
||||||
|
if [[ ! -z "$active_sessions" ]] ; then
|
||||||
|
# active sessions
|
||||||
|
session=$(echo "$active_sessions" | grep "$SESSION" | cut -d ':' -f 1 2>/dev/null)
|
||||||
|
# tmux doormat script
|
||||||
|
if [[ "$session" != "$SESSION" ]] ; then
|
||||||
|
# door mat doesn't exist
|
||||||
|
START_SERVER=true
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
START_SERVER=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $START_SERVER ; then
|
||||||
|
# need to start server
|
||||||
|
tmux new-session -d -s "$SESSION"
|
||||||
|
tmux set-hook -t "$SESSION" client-attached 'run-shell ~/.dotfiles/bin/startup/lay_doormat.sh'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
set_session
|
||||||
|
|
||||||
|
if $print_output ; then
|
||||||
|
echo "SESSION=$SESSION"
|
||||||
|
fi
|
@ -1,71 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set_greeting() {
|
|
||||||
# sets the TOD variable based on time of calling
|
|
||||||
cur_time=$(date +%H) # hour
|
|
||||||
# this control flow will be scuffed because I need to deal with early AM = evening
|
|
||||||
if [[ $cur_time -lt 4 || $cur_time -gt 17 ]] ; then
|
|
||||||
# between 5:00 pm and 4:00 am
|
|
||||||
Greeting="Evening"
|
|
||||||
elif [[ $cur_time -lt 12 ]] ; then
|
|
||||||
# between 4:00 am and 12:00 pm
|
|
||||||
Greeting="Morning"
|
|
||||||
else
|
|
||||||
Greeting="Afternoon"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
lay_doormat(){
|
|
||||||
# formats a tmux session stored under $session
|
|
||||||
set_greeting # set $Greeting based on TOD
|
|
||||||
window="Good $Greeting"
|
|
||||||
|
|
||||||
tmux select-window -t $session:0
|
|
||||||
# creating a weather view on right quater
|
|
||||||
tmux split-window -h -p 25
|
|
||||||
tmux send-keys 'cd && clear && curl --silent -fL https://wttr.in?Fn' Enter
|
|
||||||
|
|
||||||
# creating a central vim pane taking up half the screen and a little box on the top left
|
|
||||||
tmux select-pane -t 0
|
|
||||||
tmux split-window -h -p 66
|
|
||||||
tmux select-pane -t 0
|
|
||||||
tmux split-window -v -p 90
|
|
||||||
|
|
||||||
# clearing bottom left
|
|
||||||
tmux select-pane -t 1
|
|
||||||
tmux send-keys 'cd && clear' C-m
|
|
||||||
# writing quote to top left
|
|
||||||
tmux select-pane -t 0
|
|
||||||
tmux send-keys 'cd && clear && ~/.dotfiles/bin/startup/quote.sh' Enter
|
|
||||||
# opening vim
|
|
||||||
tmux select-pane -t 2
|
|
||||||
tmux send-keys 'cd && clear && vim' C-m
|
|
||||||
# renaming based on TOD
|
|
||||||
tmux rename-window -t $session:0 "$window"
|
|
||||||
}
|
|
||||||
|
|
||||||
session="doormat"
|
|
||||||
|
|
||||||
|
|
||||||
if [[ ! tmuxhas-session -t $session 2>/d ]] ; then
|
|
||||||
# no server
|
|
||||||
tmux new-session -d -t "$session"
|
|
||||||
lay_doormat
|
|
||||||
else
|
|
||||||
# existing server
|
|
||||||
cur_session=$(tmux list-sessions 2>/dev/null | awk '{print $1}' | cut -d ":" -f 1)
|
|
||||||
if [[ "$cur_session" == "$session" ]] ; then
|
|
||||||
# check to see if window is set up
|
|
||||||
cur_window=$(tmux list-windows -t "$session" 2>/dev/null | grep Good)
|
|
||||||
if [[ -z $cur_window ]] ; then
|
|
||||||
# no window active
|
|
||||||
lay_doormat
|
|
||||||
#tmux -2 attach-session -t "$session"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# doormat exists get window
|
|
||||||
tmux new-session -d -t "$session"
|
|
||||||
lay_doormat
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
@ -36,6 +36,9 @@ set -g @plugin 'tmux-plugins/tmux-continuum'
|
|||||||
set -g @continuum-save-interval 10
|
set -g @continuum-save-interval 10
|
||||||
set -g @resurrect-capture-pane-contents 'on'
|
set -g @resurrect-capture-pane-contents 'on'
|
||||||
set -g @resurrect-strategy-vim 'session'
|
set -g @resurrect-strategy-vim 'session'
|
||||||
|
set -g @continuum-boot 'on'
|
||||||
|
set -g @continuum-systemd-start-cmd 'new-session -d -s doormat'
|
||||||
|
|
||||||
|
|
||||||
# run tpm
|
# run tpm
|
||||||
run '~/.tmux/plugins/tpm/tpm'
|
run '~/.tmux/plugins/tpm/tpm'
|
||||||
|
4
zshrc
4
zshrc
@ -150,6 +150,4 @@ alias water="$HOME/.dotfiles/bin/water/water.sh"
|
|||||||
|
|
||||||
# setting up location variables
|
# setting up location variables
|
||||||
# source "$HOME/.dotfiles/bin/weather/location.sh"
|
# source "$HOME/.dotfiles/bin/weather/location.sh"
|
||||||
#
|
source "$HOME/.dotfiles/bin/startup/tmux_start.sh"
|
||||||
# tmux doormat script
|
|
||||||
# source "$HOME/.dotfiles/bin/startup/tmux_startup.sh"
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user