Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tmux update #10

Merged
merged 2 commits into from
Dec 30, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 43 additions & 8 deletions aliases_shared
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,56 @@ alias ll='ls -halF'
alias la='ls -A'
alias l='ls -CF'

bmux_start () {
if [ -n $1 ]; then
tmux_public() {
if [ -n "$TMUX" ]; then
tmux_filepath=${TMUX%%,*}
chmod 777 $tmux_filepath
else
echo "You must run this command from within a tmux session"
fi
}

tmux_secure() {
if [ -n "$1" ]; then
chmod 700 /tmp/$1
echo "Set session to be private ($1)"
else
echo "Please specify the name of a tmux to secure"
fi
}

tmux_start () {
if [ -n "$1" ]; then
tmux -S /tmp/$1 new-session -s $1 -d
chmod 777 /tmp/$1
tmux_secure $1

tmux -S /tmp/$1 attach -t $1

# After detaching/exiting from the tmux
# Check if the session is still active to decide whether to clean or secure
if ps -o ruser,command -ax | grep -q "[n]ew-session -s $1" ; then
tmux_secure $1
else
rm /tmp/$1
echo "Deleted unused session ($1)"
fi
else
echo "Please specify the name of a tmux to start"
fi
}

bmux_list () {
tmux_list () {
ps -o ruser,command -ax | grep '[n]ew-session -s' | ruby -ne '$_ =~ /^(\w+).*-s (\w+)/; puts "#{$1} started #{$2}"'
}

alias bmux-start="bmux_start"
alias bmuxs="bmux_start"
alias bmux-list="bmux_list"
alias bmuxl="bmux_list"
alias tmux-start='tmux_start'
alias tmuxs='tmux_start'
alias tmux-list='tmux_list'
alias tmuxl='tmux_list'
alias tmux-public='tmux_public'
alias tmuxpub='tmux_public'

alias bmux-start="echo 'DEPRECATED: SWITCH TO tmux-start' && tmux_start"
alias bmuxs="echo 'DEPRECATED: SWITCH TO tmuxs' && tmux_start"
alias bmux-list="echo 'DEPRECATED: SWITCH TO tmux-list' && tmux_list"
alias bmuxl="echo 'DEPRECATED:SWTICH TO tmuxl' && tmux_list"