# Paths
export ZSH="$HOME/.oh-my-zsh"
export PATH="$PATH:$HOME/.go/bin:$HOME/.local/bin:$HOME/.cargo/bin:$HOME/.dotnet/tools:$HOME/.emacs.d/bin"
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export PenTestTools=$HOME/Local/PenTesting/
export CTF=$HOME/Documents/CTF/
export WORKSPACE=$HOME/workspace_l
export ZSHRC="$HOME/.zshrc"
export VISUAL="nvim"
export EDITOR="nvim"


# History
export HISTSIZE=50000
export SAVEHIST=50000
export HISTTIMEFORMAT="[%F %T] "

# Following commands from: https://registerspill.thorstenball.com/p/which-command-did-you-run-1731-days
# Immediately append to history file:
setopt INC_APPEND_HISTORY

# Record timestamp in history:
setopt EXTENDED_HISTORY

# Expire duplicate entries first when trimming history:
setopt HIST_EXPIRE_DUPS_FIRST

# Dont record an entry that was just recorded again:
setopt HIST_IGNORE_DUPS

# Delete old recorded entry if new entry is a duplicate:
setopt HIST_IGNORE_ALL_DUPS

# Do not display a line previously found:
setopt HIST_FIND_NO_DUPS

# Dont record an entry starting with a space:
setopt HIST_IGNORE_SPACE

# Dont write duplicate entries in the history file:
setopt HIST_SAVE_NO_DUPS

# Share history between all sessions:
setopt SHARE_HISTORY

# Alias
alias q="exit"
alias vim="nvim"
alias cat="bat --pager=never"
alias ranger='ranger --choosedir=$HOME/.rangerdir; LASTDIR=`cat $HOME/.rangerdir`; cd "$LASTDIR"'
alias xsel='xsel -ib'
alias df="df -h"
alias picpaste="xclip -selection clipboard -t image/png -o"
alias wttr="curl wttr.in/Essen"
alias notify="dunstify \"ping~\""
alias latexmk="latexmk -f -pdf -interaction=nonstopmode"
alias picotik="picocom --b 115200 /dev/ttyUSB0"

# Theme
ZSH_THEME="agnoster"

# Plugins
plugins=(
    git
    history
    z
    zsh-eza
)

randpw() { < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-$1};echo;};

autoload -U +X bashcompinit && bashcompinit

if [[ -z "$ZELLIJ" ]]; then
    if [[ "$ZELLIJ_AUTO_ATTACH" == "true" ]]; then
        zellij attach -c
    else
        zellij
    fi

    if [[ "$ZELLIJ_AUTO_EXIT" == "true" ]]; then
        exit
    fi
fi

# Source
source $ZSH/oh-my-zsh.sh
