<commit_before># ref: http://qiita.com/b4b4r07/items/01359e8a3066d1c37edc
function is_tmux_running() { [ ! -z "$TMUX" ]; }
function shell_has_started_interactively() { [ ! -z "$PS1" ]; }
function is_ssh_running() { [ ! -z "$SSH_CONNECTION" ]; }

function tmux_attach_session() {
  if ! is_tmux_running; then
    if shell_has_started_interactively && ! is_ssh_running; then
      if (( $+commands[tmux] )); then
        if tmux has-session >/dev/null 2>&1; then
          tmux list-sessions
          echo -n "Tmux: attach? (y/N/num) "
          read
          if [[ "$REPLY" =~ ^[Yy]$ ]] || [[ "$REPLY" == '' ]]; then
            tmux attach-session
          else
            tmux attach -t "$REPLY"
          fi
        else
          tmux
        fi
      fi
    fi
  fi
}
tmux_attach_session
<commit_msg>Fix tmux auto attach script<commit_after># ref: http://qiita.com/b4b4r07/items/01359e8a3066d1c37edc
function is_tmux_running() { [ ! -z "$TMUX" ]; }
function shell_has_started_interactively() { [ ! -z "$PS1" ]; }
function is_ssh_running() { [ ! -z "$SSH_CONNECTION" ]; }

function tmux_attach_session() {
  if ! is_tmux_running; then
    if shell_has_started_interactively && ! is_ssh_running; then
      if (( $+commands[tmux] )); then
        if tmux has-session >/dev/null 2>&1; then
          tmux list-sessions
          echo -n "Tmux: attach? (y/N/num) "
          read
          if [[ "$REPLY" =~ ^[Yy]$ ]] || [[ "$REPLY" == '' ]]; then
            tmux attach-session
          elif [[ "$REPLY" =~ ^[Nn]$ ]]; then
            return 0
          else
            tmux attach -t "$REPLY"
          fi
        else
          tmux
        fi
      fi
    fi
  fi
}
tmux_attach_session

{'fraction_non_alphanumeric': 0.14496169711255155, 'fraction_numerical': 0.024160282852091926, 'mean_word_length': 2.132841328413284, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4398453', 'n_tokens_mistral': 639, 'n_tokens_neox': 612, 'n_words': 132}