Skip to content

Commit

Permalink
Initial screen wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
gbraad committed Jan 1, 2025
1 parent 201532b commit 2ce3de6
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions zsh/.screenrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[screen]
override=true

40 changes: 40 additions & 0 deletions zsh/.zshrc.d/screen.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/zsh

CONFIG="${HOME}/.screenrc"
alias screenini="git config -f ${CONFIG}"
shift

screen () {
local OVERRIDE=$(screenini --bool "screen.override")
if [[ ${OVERRIDE} == true ]]; then
local screenname="screen"

if [[ -n "${TMUX}" ]]; then
echo "send $@"
tmux split-window -h "$@"

else

tmux has-session -t ${screenname} 2>/dev/null
if [[ $? != 0 ]]; then
tmux new-session -d -s ${screenname}
tmux send-keys -t ${screenname} $@ C-m
tmux attach-session -t ${screenname}
else
tmux attach-session -t ${screenname}
fi
fi

else
local distscreen="/usr/bin/screen"
local brewscreen="/var/home/linuxbrew/.linuxbrew/bin/screen"

if [[ -e "${distscreen}" ]]; then
${distscreen} $@
elif [[ -e "${brewscreen}" ]]; then
${brewscreen} $@
else
echo "screen not found: please use override or tmux"
fi
fi
}

0 comments on commit 2ce3de6

Please sign in to comment.