Add [unix-]OS-agnostic bin/open + shell/tmux/bin/tmux-session-name
This commit is contained in:
parent
a98823e568
commit
b87063b27e
12
bin/open
Executable file
12
bin/open
Executable 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
|
|
@ -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'
|
||||||
|
|
||||||
|
|
7
shell/tmux/bin/tmux-session-name
Executable file
7
shell/tmux/bin/tmux-session-name
Executable 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:}"
|
Loading…
Reference in a new issue