Fix tm script formatting

This commit is contained in:
Marty Oehme 2019-07-27 14:26:06 +02:00
parent 55c1e12e43
commit e1113a3f6c

View file

@ -3,7 +3,7 @@
# Attach to a tmux session, or create it if it doesnt exist # Attach to a tmux session, or create it if it doesnt exist
if [ "$1" = '-h' ] || [ "$1" = '--help' ]; then if [ "$1" = '-h' ] || [ "$1" = '--help' ]; then
cat <<-EOF cat <<-EOF
Usage: $0 [FILE] [NAME] Usage: $0 [FILE] [NAME]
Attach to an existing tmux session, or bootstrap a new session. Attach to an existing tmux session, or bootstrap a new session.
@ -54,7 +54,7 @@ _not_in_tmux() {
} }
_session_exists() { _session_exists() {
if tmux has-session -t "$session_name" > /dev/null 2>&1; then if tmux has-session -t "$session_name" >/dev/null 2>&1; then
true true
else else
false false
@ -67,13 +67,13 @@ _create_detached_session() {
_load_env_session_file() { _load_env_session_file() {
if [ -f ./.tmux.session ]; then if [ -f ./.tmux.session ]; then
xargs -L1 tmux < ./.tmux.session xargs -L1 tmux <./.tmux.session
fi fi
} }
_load_session_file() { _load_session_file() {
if [ -f "$session_file" ]; then if [ -f "$session_file" ]; then
xargs -L1 tmux < "$session_file" xargs -L1 tmux <"$session_file"
fi fi
} }
@ -92,7 +92,7 @@ _set_session_vars() {
# set up session name and config file - if passed in as arguments # set up session name and config file - if passed in as arguments
if [ "$#" -eq 2 ]; then if [ "$#" -eq 2 ]; then
if ! _file_exists "$1" && ! _file_exists "${session_dir}${1}"; then if ! _file_exists "$1" && ! _file_exists "${session_dir}${1}"; then
echo "$0: can not source configuration file: '${1}' does not exist." echo >&2 "can not source session file: '${1}' does not exist."
exit 1 exit 1
fi fi
_set_session_file_path "$1" _set_session_file_path "$1"
@ -106,12 +106,12 @@ _set_session_vars() {
# set default session name if none was passed # set default session name if none was passed
if [ -z "$session_name" ]; then if [ -z "$session_name" ]; then
# only if we have a filename should we append it to the session name # only if we have a filename should we append it to the session name
if [ -n "$session_file" ]; then if [ -n "$session_file" ]; then
fname=/$(basename "$session_file" .session) fname=/$(basename "$session_file" .session)
fi fi
# default to parent directory name / config file name for the session # default to parent directory name / config file name for the session
session_name=$(basename "$PWD" | sed 's/[^a-zA-Z0-9\-]//g' | tr . -)"$fname" session_name=$(basename "$PWD" | sed 's/[^a-zA-Z0-9\-]//g' | tr . -)"$fname"
fi fi
} }