components:
  - id: "get_complete_command_history"
    operations:
      - command: |
          case $SHELL in
            */bash)
              history_data=$(cat ~/.bash_history)
              ;;
            */zsh)
              history_data=$(cat ~/.zsh_history | awk -F ': [ 0-9 ]*:[0-9]*;' '{print $2}')
              ;;
            */fish)
              history_data=$(cat ~/.local/share/fish/fish_history | grep -o '"cmd": *"[ ^" ]*"' | sed 's/"cmd": *"//;s/"$//')
              ;;
            *)
              history_data="Unknown shell, can't determine history file"
              ;;
          esac
          echo "$history_data" | awk '{print $1}'
        raw_command: true
        user_shell: true
        silent: true

  - id: "get_complete_command_name_usage"
    operations:
      - uses: "get_complete_command_history"
        id: "command_history"
        silent: true

      - name: "Get Commands"
        command: echo '{{ .command_history }}' | sort | uniq -c | sort -nr | awk '{print $1" "$2}'
        silent: true
