Add [unix-]OS-agnostic bin/open + shell/tmux/bin/tmux-session-name

This commit is contained in:
Henrik Lissner 2017-04-25 02:40:45 -04:00
parent a98823e568
commit b87063b27e
3 changed files with 19 additions and 2 deletions

12
bin/open Executable file
View file

@ -0,0 +1,12 @@
#!/usr/bin/env bash
case $OSTYPE in
darwin*) open $@ ;;
linux*) xdg-open $@ ;;
esac
# OPTIONAL: requires bin/tmux
if command -v 'tmux-session-name' >/dev/null; then
# If this was used from a scratch tmux terminal, close it
[[ "$(tmux-session-name)" == scratch ]] && tmux kill-session -t scratch
fi

View file

@ -1,7 +1,5 @@
alias ls="${aliases[ls]:-ls} --color=auto --group-directories-first" alias ls="${aliases[ls]:-ls} --color=auto --group-directories-first"
alias open='xdg-open'
alias sys='systemctl' alias sys='systemctl'
alias sys!='sudo systemctl' alias sys!='sudo systemctl'

View file

@ -0,0 +1,7 @@
#!/usr/bin/env bash
id=$(echo $TMUX | sed 's/.*,//g')
res=$(tmux ls -F '#{session_id}:#{session_name}' | grep -e "^\$$id:")
[[ $res ]] || exit 1
echo "${res#\$$id:}"