<commit_before>
function g
  set -l config "$HOME/.lists/g"
  awk -v "key=$argv[1]" -F' += +' '
    $1 == key {
      dst = $2
      if (dst !~ /^\//) {
        dst = ENVIRON["HOME"] "/" dst
      }
      print dst
      exit
    }
  ' $config | read -l dst
  test -n "$dst"; and cd "$dst"
end

function __g_keys
  awk -F' += +' '{ print $1 "\t" $2 }' "$HOME/.lists/g"
end

complete -c g --no-files -a "(__g_keys)"

<commit_msg>Extend g command, with argparse #fish<commit_after>function g
  set -l config "$HOME/.lists/g"

  argparse --name g add edit -- $argv
  or return

  # --add
  if set -q _flag_add
    set -l key (basename $PWD)
    set -l value (pwd | sed -e "s#"$HOME"/##")
    echo "$key = $value" | tee -a $config
    return
  end

  # --edit
  if set -q _flag_edit
    $EDITOR $config
    return
  end

  # empty...
  if test -z "$argv"
    cat $config
    return
  end

  awk -v "key=$argv[1]" -F' += +' '
    $1 == key {
      dst = $2
      if (dst !~ /^\//) {
        dst = ENVIRON["HOME"] "/" dst
      }
      print dst
      exit
    }
  ' $config | read -l dst
  test -n "$dst"; and cd "$dst"
end

function __g_keys
  awk -F' += +' '{ print $1 "\t" $2 }' "$HOME/.lists/g"
end

complete -c g -l edit -l add
complete -c g --no-files -a "(__g_keys)"

{'fraction_non_alphanumeric': 0.18833727344365642, 'fraction_numerical': 0.007880220646178092, 'mean_word_length': 1.8097345132743363, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3593586', 'n_tokens_mistral': 520, 'n_tokens_neox': 510, 'n_words': 162}