<commit_before>

_tmux()
{

  local subcommands="attach new-session list-sessions"
  local cur="${COMP_WORDS[COMP_CWORD]}"
  local prev="${COMP_WORDS[COMP_CWORD-1]}"

  case $prev in 
    -t)
      COMPREPLY=( $(compgen -W "$(tmux list-sessions | awk -F ':' '{print $1}')" -- $cur) )
      return 0
  esac

  COMPREPLY=( $(compgen -W "$(tmux list-commands | awk '{print $1'})" -- $cur))
  return 0
}

complete -F _tmux tmux<commit_msg>Properly handle when no tmux server is running<commit_after>

_tmux()
{
  local subcommands="list-sessions attach new-session"
  local cur="${COMP_WORDS[COMP_CWORD]}"
  local prev="${COMP_WORDS[COMP_CWORD-1]}"

  case $prev in 
    -t)
      local sessions=$(tmux list-sessions 2>&1)
      if [[ $? == 0 ]]; then
        COMPREPLY=( $(compgen -W "$(echo $sessions | awk -F ':' '{print $1}')" -- $cur) )
        return 0
      fi
      ;;
  esac

  local commands=$(tmux list-commands 2>/dev/null | awk '{printf("%s ",$1)}')
  if [[ -z $commands ]]; then
    COMPREPLY=( $(compgen -W "$subcommands" -- $cur))
  else
    COMPREPLY=( $(compgen -W "$commands" -- $cur))
  fi
  return 0
}

complete -F _tmux tmux
{'fraction_non_alphanumeric': 0.18476357267950963, 'fraction_numerical': 0.012259194395796848, 'mean_word_length': 3.03886925795053, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1639081', 'n_tokens_mistral': 441, 'n_tokens_neox': 427, 'n_words': 112}