dotfiles

My personal dotfiles
git clone git://pcardensab.com/dotfiles
Log | Files | Refs | Submodules | README

sessions.sh (1226B)


      1 #!/bin/sh
      2 
      3 create_session() {
      4 	group=$1
      5 	session=$2
      6 	path=$3
      7 	mkdir -p "${path}"
      8 
      9 	if ! tmux list-sessions -F '#{session_group}' | grep -q impa; then
     10 		tmux new-session -s "${session}" -t "${group}" -d -c "${path}"
     11 		tmux new-window -t "${session}": -n "${session}" -c "${path}"
     12 		tmux kill-window -t "${session}":0
     13 	fi
     14 
     15 	if ! tmux has-session -t "${session}" 2>/dev/null; then
     16 		tmux new-session -s "${session}" -t "${group}" -d -c "${path}"
     17 	fi
     18 
     19 	if ! tmux list-windows -t "${session}" -F '#{window_name}' | grep -q "${session}"; then
     20 		tmux new-window -t "${session}": -n "${session}" -c "${path}"
     21 	elif { tmux display-message -p '#{window_name}' | grep -q "${session}"; } && ! [ "$PWD" -ef "${path}" ]; then
     22 		pushd "${path}" >/dev/null || return
     23 		dirs -v
     24 	fi
     25 
     26 	if [ -z "${TMUX}" ]; then
     27 		tmux attach -t "${session}"
     28 	fi
     29 
     30 	tmux switch-client -t "${session}"
     31 	tmux select-window -t "${session}:${session}"
     32 	unset group session path
     33 }
     34 
     35 fa() {
     36 	create_session impa fa ~/dox/dev/notes-functional-analysis
     37 }
     38 
     39 hdp() {
     40 	create_session impa hdp ~/dox/dev/notes-high-dimension-probability
     41 }
     42 
     43 mt() {
     44 	create_session impa mt ~/dox/dev/notes-measure-theory
     45 }
     46 
     47 ts() {
     48 	create_session impa ts ~/dox/dev/notes-theoretical-statistics
     49 }