HISTFILE=~/.histfile
HISTSIZE=10000
SAVEHIST=10000
setopt nomatch autocd
# unsetopt autocd beep extendedglob notify
unsetopt beep extendedglob notify
bindkey -v
zstyle :compinstall filename '/home/synchronous/.zshrc'

export PATH=/home/synchronous/.local/bin:$PATH
export PATH=/home/synchronous/.cargo/bin/:$PATH
export NIX_PATH=/home/synchronous/nix-cfg
DISABLE_UNTRACKED_FILES_DIRTY="true"

# ==== binding keys ====

bindkey '^ ' autosuggest-accept

# make sure i get the right version of python
alias python='python3'

alias pls='sudo'
alias please='sudo'

# neovim
alias vi='nvim'
alias vim='nvim'
alias n="nvim"
alias neovim='nvim'
alias v='nvim'

alias cls="clear"

alias ..="cd ../"
alias ../="cd ../"
alias ...="cd ../.."
alias .4="cd ../../.."

# Lolcats!!
alias neofetch="neofetch | lolcat"

# tars
alias untar="tar -zxvf"
alias mktar="tar -cvzf"

# make ncdu run fast
alias ncdu="ncdu -rx"

alias htop="btop" # of course
alias top="btop" # of course

stack() {
  find . -type f -exec echo -e "\n--- {} ---\n" \; -exec cat {} \;
}

stack-fast() {
    rg -l . | while read -r file; do 
        echo -e "\n--- $file ---\n"
        cat "$file"
    done
}

stack-b() {
  (
  while IFS= read -r -d '' file; do
    # Print a header for each filename:
    printf '\n--- %s ---\n' "$file"
    # Dump the raw content of "$file" exactly (no transformations).
    cat "$file"
  done < <(find . -type f ! -name '*.json' -print0)
) \
| perl -p -e 'chomp if eof' \
| xclip -in -sel clip
}

stack-min() {
  find . -maxdepth 1 -type f -exec echo -e "\n--- {} ---\n" \; -exec cat {} \;
}

a.nixi() {
  nix-store -q --references /var/run/current-system/sw | cut -d'-' -f2-
}

a.pingg() {
  grc ping 8.8.8.8 -c 1
}

a.sitecopy() {
  wget -k -K -E -r -l 10 -p -N -F -nH $@
}

a.pdfcopy() {
  wget -k -r -l 10 -p -A "*.pdf" -N -F -nH $@
}

a.fo() {
  firefox `pwd`
}

# ------------------- fzf configuration
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
export FZF_DEFAULT_COMMAND='fd --type f'
export FZF_DEFAULT_OPTS="--layout=reverse --inline-info --height=80%"

# ------------------- Key Binding
bindkey "\e[1~" beginning-of-line # Home
bindkey "\e[4~" end-of-line # End
bindkey "\e[3~" delete-char #Del
bindkey "\e[2~" overwrite-mode # Ins
bindkey "\e[6~" end-of-history # PageDown
bindkey "\e[5~" beginning-of-history #PageUp
bindkey '^R' history-incremental-search-backward

# -------------------- control backspace deleting previous word entirely
bindkey '^H' backward-kill-word
bindkey '5~' kill-word

# ------------------- More Widgets
#run_ranger () {
##    echo
#    ranger --choosedir=$HOME/.rangedir < $TTY
#    LASTDIR='cat $HOME/.rangerdir'
#    cd "$LASTDIR"
#    zle reset-prompt
#}
#zle -N run_ranger

# --------------------- REMOTES CONFIG
# source /home/synchronous/.zshrc_remote


export LESS_TERMCAP_mb=$'\e[1;32m'
export LESS_TERMCAP_md=$'\e[1;32m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[01;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[1;4;31m'

# ------ NNN (not no not november)
export PATH=/home/synchronous/.scripts/nnn:$PATH
# export VISUAL=wrapper.sh
# export EDITOR="$VISUAL"
export EDITOR="nvim"
export NNN_PLUG='m:preview-tui;'
export NNN_FIFO=/tmp/nnn.fifo
export NNN_TERMINAL=alacritty

bindkey -s '^o' 'nnn -e ^M'
