2024-07-01 13:14:12 +02:00
|
|
|
|
export ZSH="/home/{{ target_user }}/.oh-my-zsh"
|
2023-08-27 11:43:02 +02:00
|
|
|
|
|
|
|
|
|
ENABLE_CORRECTION=true
|
2024-05-07 13:46:15 +02:00
|
|
|
|
plugins=(git common-aliases history systemd sudo zsh-autosuggestions zsh-syntax-highlighting eza fzf direnv taskwarrior zoxide)
|
2023-08-27 11:43:02 +02:00
|
|
|
|
source $ZSH/oh-my-zsh.sh
|
|
|
|
|
|
|
|
|
|
### add .local/bin to PATH ###
|
2024-07-01 13:17:03 +02:00
|
|
|
|
export PATH=$HOME/.local/bin:$PATH
|
2023-08-27 11:43:02 +02:00
|
|
|
|
|
|
|
|
|
### zsh autosuggestions color ###
|
2024-07-01 13:18:05 +02:00
|
|
|
|
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=8,underline"
|
|
|
|
|
|
|
|
|
|
# Solarized theme
|
|
|
|
|
# ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=10,underline"
|
2023-08-27 11:43:02 +02:00
|
|
|
|
|
|
|
|
|
### Ruby gems ###
|
|
|
|
|
if which ruby >/dev/null && which gem >/dev/null; then
|
|
|
|
|
PATH="$(ruby -r rubygems -e 'puts Gem.user_dir')/bin:$PATH"
|
|
|
|
|
fi
|
|
|
|
|
|
2024-11-28 09:39:13 +01:00
|
|
|
|
### editor ###
|
|
|
|
|
export EDITOR=hx
|
2024-07-01 13:18:39 +02:00
|
|
|
|
alias vim="nvim -p"
|
2023-08-27 11:43:02 +02:00
|
|
|
|
|
|
|
|
|
alias alacrittyconf="$EDITOR ~/.config/alacritty/alacritty.yml"
|
|
|
|
|
alias kittyconf="$EDITOR ~/.config/kitty/kitty.conf"
|
|
|
|
|
|
|
|
|
|
### git aliases ###
|
|
|
|
|
export GIT_EDITOR=$EDITOR
|
2024-05-07 13:46:15 +02:00
|
|
|
|
alias gcs="git commit --gpg-sign --signoff --verbose"
|
|
|
|
|
alias gcsp="git commit --gpg-sign --signoff --verbose --patch"
|
2023-08-27 11:43:02 +02:00
|
|
|
|
|
|
|
|
|
### tokens ###
|
|
|
|
|
source ~/.tokens
|
|
|
|
|
|
|
|
|
|
### gpg as ssh key ###
|
|
|
|
|
function gpg_for_ssh() {
|
|
|
|
|
export GPG_TTY=$(tty)
|
|
|
|
|
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
|
|
|
|
|
gpgconf --launch gpg-agent
|
|
|
|
|
}
|
|
|
|
|
gpg_for_ssh
|
|
|
|
|
|
|
|
|
|
### direnv & nixpkg ###
|
|
|
|
|
if [[ $(command -v direnv 2> /dev/null) ]]; then
|
|
|
|
|
eval "$(direnv hook zsh)";
|
|
|
|
|
fi
|
2024-07-01 13:14:12 +02:00
|
|
|
|
if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then
|
|
|
|
|
. $HOME/.nix-profile/etc/profile.d/nix.sh;
|
2023-08-27 11:43:02 +02:00
|
|
|
|
fi # added by Nix installer
|
|
|
|
|
|
|
|
|
|
### Rust ###
|
|
|
|
|
# export RUSTUP_HOME=/opt/rustup
|
|
|
|
|
# export CARGO_HOME=/opt/cargo
|
|
|
|
|
# export PATH=/opt/cargo/bin:$PATH
|
2024-11-28 09:39:43 +01:00
|
|
|
|
|
|
|
|
|
# For user-space installation
|
|
|
|
|
# export PATH=~/.cargo/bin:$PATH
|
|
|
|
|
|
|
|
|
|
# For ‹/opt› installation
|
|
|
|
|
# export PATH=/opt/cargo/bin:$PATH
|
2023-08-27 11:43:02 +02:00
|
|
|
|
# [[ -s "/opt/cargo/env" ]] && source /opt/cargo/env
|
|
|
|
|
|
|
|
|
|
### Go ###
|
2024-05-07 13:46:15 +02:00
|
|
|
|
export GOPATH=$HOME/.go
|
2023-08-27 11:43:02 +02:00
|
|
|
|
export PATH="$HOME/.go/bin:$PATH"
|
|
|
|
|
|
|
|
|
|
### SDKMan ###
|
|
|
|
|
export SDKMAN_DIR="/opt/sdkman"
|
|
|
|
|
[[ -s "/opt/sdkman/bin/sdkman-init.sh" ]] && source "/opt/sdkman/bin/sdkman-init.sh"
|
|
|
|
|
|
|
|
|
|
### Bitwarden ###
|
|
|
|
|
eval "$(bw completion --shell zsh); compdef _bw bw;"
|
|
|
|
|
|
|
|
|
|
function bwu() {
|
2024-05-07 13:34:27 +02:00
|
|
|
|
local VAULT=$(basename $BITWARDENCLI_APPDATA_DIR)
|
2024-07-07 17:46:23 +02:00
|
|
|
|
local PASS=$(kdialog --password "Master password for Bitwarden Vault @ $VAULT")
|
2023-08-27 11:43:02 +02:00
|
|
|
|
export BW_SESSION=$(bw unlock --raw "$PASS")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
alias bwl='export BW_SESSION='
|
|
|
|
|
|
2024-07-12 14:56:34 +02:00
|
|
|
|
function bwpublic() {
|
2024-05-07 13:34:27 +02:00
|
|
|
|
export BITWARDENCLI_APPDATA_DIR="$HOME/.config/Bitwarden CLI/vault.bitwarden.com"
|
|
|
|
|
}
|
|
|
|
|
function bwvps() {
|
2024-07-12 14:56:34 +02:00
|
|
|
|
export BITWARDENCLI_APPDATA_DIR="$HOME/.config/Bitwarden CLI/{{ vaultwarden_address }}"
|
2024-05-07 13:34:27 +02:00
|
|
|
|
}
|
|
|
|
|
bwvps
|
2023-08-27 11:43:02 +02:00
|
|
|
|
|
|
|
|
|
function gen_pass() {
|
|
|
|
|
LENGTH=12
|
|
|
|
|
if [[ -n $1 ]]; then
|
2024-05-07 13:34:27 +02:00
|
|
|
|
LENGTH=$1
|
2023-08-27 11:43:02 +02:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
bw generate -uln --length $LENGTH
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function gen_passphrase() {
|
|
|
|
|
LENGTH=2
|
|
|
|
|
if [[ -n $1 ]]; then
|
2024-05-07 13:34:27 +02:00
|
|
|
|
LENGTH=$1
|
2023-08-27 11:43:02 +02:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
bw generate -p --words $LENGTH
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-06 11:42:26 +02:00
|
|
|
|
### HashiCorp Vault ###
|
2024-07-12 14:56:34 +02:00
|
|
|
|
export VAULT_ADDR="https://{{ hashicorp_vault_address }}"
|
2023-08-27 11:43:02 +02:00
|
|
|
|
function hcvu() {
|
2024-07-12 14:56:34 +02:00
|
|
|
|
local PASS=$(kdialog --password "Password for HashiCorp Vault @ {{ hashicorp_vault_address }}")
|
2023-08-27 11:43:02 +02:00
|
|
|
|
vault login -method=userpass -no-print username=$(whoami) password=$PASS
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-06 11:42:26 +02:00
|
|
|
|
# SSH variables for HashiCorp Vault
|
|
|
|
|
export VSSH_ROLE=$(whoami)
|
|
|
|
|
export VSSH_PRINCIPALS="$(whoami),me@mfocko.xyz"
|
|
|
|
|
|
2023-08-27 11:43:02 +02:00
|
|
|
|
### public_html ###
|
|
|
|
|
function from_phrase() {
|
|
|
|
|
bw list items --search $2 | jq --raw-output ".[] | select(.folderId == \"$1\") | .fields[] | select(.value == \"$3\") | .name"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function to_phrase() {
|
|
|
|
|
bw list items --search $2 | jq --raw-output ".[] | select(.folderId == \"$1\") | .fields[] | select(.name == \"$3\") | .value"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_link() {
|
|
|
|
|
FOLDER=$(bw list folders --search public_html | jq --raw-output ".[0].id")
|
|
|
|
|
if [[ "$1" == "aisa" ]]; then
|
|
|
|
|
PREFIX="https://fi.muni.cz/~xfocko";
|
|
|
|
|
elif [[ "$1" == "poincare" ]]; then
|
|
|
|
|
PREFIX="https://me.mfocko.xyz";
|
|
|
|
|
fi;
|
|
|
|
|
|
|
|
|
|
echo $PREFIX/$(to_phrase $FOLDER $1 $2)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ls_links() {
|
|
|
|
|
FOLDER=$(bw list folders --search public_html | jq --raw-output ".[0].id")
|
|
|
|
|
bw list items --search $1 | jq ".[] | select(.folderId == \"$FOLDER\") | .fields[].name"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
### Red Hat ###
|
2024-11-28 09:40:01 +01:00
|
|
|
|
function _rh_pass() {
|
|
|
|
|
local PIN=$(bw get password "Red Hat - SSO")
|
|
|
|
|
local TOKEN=$(kdialog --password 'Token for Red Hat - SSO')
|
|
|
|
|
echo "$PIN$TOKEN"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export RH_VPN_ENDPOINT="Brno (BRQ)"
|
|
|
|
|
function rh_vpn() {
|
|
|
|
|
PASS=$(_rh_pass)
|
|
|
|
|
echo $PASS | nmcli --ask connection up "$RH_VPN_ENDPOINT"
|
|
|
|
|
}
|
|
|
|
|
function rh_vpn_rdu2() {
|
|
|
|
|
RH_VPN_ENDPOINT="Raleigh (RDU2)" rh_vpn
|
|
|
|
|
}
|
2023-08-27 11:43:02 +02:00
|
|
|
|
alias rh_ticket='echo "$(bw get password Red\ Hat\ -\ Kerberos)" | kinit mfocko@REDHAT.COM'
|
|
|
|
|
|
|
|
|
|
### Fedora ###
|
|
|
|
|
alias fk='echo "$(bw get password Fedora\ Accounts)$(bw get totp Fedora\ Accounts)" | fkinit'
|
|
|
|
|
|
|
|
|
|
### FI ###
|
|
|
|
|
alias fi_vpn='echo "$(bw get password Faculty\ Pass)" | nmcli --ask connection up VPN\ FI\ MU'
|
|
|
|
|
|
|
|
|
|
### C(XX)FLAGS ###
|
|
|
|
|
# export CC=gcc
|
|
|
|
|
# export CFLAGS="-std=c11 -Wall -Werror"
|
|
|
|
|
# export CXXFLAGS="-std=c++14 -Wall -Werror"
|
|
|
|
|
# export LDLIBS="-lm -lkarel -lcurses"
|
|
|
|
|
# export LDLIBS="-lm"
|
|
|
|
|
|
|
|
|
|
export LANG=en_US.UTF-8
|
|
|
|
|
|
|
|
|
|
### Lazy aliases ###
|
|
|
|
|
alias q="exit"
|
|
|
|
|
alias k="exit"
|
|
|
|
|
alias ts="tmux new -As default"
|
|
|
|
|
alias Reset="reset && tmux clear-history"
|
2024-07-01 13:18:39 +02:00
|
|
|
|
alias ff=fastfetch
|
2023-08-27 11:43:02 +02:00
|
|
|
|
|
|
|
|
|
### Java ###
|
|
|
|
|
export PATH="/opt/jdk-18/bin:$PATH"
|
|
|
|
|
|
|
|
|
|
### fzf ###
|
|
|
|
|
# source $HOME/.oh-my-zsh/custom/plugins/fzf-tab-completion/zsh/fzf-zsh-completion.sh
|
|
|
|
|
# bindkey '^I' fzf_completion
|
|
|
|
|
|
|
|
|
|
# if [[ "$TMUX" == "" && "$VSCODE_SHELL_INTEGRATION" == "" ]]; then
|
|
|
|
|
# tmux new -s
|
|
|
|
|
# fi;
|
|
|
|
|
|
2024-05-07 13:46:15 +02:00
|
|
|
|
### Bat ###
|
|
|
|
|
export BAT_THEME=Dracula
|
|
|
|
|
|
2023-08-27 11:43:02 +02:00
|
|
|
|
### sprunge ###
|
|
|
|
|
function sprunge_paste() {
|
|
|
|
|
echo "Paste your code: "
|
|
|
|
|
cat - | curl -F 'sprunge=<-' http://sprunge.us
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-28 09:41:18 +01:00
|
|
|
|
### Zig ###
|
|
|
|
|
export PATH="$HOME/.zig:$PATH"
|
|
|
|
|
|
2024-05-07 13:46:15 +02:00
|
|
|
|
### rg wrapper with delta ###
|
|
|
|
|
function rgd() {
|
|
|
|
|
rg -C2 --json $@ | delta
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-27 11:43:02 +02:00
|
|
|
|
### Starship ###
|
|
|
|
|
eval "$(starship init zsh)"
|