You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
4.1 KiB
Bash

# vim:ft=zsh:fenc=utf-8
# Shell Integration
source "$HOME/.config/wezterm/wezterm.sh"
# Prompt
eval "$(starship init zsh)"
# source antidote
source ${ZDOTDIR:-~}/.antidote/antidote.zsh
# set omz variables
ZSH=$(antidote path ohmyzsh/ohmyzsh)
ZSH_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/oh-my-zsh"
[[ -d $ZSH_CACHE_DIR ]] || mkdir -p $ZSH_CACHE_DIR
# initialize plugins statically with ${ZDOTDIR:-~}/.zsh_plugins.txt
antidote load
# Make 'less' friendlier for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# Konf
# source <(konf-go shellwrapper zsh)
# Autocompletion
# source <(konf completion zsh)
# Auto load context
# export KUBECONFIG=$(konf set -)
# Aliases
alias magit="nvim '+Neogit kind=replace'"
alias clipboard='xclip -sel clip'
alias dc="docker compose"
alias dcud="docker compose down && docker compose up -d"
alias kctx="konf set"
alias kns="konf ns"
# Keep History
export HISTFILE="$HOME/.zhistory"
export HISTSIZE=10000
export SAVEHIST=10000
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_IGNORE_DUPS
# Coloured GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# Use 'iHD' by default
export LIBVA_DRIVER_NAME="iHD"
# Color support of 'ls' and also add aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
fi
# Make directories & cd into them
function mkcd() {
mkdir -p $@ && cd ${@:$#}
}
# Use 'wezterm ssh' if available
function ssh() {
if [[ "$TERM_PROGRAM" == "WezTerm" ]]; then
bj wezterm ssh $@
else
echo "Falling back to normal 'ssh' as WezTerm hasn't been detected"
command ssh $@
fi
}
# Easily run background jobs
function bj() {
nohup $@ </dev/null &>/dev/null &
}
# Display images in the terminal
function icat() {
function display() {
if [[ "$TERM_PROGRAM" == "WezTerm" ]]; then
cat - | wezterm imgcat
elif [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
cat - | $(alias imgcat | cut -d "=" -f2-)
elif [[ "$TERM" = "xterm-kitty" ]]; then
cat - | kitty +kitten icat
else
echo "No image viewer defined for this terminal" && return 1
fi
return 0
}
function displaySVG() {
[[ ! -x "$(command -v convert)" ]] && echo "convert not found, install imagemagick" && return 1
convert -background none -density 192 - png:- | display
}
function displayVID() {
ffmpeg -i "$1" -vf scale=720:-1 -r 10 -f image2pipe -vcodec ppm - &>/dev/null | convert -delay 10 -loop 1 - gif:- | display
}
if [ ! -t 0 ]; then
input="$(cat - | base64)"
headers="$(echo "$input" | base64 -d | file - --mime-type | cut -d " " -f2-)"
case $headers in
*svg*) echo "$input" | base64 -d | displaySVG ;;
*video*) echo "haven't figured this part out yet" && return 1;;
*image*) echo "$input" | base64 -d | display ;;
*) echo "Unknown file type" && return 1 ;;
esac
elif [[ "$1" == http* ]]; then
case "$(curl -sSLI "$1" | grep -i "^content-type:")" in
*svg*) curl -fsSL "$1" | displaySVG ;;
*video*) echo "haven't figured this part out yet" && return 1;;
*image*) curl -fsSL "$1" | display ;;
*) echo "Unknown file type" && return 1 ;;
esac
else
[[ -z "$1" ]] && echo "Usage: icat <file|url>" && return 1
[[ ! -f "$1" ]] && echo "File not found: $1" && return 1
case "$(file -b --mime-type "$1")" in
*svg*) cat "$1" | displaySVG ;;
*video*) displayVID $1 ;;
*image*) cat "$1" | display ;;
*) echo "Unknown file type" && return 1 ;;
esac
fi
}
# export M2_HOME="$HOME/.local/bin/apache-maven-3.8.6/bin"
# export PATH="$PATH:$M2_HOME"
# Node
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
eval "$(direnv hook zsh)"
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"