#zmodload zsh/zprof

HISTFILE="$HOME/.zsh_history"
HISTSIZE=1000000000
SAVEHIST=1000000000
setopt hist_ignore_all_dups
setopt hist_ignore_space


LW_PATH=~/git/github.com/lunarway
GOPATH=~/go
GOBIN="$GOPATH/bin"
PATH="$HOME/.asdf/shims/:$GOBIN:$PATH:$HOME/bin/:$HOME/.local/bin/:$HOME/.dotnet/tools:$HOME/.cargo/bin:$HOME/.yarn/bin:$HOME/Library/Application Support/Coursier/bin:${KREW_ROOT:-$HOME/.krew}/bin"
{{ if .homebrew }}
export PATH="/opt/homebrew/opt/libpq/bin:$HOME/.git-bins/:$PATH"
export PATH="/opt/homebrew/opt/openjdk/bin:$PATH:$(brew --prefix llvm)/bin:$(brew --prefix llvm)/lib"
export PATH=/opt/homebrew/bin:$PATH
export PATH="/Users/kah/.rustup/toolchains/nightly-aarch64-apple-darwin/bin:$PATH"
{{ end }}

export DAGGER_CLOUD_TOKEN={{.dagger_cloud_token | quote}}

export SHUTTLE_INTERACTIVE=true
export SHUTTLE_REMOTE_TRACING=remote
export SHUTTLE_REMOTE_TRACING_URL=https://shuttle-telemetry.dev.lunar.tech/publish
export SHUTTLE_GOLANG_ACTIONS=true

export GITHUB_TOKEN={{ .github_token | quote }}
export GITHUB_USERNAME=kjuulh
export GITHUB_ACCESS_TOKEN="$GITHUB_TOKEN"
export HOMEBREW_GITHUB_API_TOKEN="$GITHUB_ACCESS_TOKEN"
export GITHUB_LUNAR_CI_TOKEN="$GITHUB_ACCESS_TOKEN"
export RENOVATE_TOKEN={{ .renovate_token | quote }}

export CLANK_KUBERNETES_CONFIGS={{ .clank_kubernetes_configs_path }}

# Toolkit
export SRC_ENDPOINT=https://lunar.sourcegraph.com
export SRC_ACCESS_TOKEN={{ .source_graph_token | quote }}
export GITHUB_FC_ROOT="$HOME/git/github.com"
export GITHUB_FC_ORGS="lunarway,kjuulh"

export GITEA_FUZZY_CLONE_ROOT="$HOME/git/git.front.kjuulh.io"
export GITEA_FUZZY_CLONE_ORGS="kjuulh"

{{ if .homebrew }}
export BITEME_ROOT="$HOME/Documents/vaults/kjuulh"
{{ else }}
export BITEME_ROOT="$HOME/Documents/obsidian"
{{ end }}

alias devshuttle="$HOME/go/bin/shuttle"
alias kitty="kitty --config ~/.config/kitty/kitty.conf"
alias lg="lazygit"

{{ if not .homebrew -}}
#alias hx="helix"
export EDITOR=hx
{{ else }}
HELIX_RUNTIME=/Users/kah/git/github.com/kjuulh/helix/runtime
export EDITOR=hx
{{ end -}}
export LW_DEFAULT_THEME='false'

export HAMCTL_AUTH_TOKEN={{ .hamctl_token | quote }}

fpath=("$HOME/.zsh_completions/" $fpath)
{{ if .homebrew }}
fpath=("$(brew --prefix)/share/zsh/site-functions" $fpath)
{{ end }}

# Use degit for faster cloning
#zstyle ':zim:completion' dumpfile
#zstyle ':completion::complete:*' cache-path ${XDG_CACHE_HOME}/zsh/zcompcache
zstyle ':zim:zmodule' use 'degit'

# set home
export ZIM_HOME=~/.zim

# Fetch zim package manager
if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then
  curl -fsSL --create-dirs -o ${ZIM_HOME}/zimfw.zsh \
      https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh
fi

# Install missing modules, and update ${ZIM_HOME}/init.zsh if missing or outdated.
if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZDOTDIR:-${HOME}}/.zimrc ]]; then
  source ${ZIM_HOME}/zimfw.zsh init -q
fi

# Initialize modules.
source ${ZIM_HOME}/init.zsh
source ~/bin/zimfwupdate.sh

### Lunar Way Setup ###

# Init zplug
#source ~/.zplug/init.zsh

# Instruct zplug to use ssh for fetching plugins
#ZPLUG_PROTOCOL=ssh

# Load default plugins from lw-zsh
#source ~/.zplug/repos/lunarway/lw-zsh/default-plugins.zsh

# Load plugins using zplug
#zplug "lunarway/lw-zsh"
#zplug "lunarway/hubble-zsh"

# Check for updates and install them
#if ! zplug check; then
#    zplug install
#fi

# Load all zplug plugins
#zplug load

# Configure Lunar Way kubernetes setup
#k8s_init kah@lunar.app

# Periodic updates
#lw_periodic_update

### Theme overrides here

## Dot files
alias config='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'

## Dev hamctl
#alias devhamctl='HAMCTL_URL="https://some-url" go run github.com/lunarway/release-manager cmd/hamctl/main.go'

{{ if .lunar }}
k8s_init kah@lunar.app admin
{{ end }}

#k8s_init kah@lunar.app dev

#eval "$(starship init zsh)"
eval "$(zoxide init zsh)"
eval "$(fuzzy-clone init zsh)"

# pnpm
export PNPM_HOME="{{ .pnpm_home }}"
export PATH="$PNPM_HOME:$PATH"
# pnpm end
#

alias ,="source ,cd"
alias ,g="source ,ccd"

export SHUTTLE_CACHE_DURATION_MIN=10080

#alias nvim=lvim
alias cat=bat
alias python=python3
alias pip=pip3
export LESS=-R
export _EXPERIMENTAL_DAGGER_TUI=yep
export OPENAI_API_KEY={{ .openai_token | quote }}

eval "$(starship init zsh)"
eval "$(atuin init zsh)"

#zprof
export ANSIBLE_VAULT_PASSWORD_FILE="~/.config/ansible/password"
export DRONE_SERVER=https://ci.i.kjuulh.io
export DRONE_HOST=https://ci.i.kjuulh.io
export DRONE_USER=kjuulh
export DRONE_TOKEN={{ .drone_token | quote }}
export GITEA_ACCESS_TOKEN={{ .gitea_token | quote }}
export GITEA_URL="https://git.i.kjuulh.io/api/v1"
export GITEA_ORG="kjuulh"

# bun completions
[ -s "/Users/kah/.bun/_bun" ] && source "/Users/kah/.bun/_bun"

# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"

export GITHUB_COMMITTER_EMAIL=contact@kjuulh
export GITHUB_COMMITTER_NAME=kjuulh
export SHUTTLE_EXTENSIONS_REGISTRY="git=git@github.com:kjuulh/shuttle-extensions.git"
export SHUTTLE_EXTENSIONS_GITHUB_ACCESS_TOKEN="$GITHUB_TOKEN"
export CUDDLE_PLEASE_TOKEN=$GITEA_ACCESS_TOKEN

#zprof
