finished startup script for tmux
parent
4d8504a05a
commit
dc6269803c
@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
get_qotd() {
|
||||
# needs $quotes_json to be set
|
||||
len=$(echo "$quotes_json" | jq '. | length ')
|
||||
qotd=$(( $RANDOM % $len ))
|
||||
quote=$(echo "$quotes_json" | jq -r ".[$qotd].q")
|
||||
author=$(echo "$quotes_json" | jq -r ".[$qotd].a")
|
||||
}
|
||||
|
||||
cur_date=$(date +%m-%d)
|
||||
quotes_file="$HOME/.dotfiles/bin/startup/$cur_date.json"
|
||||
if [[ ! -f $quotes_file ]] ; then
|
||||
# quotes file doesn't exist
|
||||
# remove old files and create new one
|
||||
quotes_json=$(curl --silent -fL "https://zenquotes.io/api/quotes/")
|
||||
old_files="$HOME"/.dotfiles/bin/startup/*.json
|
||||
if [[ ! -z $old_files ]] ; then
|
||||
rm "$HOME"/.dotfiles/bin/startup/*.json
|
||||
fi
|
||||
echo "$quotes_json" > "$HOME/.dotfiles/bin/startup/$cur_date.json"
|
||||
else
|
||||
# quotes file doesn't exist
|
||||
quotes_json=$(cat "$quotes_file")
|
||||
fi
|
||||
|
||||
get_qotd # sets quote and author
|
||||
printf '"%s" - %s\n' "$quote" "$author"
|
||||
|
@ -0,0 +1,47 @@
|
||||
#!/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
|
||||
}
|
||||
|
||||
session="doormat"
|
||||
|
||||
session_exists=$(tmux list-sessions 2>/dev/null | grep $session) # get rid of "no server" error
|
||||
|
||||
if [[ -z $session_exists ]] ; then
|
||||
|
||||
|
||||
tmux new-session -d -s $session
|
||||
set_greeting
|
||||
window="Good $Greeting"
|
||||
|
||||
tmux select-window -t $session:0
|
||||
tmux split-window -h -p 25
|
||||
tmux send-keys "cd && clear && printf '\n\n\n' && curl --silent -fL "https://wttr.in?Fn"" C-m
|
||||
tmux select-pane -t 0
|
||||
tmux split-window -h -p 66
|
||||
tmux select-pane -t 0
|
||||
tmux split-window -v -p 90
|
||||
tmux select-pane -t 0
|
||||
|
||||
tmux send-keys "cd && clear && printf '\n\n' && $HOME/.dotfiles/bin/startup/quote.sh && printf '\n'" C-m
|
||||
tmux select-pane -t 1
|
||||
tmux send-keys 'cd && clear' C-m
|
||||
tmux select-pane -t 2
|
||||
tmux send-keys 'cd && clear && vim' C-m
|
||||
tmux rename-window -t $session:0 "$window"
|
||||
fi
|
||||
|
||||
#tmux -2 attach-session -t "$session"
|
||||
|
Loading…
Reference in New Issue