version: v0.4.4
general:
  show_hidden: false
  prompt:
    format: "> "
  cursor:
    format: █
  logs:
    info:
      format: "INFO"
      style:
        fg: LightBlue
    success:
      format: "SUCCESS"
      style:
        fg: Green
    error:
      format: "ERROR"
      style:
        fg: Red
  table:
    header:
      cols:
        - format: │     path
          style:
            fg: null
            bg: null
            add_modifier:
              bits: 0
            sub_modifier:
              bits: 0
        - format: type
          style:
            fg: null
            bg: null
            add_modifier:
              bits: 0
            sub_modifier:
              bits: 0
        - format: ' index'
          style:
            fg: null
            bg: null
            add_modifier:
              bits: 0
            sub_modifier:
              bits: 0
      style:
        fg: null
        bg: null
        add_modifier:
          bits: 1
        sub_modifier:
          bits: 0
      height: 1
    row:
      cols:
        - format: >
            {{{tree}}}{{{prefix}}}{{{meta.icon}}}
            {{{relativePath}}}{{#if isDir}}/{{/if}}{{{suffix}}}
            {{#if isSymlink}}-> {{#if isBroken}}×{{else}}{{{symlink.absolutePath}}}{{/if}}{{#if symlink.isDir}}/{{/if}}{{/if}}

          style:
            fg: null
            bg: null
            add_modifier:
              bits: 0
            sub_modifier:
              bits: 0
        - format: '{{#if isSymlink}}{{{symlink.mimeEssence}}}{{else}}{{{mimeEssence}}}{{/if}}'
          style:
            fg: null
            bg: null
            add_modifier:
              bits: 0
            sub_modifier:
              bits: 0
        - format: '{{#if isBeforeFocus}}-{{else}} {{/if}}{{{relativeIndex}}}/{{{index}}}/{{{total}}}'
          style:
            fg: null
            bg: null
            add_modifier:
              bits: 0
            sub_modifier:
              bits: 0
      style:
        fg: null
        bg: null
        add_modifier:
          bits: 0
        sub_modifier:
          bits: 0
      height: 0
    style:
      fg: null
      bg: null
      add_modifier:
        bits: 0
      sub_modifier:
        bits: 0
    tree:
      - format: ├─
        style:
          fg: null
          bg: null
          add_modifier:
            bits: 0
          sub_modifier:
            bits: 0
      - format: ├─
        style:
          fg: null
          bg: null
          add_modifier:
            bits: 0
          sub_modifier:
            bits: 0
      - format: ╰─
        style:
          fg: null
          bg: null
          add_modifier:
            bits: 0
          sub_modifier:
            bits: 0
    col_spacing: 3
    col_widths:
      - percentage: 60
      - percentage: 20
      - percentage: 20
  default_ui:
    prefix: '  '
    suffix: ''
    style:
      fg: null
      bg: null
      add_modifier:
        bits: 0
      sub_modifier:
        bits: 0
  focus_ui:
    prefix: ▸[
    suffix: ']'
    style:
      fg: Blue
      bg: null
      add_modifier:
        bits: 1
      sub_modifier:
        bits: 0
  selection_ui:
    prefix: ' {'
    suffix: '}'
    style:
      fg: LightGreen
      bg: null
      add_modifier:
        bits: 1
      sub_modifier:
        bits: 0

node_types:
  directory:
    style:
      fg: Cyan
      bg: null
      add_modifier:
        bits: 1
      sub_modifier:
        bits: 0
    meta:
      icon: ð
  file:
    style:
      fg: null
      bg: null
      add_modifier:
        bits: 0
      sub_modifier:
        bits: 0
    meta:
      icon: ƒ
  symlink:
    style:
      fg: Magenta
      bg: null
      add_modifier:
        bits: 4
      sub_modifier:
        bits: 0
    meta:
      icon: §
  mime_essence: {}
  extension: {}
  special: {}

modes:
  builtin:
    selection_ops:
      name: selection ops
      help: null
      extra_help: null
      key_bindings:
        remaps: {}
        on_key:
          c:
            help: copy here
            messages:
              - BashExec: |
                  (while IFS= read -r line; do
                    if cp -vr "${line:?}" ./; then
                      echo "LogSuccess: $line copied to $PWD" >> "${XPLR_PIPE_MSG_IN:?}"
                    else
                      echo "LogError: Failed to copy $line to $PWD" >> "${XPLR_PIPE_MSG_IN:?}"
                    fi
                  done < "${XPLR_PIPE_SELECTION_OUT:?}")
                  echo Explore >> "${XPLR_PIPE_MSG_IN:?}"
                  echo ClearSelection >> "${XPLR_PIPE_MSG_IN:?}"
                  read -p "[enter to continue]"
              - SwitchMode: default

          m:
            help: move here
            messages:
              - BashExec: |
                  (while IFS= read -r line; do
                    if mv -v "${line:?}" ./; then
                      echo "LogSuccess: $line moved to $PWD" >> "${XPLR_PIPE_MSG_IN:?}"
                    else
                      echo "LogError: Failed to move $line to $PWD" >> "${XPLR_PIPE_MSG_IN:?}"
                    fi
                  done < "${XPLR_PIPE_SELECTION_OUT:?}")
                  echo Explore >> "${XPLR_PIPE_MSG_IN:?}"
                  read -p "[enter to continue]"
              - SwitchMode: default

          ctrl-c:
            help: terminate
            messages:
              - Terminate

        default:
          messages:
            - SwitchMode: default

    create_file:
      name: create file
      help: null
      extra_help: null
      key_bindings:
        remaps: {}
        on_key:
          enter:
            help: create file
            messages:
              - BashExecSilently: |
                  PTH="${XPLR_INPUT_BUFFER:?}"
                  if touch "${PTH:?}"; then
                    echo Explore >> "${XPLR_PIPE_MSG_IN:?}"
                    echo "LogSuccess: $PTH created" >> "${XPLR_PIPE_MSG_IN:?}"
                    echo "FocusPath: $PTH" >> "${XPLR_PIPE_MSG_IN:?}"
                  else
                    echo "LogError: Failed to create $PTH" >> "${XPLR_PIPE_MSG_IN:?}"
                    echo Refresh >> "${XPLR_PIPE_MSG_IN:?}"
                  fi
              - SwitchMode: default

          backspace:
            help: clear
            messages:
              - SetInputBuffer: ""

          esc:
            help: cancel
            messages:
              - SwitchMode: default

          ctrl-c:
            help: terminate
            messages:
              - Terminate

        default:
          messages:
            - BufferInputFromKey

    create_directory:
      name: create directory
      help: null
      extra_help: null
      key_bindings:
        remaps: {}
        on_key:
          enter:
            help: create directory
            messages:
              - BashExecSilently: |
                  PTH="${XPLR_INPUT_BUFFER:?}"
                  if mkdir -p "${PTH:?}"; then
                    echo Explore >> "${XPLR_PIPE_MSG_IN:?}"
                    echo "LogSuccess: $PTH created" >> "${XPLR_PIPE_MSG_IN:?}"
                    echo "FocusPath: $PTH" >> "${XPLR_PIPE_MSG_IN:?}"
                  else
                    echo "LogError: Failed to create $PTH" >> "${XPLR_PIPE_MSG_IN:?}"
                    echo Refresh >> "${XPLR_PIPE_MSG_IN:?}"
                  fi
              - SwitchMode: default

          backspace:
            help: clear
            messages:
              - SetInputBuffer: ""

          esc:
            help: cancel
            messages:
              - SwitchMode: default

          ctrl-c:
            help: terminate
            messages:
              - Terminate

        default:
          messages:
            - BufferInputFromKey

    create:
      name: create
      help: null
      extra_help: null
      key_bindings:
        remaps: {}
        on_key:
          ctrl-c:
            help: terminate
            messages:
              - Terminate
          d:
            help: create directory
            messages:
              - SwitchMode: create directory
              - SetInputBuffer: ''
          esc:
            help: cancel
            messages:
              - SwitchMode: default
          f:
            help: create file
            messages:
              - SwitchMode: create file
              - SetInputBuffer: ''
        on_alphabet: null
        on_number: null
        on_special_character: null
        default:
          help: null
          messages:
            - SwitchMode: default
    rename:
      name: rename
      help: null
      extra_help: null
      key_bindings:
        remaps: {}
        on_key:
          enter:
            help: rename
            messages:
              - BashExecSilently: |
                  SRC="${XPLR_FOCUS_PATH:?}"
                  TARGET="${XPLR_INPUT_BUFFER:?}"
                  if mv -v "${SRC:?}" "${TARGET:?}"; then
                    echo Explore >> "${XPLR_PIPE_MSG_IN:?}"
                    echo "LogSuccess: $SRC renamed to $TARGET" >> "${XPLR_PIPE_MSG_IN:?}"
                    echo "FocusPath: $TARGET" >> "${XPLR_PIPE_MSG_IN:?}"
                  else
                    echo "LogError: Failed to rename $SRC to $TARGET" >> "${XPLR_PIPE_MSG_IN:?}"
                  fi
              - SwitchMode: default

          backspace:
            help: clear
            messages:
              - SetInputBuffer: ""

          esc:
            help: cancel
            messages:
              - SwitchMode: default

          ctrl-c:
            help: terminate
            messages:
              - Terminate

        default:
          messages:
            - BufferInputFromKey

    default:
      name: default
      help: null
      extra_help: null
      key_bindings:
        remaps:
          /: ctrl-f
          h: left
          j: down
          k: up
          l: right
          v: space
          V: ctrl-a
          tab: ctrl-i
        on_key:
          '#':
            help: null
            messages:
              - PrintAppStateAndQuit
          .:
            help: show hidden
            messages:
              - ToggleNodeFilter:
                  filter: RelativePathDoesNotStartWith
                  input: .
                  case_sensitive: false
              - Explore
          ':':
            help: action
            messages:
              - SwitchMode: action
          '?':
            help: global help menu
            messages:
              - BashExec: |
                  ${PAGER:-less} "${XPLR_PIPE_GLOBAL_HELP_MENU_OUT}"
          '~':
            help: go home
            messages:
              - BashExecSilently: |
                  echo "ChangeDirectory: ${HOME:?}" >> "${XPLR_PIPE_MSG_IN:?}"
          G:
            help: go to bottom
            messages:
              - FocusLast
          ctrl-c:
            help: terminate
            messages:
              - Terminate
          ctrl-f:
            help: search
            messages:
              - SwitchMode: search
              - SetInputBuffer: ''
              - Explore
          d:
            help: delete
            messages:
              - SwitchMode: delete
          down:
            help: down
            messages:
              - FocusNext
          enter:
            help: quit with result
            messages:
              - PrintResultAndQuit
          g:
            help: go to
            messages:
              - SwitchMode: go to
          left:
            help: back
            messages:
              - Back
          r:
            help: rename
            messages:
              - SwitchMode: rename
              - BashExecSilently: |
                  echo "SetInputBuffer: $(basename ${XPLR_FOCUS_PATH})" >> "${XPLR_PIPE_MSG_IN:?}"
          right:
            help: enter
            messages:
              - Enter
          space:
            help: toggle selection
            messages:
              - ToggleSelection
              - FocusNext
          ctrl-a:
            help: select all
            messages:
              - ToggleSelectAll
          up:
            help: up
            messages:
              - FocusPrevious
          ctrl-o:
            help: last visited path
            messages:
              - LastVisitedPath

          ctrl-i:  # Actually means tab
            help: next visited path
            messages:
              - NextVisitedPath
          q:
            help: quit
            messages:
              - Quit

        on_alphabet: null
        on_number:
          help: input
          messages:
            - ResetInputBuffer
            - SwitchMode: number
            - BufferInputFromKey
        on_special_character: null
        default:
          help: null
          messages:
            - SwitchMode: default
    go_to:
      name: go to
      help: null
      extra_help: null
      key_bindings:
        remaps: {}
        on_key:
          ctrl-c:
            help: terminate
            messages:
              - Terminate
          g:
            help: top
            messages:
              - FocusFirst
              - SwitchMode: default
          x:
            help: open in gui
            messages:
              - BashExecSilently: |
                  OPENER="$(which xdg-open)"
                  ${OPENER:-open} "${XPLR_FOCUS_PATH:?}" &> /dev/null
              - SwitchMode: default

        on_alphabet: null
        on_number: null
        on_special_character: null
        default:
          help: null
          messages:
            - SwitchMode: default

    number:
      name: number
      help: null
      extra_help: null
      key_bindings:
        remaps:
          j: down
          k: up
        on_key:
          backspace:
            help: clear
            messages:
              - SetInputBuffer: ""
          ctrl-c:
            help: terminate
            messages:
              - Terminate
          down:
            help: to down
            messages:
              - FocusNextByRelativeIndexFromInput
              - SwitchMode: default
          enter:
            help: to index
            messages:
              - FocusByIndexFromInput
              - SwitchMode: default
          up:
            help: to up
            messages:
              - FocusPreviousByRelativeIndexFromInput
              - SwitchMode: default
        on_alphabet: null
        on_number:
          help: input
          messages:
            - BufferInputFromKey
        on_special_character: null
        default:
          help: null
          messages:
            - SwitchMode: default
    delete:
      name: delete
      help: null
      extra_help: null
      key_bindings:
        remaps: {}
        on_key:
          d:
            help: delete
            messages:
              - BashExec: |
                  (while IFS= read -r line; do
                    if [ -d "$line" ]; then
                      if rmdir -v "${line:?}"; then
                        echo "LogSuccess: $line deleted" >> "${XPLR_PIPE_MSG_IN:?}"
                      else
                        echo "LogError: Failed to delete $line" >> "${XPLR_PIPE_MSG_IN:?}"
                      fi
                    else
                      if rm -v "${line:?}"; then
                        echo "FocusNext" >> "${XPLR_PIPE_MSG_IN:?}"
                        echo "LogSuccess: $line deleted" >> "${XPLR_PIPE_MSG_IN:?}"
                      else
                        echo "LogError: Failed to delete $line" >> "${XPLR_PIPE_MSG_IN:?}"
                      fi
                    fi
                  done < "${XPLR_PIPE_RESULT_OUT:?}")
                  echo Explore >> "${XPLR_PIPE_MSG_IN:?}"
                  read -p "[enter to continue]"
              - SwitchMode: default

          D:
            help: force delete
            messages:
              - BashExec: |
                  (while IFS= read -r line; do
                    if rm -rfv "${line:?}"; then
                      echo "FocusNext" >> "${XPLR_PIPE_MSG_IN:?}"
                      echo "LogSuccess: $line deleted" >> "${XPLR_PIPE_MSG_IN:?}"
                    else
                      echo "LogError: Failed to delete $line" >> "${XPLR_PIPE_MSG_IN:?}"
                    fi
                  done < "${XPLR_PIPE_RESULT_OUT:?}")
                  echo Explore >> "${XPLR_PIPE_MSG_IN:?}"
                  read -p "[enter to continue]"
              - SwitchMode: default
              - Explore

          ctrl-c:
            help: terminate
            messages:
              - Terminate
        
        default:
          messages:
            - SwitchMode: default

    action:
      name: action to
      help: null
      extra_help: null
      key_bindings:
        remaps: {}
        on_number:
          help: go to index
          messages:
            - ResetInputBuffer
            - SwitchMode: number
            - BufferInputFromKey

        on_key:
          "!":
            help: shell
            messages:
              - Call:
                  command: bash
              - Explore
              - SwitchMode: default

          c:
            help: create
            messages:
              - SwitchMode: create

          e:
            help: open in editor
            messages:
              - BashExec: |
                  ${EDITOR:-vi} "${XPLR_FOCUS_PATH:?}"
              - SwitchMode: default

          s:
            help: selection operations
            messages:
              - SwitchMode: selection ops

          l:
            help: logs
            messages:
              - BashExec: |
                  cat "${XPLR_PIPE_LOGS_OUT}"
                  read -p "[enter to continue]"
              - SwitchMode: default

          ctrl-c:
            help: terminate
            messages:
              - Terminate

        default:
          messages:
            - SwitchMode: default
    search:
      name: search
      help: null
      extra_help: null
      key_bindings:
        remaps: {}
        on_key:
          backspace:
            help: clear
            messages:
              - RemoveNodeFilterFromInput:
                  filter: RelativePathDoesContain
                  case_sensitive: false
              - SetInputBuffer: ''
              - Explore
          ctrl-c:
            help: terminate
            messages:
              - Terminate
          down:
            help: down
            messages:
              - FocusNext
          enter:
            help: focus
            messages:
              - RemoveNodeFilterFromInput:
                  filter: RelativePathDoesContain
                  case_sensitive: false
              - SwitchMode: default
              - Explore
          esc:
            help: cancel
            messages:
              - RemoveNodeFilterFromInput:
                  filter: RelativePathDoesContain
                  case_sensitive: false
              - SwitchMode: default
              - Explore
          left:
            help: back
            messages:
              - RemoveNodeFilterFromInput:
                  filter: RelativePathDoesContain
                  case_sensitive: false
              - Back
              - SetInputBuffer: ''
              - Explore
          right:
            help: enter
            messages:
              - RemoveNodeFilterFromInput:
                  filter: RelativePathDoesContain
                  case_sensitive: false
              - Enter
              - SetInputBuffer: ''
              - Explore
          up:
            help: up
            messages:
              - FocusPrevious
        on_alphabet: null
        on_number: null
        on_special_character: null
        default:
          help: null
          messages:
            - RemoveNodeFilterFromInput:
                filter: RelativePathDoesContain
                case_sensitive: false
            - BufferInputFromKey
            - AddNodeFilterFromInput:
                filter: RelativePathDoesContain
                case_sensitive: false
            - Explore

  custom: {}
