# Zgodovina ukazov
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=10000

# Vi zadeve, se mi zdi
bindkey -v
export KEYTIMEOUT=1
zstyle :compinstall filename '/home/g1smo/.zshrc'

autoload -Uz compinit
compinit

# Barve
autoload colors zsh/terminfo
colors

# BARVE!
export GREP_COLORS='1;32'
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad

function man() {
  LESS_TERMCAP_mb=$(printf "\e[1;35m") \
  LESS_TERMCAP_md=$(printf "\e[1;34m") \
  LESS_TERMCAP_me=$(printf "\e[0m") \
  LESS_TERMCAP_se=$(printf "\e[0m") \
  LESS_TERMCAP_so=$(printf "\e[7;40m") \
  LESS_TERMCAP_ue=$(printf "\e[0m") \
  LESS_TERMCAP_us=$(printf "\e[1;33m") \
  command man "$@"
}
function perldoc() { command perldoc -n less "$@" |man -l -; }

# Prompt za git
autoload -U promptinit
promptinit
autoload -Uz vcs_info

zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' enable git svn hg
zstyle ':vcs_info:*' formats '(%b) '
precmd () {
	vcs_info
}

setopt prompt_subst
PROMPT='%n@%m %1~ %{$fg[green]%}${vcs_info_msg_0_}%{$fg[blue]%}» %{$reset_color%}'

# Reverse search shortcut
bindkey '^R' history-incremental-pattern-search-backward


# Splosno barvanje zadev
[[ -s "/etc/grc.zsh" ]] && source /etc/grc.zsh

# CCCAMP 2019 fahrplan
#camp() {
#  curl -s https://fahrplan.events.ccc.de/camp/2019/Fahrplan/schedule.json \
#    | jq -r '.schedule.conference.days | .[] | select(.date=="'$(date +%F)'") | .rooms | .[] | .[] | select(.date|strptime("%Y-%m-%dT%H:%M:%S%z") > now) | "\(.start) \(.duration)|\(.room)|\(.title)"' \
#    | sort -V | column -t -s'|'
#}

# Aliasi
alias ll='ls -l'
alias grep='grep --color=auto'
alias ls='ls --color -C'
alias vi='vim'
alias sudo='sudo env PATH=$PATH '
alias ag="rg"
alias less="less -R"

alias gitclean="git fetch -p && for branch in \$(git branch -vv | grep ': gone]' | gawk '{print \$1}'); do git branch -D \$branch; echo 'deleted \$branch'; done"
alias sctl="systemctl"
alias ddrush="ddev exec drush"
alias dcomposer="ddev exec composer"
alias offer-files="python3 -m http.server"

# X on wayland
alias wxon="xhost +local:"

# Ljudmila
alias scdev="ssh culture@milci.ljudmila.org"
alias scnew="ssh culture@zala.ljudmila.org"

# Dolzina mp3 fajlov
alias mp3len="for i in \$(ls *.mp3); do echo \$i; soxi -d \$i; done"

# Hiter ping za net preverit
alias pg="ping 1.1.1.1"

# Najvecji fajli
alias najvecji="find . -printf '%s %p\n'| sort -nr | head -30"

# RŠ ssh
alias srs='f(){ ssh jurijp@$1.radiostudent.local };f'
alias srr='f(){ ssh root@$1.radiostudent.local };f'
alias rss='f(){ ssh jurijp@$1.radiostudent.si };f'
alias rsr='f(){ ssh root@$1.radiostudent.si };f'
alias rs='ssh radiostudent.si'
alias rr='ssh root@radiostudent.si'

# Poslusaj snemanje
alias poslusaj='pactl load-module module-loopback latency_msec=1'
alias tisina='pactl unload-module module-loopback'

# PI ssh
alias spi='ssh pi@192.168.64.88'

# Na prostem sajt(i)
alias nps='cd ~/ljudmila/naprostem/sajt'
alias np='f(){ ssh root@$1.na-prostem.si };f'

# Kill element
alias kill-element='kill $(ps aux | grep element | awk '\''{print $2;}'\'')'
alias kill-zoom='pkill zoom'

alias nmc='nmcli con up '

# OBS fix
#alias obs="QT_QPA_PLATFORM=xcb obs"

# Build deb pkg
#alias deb-build="dpkg-buildpackage -us -uc"
alias deb-build="dpkg-buildpackage -b -rfakeroot -us -uc"

alias run-gamma="pkill -f gammastep; sleep 3; screen -dm -- gammastep -m wayland -l 46.05108:14.50513"

# Spanje / nespanje
alias insomnia="sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target"
alias pocivanje="sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target"
alias lowdelay="PIPEWIRE_LATENCY=128/48000 "

# zvok prek mreze!
alias pulse-listen="pactl load-module module-native-protocol-tcp port=4656 listen="
alias pulse-connect="pactl load-module module-tunnel-sink server=tcp:${PULSEIP}:4656"
alias pulse-virtual-sink="pactl load-module module-null-sink media.class=Audio/Source/Virtual sink_name=my-virtualmic channel_map=front-left,front-right"
alias sardon="source $HOME/mska/sardine/venv/bin/activate"
alias powersave="sudo cpupower frequency-set -g powersave"
alias powerfull="sudo cpupower frequency-set -g ondemand"
alias imgcrop1920="mogrify -resize 1920x1920 "

alias ustvari-drupal="composer create-project drupal/recommended-project "


# Za LXD!
if command -v go &> /dev/null; then
  export PATH="${PATH}:$(go env GOPATH)/bin:/sbin:/usr/sbin"
fi
#export LD_LIBRARY_PATH="$(go env GOPATH)/deps/dqlite/.libs/:$(go env GOPATH)/deps/raft/.libs/:${LD_LIBRARY_PATH}"

# ??? fix crashanja
#export LD_LIBRARY_PATH="/lib/x86_64-linux-gnu:/lib/i386-linux-gnu"

# JS fix (prevec nov za openssl)
#export NODE_OPTIONS="--openssl-legacy-provider"

# Terminal podpora
alias termfix="TERM=rxvt-256color "
#export TERM=rxvt-256color

export ANDROID_HOME="$HOME/Android/Sdk"
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools
