# Custom zshrc for my setup, this mostly has extra docker aliases and a list of plugins.

# This will go with my zsh installer script.

# Enable this if using a custom welcome message for SSH/user login.
# https://stackoverflow.com/questions/22913551/how-to-run-profile-inside-a-shell-script-in-ubuntu
# bash /etc/update-motd.d/5-welcome.sh

#-------------
# Default ZSH settings
#-------------

# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
  source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"

# Set name of the theme to load
ZSH_THEME="powerlevel10k/powerlevel10k"

# Uncomment one of the following lines to change the auto-update behavior
# zstyle ':omz:update' mode disabled  # disable automatic updates
# zstyle ':omz:update' mode auto      # update automatically without asking
# zstyle ':omz:update' mode reminder  # just remind me to update when it's time

# Uncomment the following line to change how often to auto-update (in days).
# zstyle ':omz:update' frequency 13

plugins=(
    command-not-found
    extract
    deno
    docker
    git
    github
    gitignore
    history-substring-search
    node
    npm
    nvm
    yarn
    volta
    vscode
    sudo
    web-search
    z
    zsh-autosuggestions
    zsh-syntax-highlighting
    ohmyzsh-full-autoupdate
)


source $ZSH/oh-my-zsh.sh

#-------------
# User configuration
#-------------

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

#-------------
# Aliases
#-------------

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.

# Add docker aliases
alias dcu='docker compose up -d'
alias dcp='docker compose pull'
alias dcs='docker compose stop'
alias dcrm='docker compose rm'
alias dcub='docker compose up --build -d'

# New for docker
# Display the IP of a container
# https://stackoverflow.com/questions/17157721/how-to-get-a-docker-containers-ip-address-from-the-host
alias dcnet='docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $1'

# Stop, remove, update and start a container back up.
alias dcup='docker compose stop && docker compose rm -f && docker compose pull && docker compose up --force-recreate -d'

# This is for gpg, I'm quite sure it is for making the password prompt show up in the terminal.
export GPG_TTY=$(tty)

alias update='sudo apt update && sudo apt upgrade -y --autoremove'

# Find total amount of files in a folder.
alias findcnt='find . | wc -l'

# Shortcut for downloading youtube videos and music with yt-dlp
# yt-dlp is required for these.
alias ytvideo-download='yt-dlp -o "%(title)s.%(ext)s" -f bestvideo+bestaudio/best'
alias ytmusic-download='yt-dlp -o "%(title)s.%(ext)s" -f bestaudio\[ext=m4a\]'

# Add path
export PATH=$HOME/bin:/usr/local/bin:$HOME/.local/bin:$PATH

# Make spaced commands not show in zsh history
# https://superuser.com/questions/352788/how-to-prevent-a-command-in-the-zshell-from-being-saved-into-history
setopt HIST_IGNORE_SPACE

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh