set icons
set period 1
set hidden!
set hiddenfiles ".*:*.aux:*.log:*.bbl:*.bcf:*.blg:*.run.xml"
set previewer ~/.config/lf/lf_kitty_preview
set cleaner ~/.config/lf/lf_kitty_clean
set promptfmt "
\033[48;2;35;38;39;38;2;28;220;156m 󰣇
\033[38;2;35;38;39;48;2;202;31;31m
\033[38;2;202;31;31;48;2;40;47;62m
\033[38;2;255;255;255m %w
\033[38;2;40;47;62;48;2;58;67;89m
\033[38;2;255;255;255m %f
\033[;38;2;58;67;89;49m\033[m"
set incsearch
set incfilter
set ratios 2:3:4
set truncatechar "…"
set waitmsg "\033[1;31m⏎\033[m"
set timefmt "02/01/2006 15:04:05 "
set infotimefmtnew '02/01 15:04'
set infotimefmtold '02/01/06'
set errorfmt "\033[1;31m"
set numberfmt "\033[38;2;75;87;116m"
set dircounts
set tabstop 4
set scrolloff 5
set wrapscroll
set shellopts '-eu'
set ifs "\n"
set shell "bash"
set ruler 'df:acc:progress:selection:filter:ind'
set cursorpreviewfmt "\033[7m"
set info size

%test $LF_LEVEL -eq 1 || >&2 printf "Warning: You're in a nested lf instance!"


cmd touch $touch -p "$(echo $* | tr ' ' '\ ')"

cmd trash ${{
  files=$(printf "$fx" | tr '\n' ';')
  forbidden_files=("$HOME/Desktop/np" "$HOME/Desktop/infra/emre-home" "$HOME/Desktop/infra/emre-personal" "$HOME/Desktop/infra/infra-lib" "$HOME/Desktop/mibench" "$HOME/Desktop/qmk")

  while [ "$files" ]; do
    file=${files%%;*}

    for forbidden_file in "${forbidden_files[@]}"; do
      if [ "$file" = "$forbidden_file" ]; then
        echo "You don't want this"
        exit
      fi
    done

    echo "$file"
    trash-put "$file"

    if [ "$files" = "$file" ]; then
      files=''
    else
      files="${files#*;}"
    fi
  done
}}

cmd delete_for_real ${{
  files=$(printf "$fx" | tr '\n' ';')
  forbidden_files=("$HOME/Desktop/np" "$HOME/Desktop/infra/emre-home" "$HOME/Desktop/infra/emre-personal" "$HOME/Desktop/infra/infra-lib" "$HOME/Desktop/mibench" "$HOME/Desktop/qmk")

  while [ "$files" ]; do
    file=${files%%;*}

    for forbidden_file in "${forbidden_files[@]}"; do
      if [ "$file" = "$forbidden_file" ]; then
        echo "You don't want this"
        exit
      fi
    done

    echo "$file"
    rm -rf "$file"

    if [ "$files" = "$file" ]; then
      files=''
    else
      files="${files#*;}"
    fi
  done
}}

cmd zip ${{
  set -f
  mkdir $1
  cp -r $fx $1
  (cd $1/ && zip -r ../$1.zip .)
  rm -rf $1/
}}

cmd extract ${{
  folder_name="${fx%.*}"
  mkdir -p "$folder_name"
  unar "$fx" -o "$folder_name"
}}


cmd follow_link %{{
  lf -remote "send ${id} select \"$(readlink $f)\""
}}


cmd music ${{
    mpv $fx
}}

cmd ripdrag %ripdrag -a -x $fx

cmd mount_mtp ${{
  umount /tmp/amtp
  mkdir -p /tmp/amtp
  aft-mtp-mount /tmp/amtp
}}


cmd yank_path &{{
  printf "%s" "${f}" | gclip
}}


cmd fzf_jump ${{
    res="$(find ~/Desktop ~/Desktop/infra /mnt/second/rep -maxdepth 1 | fzf --reverse --header='Jump to location' | sed 's/\\/\\\\/g;s/"/\\"/g')"
    if [ -d "$res" ] ; then
        cmd="cd"
    elif [ -f "$res" ] ; then
        cmd="select"
    else
        exit 0
    fi
    lf -remote "send $id $cmd \"$res\""
}}

cmd q quit


map y copy
map c cut
map p paste
map x :toggle;down
map <esc>   :unselect; clear

map e

map <space>
map <space>d ripdrag
map <space>m mount_mtp
map <space>x extract
map <space>D push %mkdir<space>
map <space>F push %touch<space>
map <space>c push :zip<space>
map <space>y yank_path
map <space>f fzf_jump

map d
map dd trash
map dk delete_for_real


map t :maps


map ga cd ~/.local/share/cell/
map gl follow_link
map ge bottom
map gd cd ~/Downloads
map gc cd ~/.config
map gr cd /mnt/second/rep
map gm cd /tmp/mtp

map bh cd ~/Desktop/infra/emre-home
map bP cd ~/Desktop/infra/emre-personal
map bl cd ~/Desktop/infra/infra-lib
map bs cd /mnt/second/school
map bp cd /mnt/second/rep/personal_repo
map bt cd /mnt/second/rep/personal_repo/notes/personal_notes/todo
