<commit_before># Open new iTerm and Terminal tabs from the command line
#
# USAGE
#
#   tab                   Opens the current directory in a new tab
#   tab [path]            Open PATH in a new tab
#   tab [cmd]             Open a new tab and execute CMD
#   tab [path] [cmd] ...  You can prolly guess
#
# If you use iTerm and your default session profile isn't "Default Session",
# override it in your `config.fish` or `omf/init.fish`
#
#     set -g tab_iterm_profile "MyProfile"
#
# AUTHOR
#
#   <NAME> (http://<EMAIL>)
#

function tab -d 'Open the current directory (or any other directory) in a new tab'
  set -l cmd ''
  set -l cdto $PWD

  if test (count $argv) -gt 0
    if test -d $argv[1]
      pushd . >/dev/null
      cd $argv[1]
      set cdto $PWD
      set -e argv[1]
      popd >/dev/null
    end
  end

  if test (count $argv) -gt 0
    set cmd "; $argv"
  end

  switch $TERM_PROGRAM

  case 'iTerm.app'
    set -l profile 'Default Session'
    if set -q tab_iterm_profile
      set profile $tab_iterm_profile
    end
    osascript 2>/dev/null -e "
      tell application \"iTerm\"
        tell current terminal
          launch session \"$profile\"
          tell the last session
            write text \"cd \\\"$cdto\\\"$cmd\"
          end tell
        end tell
      end tell
    "; or osascript 2>/dev/null -e "
      tell application \"iTerm\"
        tell current window
          set newTab to (create tab with profile \"$profile\")
          tell current session of newTab
            write text \"cd \\\"$cdto\\\"$cmd\"
          end tell
        end tell
      end tell
    "

  case 'Apple_Terminal'
    osascript 2>/dev/null -e "
      tell application \"Terminal\"
        activate
        tell application \"System Events\" to keystroke \"t\" using command down
        repeat while contents of selected tab of window 1 starts with linefeed<commit_msg>Use default session on iTerm Beta by default<commit_after># Open new iTerm and Terminal tabs from the command line
#
# USAGE
#
#   tab                   Opens the current directory in a new tab
#   tab [path]            Open PATH in a new tab
#   tab [cmd]             Open a new tab and execute CMD
#   tab [path] [cmd] ...  You can prolly guess
#
# If you use iTerm and your default session profile isn't "Default Session",
# override it in your `config.fish` or `omf/init.fish`
#
#     set -g tab_iterm_profile "MyProfile"
#
# AUTHOR
#
#   <NAME> (http://justinhileman.com)
#

function tab -d 'Open the current directory (or any other directory) in a new tab'
  set -l cmd ''
  set -l cdto $PWD

  if test (count $argv) -gt 0
    if test -d $argv[1]
      pushd . >/dev/null
      cd $argv[1]
      set cdto $PWD
      set -e argv[1]
      popd >/dev/null
    end
  end

  if test (count $argv) -gt 0
    set cmd "; $argv"
  end

  switch $TERM_PROGRAM

  case 'iTerm.app'
    if set -q tab_iterm_profile
      set profile $tab_iterm_profile
    else
      set profile "Default Session"
    end

    osascript 2>/dev/null -e "
      tell application \"iTerm\"
        tell current terminal
          launch session \"$profile\"
          tell the last session
            write text \"cd \\\"$cdto\\\"$cmd\"
          end tell
        end tell
      end tell
    "; or begin
      # Support for iTerm 2.9 beta:
      # - Handle new interface.
      # - New feature: open tab with default profile.

      if set -q tab_iterm_profile
        set profile "profile \"$tab_iterm_profile\""
      else
        set profile "default profile"
      end

      osascript 2>/dev/null -e "
        tell application \"iTerm\"
          tell current window
            set newTab to (create tab with $profile)
            tell current session of newTab
              write text \"cd \\\"$cdto\\\"$cmd\"
            end tell
          end tell
        end tell
      "
    end

  case 'Apple_Terminal'
    osascript 2>/dev/null -e "
      tell application \"Terminal\"
        activate
        tell application \"System Events\" to keystroke \"t\" using command down
        repeat while contents of selected tab of window 1 starts with linefeed
{'fraction_non_alphanumeric': 0.09271844660194174, 'fraction_numerical': 0.0048543689320388345, 'mean_word_length': 1.8737796373779638, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 16, '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': '4162976', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1237, 'n_words': 504}