2023-08-27 11:43:02 +02:00
|
|
|
export ZSH="/home/mfocko/.oh-my-zsh"
|
|
|
|
|
|
|
|
ENABLE_CORRECTION=true
|
|
|
|
plugins=(git common-aliases history systemd sudo zsh-autosuggestions zsh-syntax-highlighting zsh-aliases-exa fzf direnv taskwarrior autojump)
|
|
|
|
source $ZSH/oh-my-zsh.sh
|
|
|
|
|
|
|
|
### add .local/bin to PATH ###
|
|
|
|
export GOPATH=$HOME/.go
|
|
|
|
export PATH=$HOME/.go/bin:$HOME/.npm/bin:$HOME/.emacs.d/bin:$HOME/.local/bin:$PATH
|
|
|
|
|
|
|
|
### zsh autosuggestions color ###
|
|
|
|
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=8,bold,underline"
|
|
|
|
|
|
|
|
### Ruby gems ###
|
|
|
|
if which ruby >/dev/null && which gem >/dev/null; then
|
|
|
|
PATH="$(ruby -r rubygems -e 'puts Gem.user_dir')/bin:$PATH"
|
|
|
|
fi
|
|
|
|
|
|
|
|
### NeoVim ###
|
|
|
|
export EDITOR=nvim
|
|
|
|
alias vim=nvim
|
|
|
|
|
|
|
|
alias alacrittyconf="$EDITOR ~/.config/alacritty/alacritty.yml"
|
|
|
|
alias kittyconf="$EDITOR ~/.config/kitty/kitty.conf"
|
|
|
|
|
|
|
|
### git aliases ###
|
|
|
|
export GIT_EDITOR=$EDITOR
|
|
|
|
alias gcs="git commit -v -s"
|
|
|
|
|
|
|
|
### 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
|
|
|
|
if [ -e /home/mfocko/.nix-profile/etc/profile.d/nix.sh ]; then
|
|
|
|
. /home/mfocko/.nix-profile/etc/profile.d/nix.sh;
|
|
|
|
fi # added by Nix installer
|
|
|
|
|
|
|
|
### Rust ###
|
|
|
|
# export RUSTUP_HOME=/opt/rustup
|
|
|
|
# export CARGO_HOME=/opt/cargo
|
|
|
|
# export PATH=/opt/cargo/bin:$PATH
|
|
|
|
export PATH=~/.cargo/bin:$PATH
|
|
|
|
# [[ -s "/opt/cargo/env" ]] && source /opt/cargo/env
|
|
|
|
|
|
|
|
### Go ###
|
|
|
|
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() {
|
|
|
|
local VAULT=$(readlink ~/.config/Bitwarden\ CLI/data.json | cut -d'/' -f6 | cut -d'.' -f-3)
|
|
|
|
local PASS=$(yad --text "Master password for Bitwarden Vault @ $VAULT:" --center --button "yad-ok" --entry --hide-text)
|
|
|
|
export BW_SESSION=$(bw unlock --raw "$PASS")
|
|
|
|
}
|
|
|
|
|
|
|
|
# alias bwu='export BW_SESSION="$(bw unlock --raw)"'
|
|
|
|
alias bwl='export BW_SESSION='
|
|
|
|
|
|
|
|
alias bwrh='ln -sf $HOME/.config/Bitwarden\ CLI/{vault.bitwarden.com,data}.json'
|
|
|
|
alias bwvps='ln -sf $HOME/.config/Bitwarden\ CLI/{vault.mfocko.xyz,data}.json'
|
|
|
|
|
|
|
|
function gen_pass() {
|
|
|
|
LENGTH=12
|
|
|
|
if [[ -n $1 ]]; then
|
2023-09-06 11:42:26 +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
|
2023-09-06 11:42:26 +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 ###
|
2023-08-27 11:43:02 +02:00
|
|
|
export VAULT_ADDR="https://hvault.mfocko.xyz"
|
|
|
|
function hcvu() {
|
|
|
|
local PASS=$(yad --text "Password for HashiCorp Vault @ mfocko.xyz:" --center --button "yad-ok" --entry --hide-text)
|
|
|
|
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 ###
|
|
|
|
alias rh_vpn='echo "$(bw get password Red\ Hat\ -\ SSO)$(bw get totp Red\ Hat\ -\ SSO)" | nmcli --ask connection up Brno\ \(BRQ\)'
|
|
|
|
alias rh_vpn_rdu2='echo "$(bw get password Red\ Hat\ -\ SSO)$(bw get totp Red\ Hat\ -\ SSO)" | nmcli --ask connection up Raleigh\ \(RDU2\)'
|
|
|
|
alias rh_wifi='echo -e "\n$(bw get password Red\ Hat\ -\ SSO)$(bw get totp Red\ Hat\ -\ SSO)" | nmcli --ask connection up Red\ Hat'
|
|
|
|
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"
|
|
|
|
|
|
|
|
### 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;
|
|
|
|
|
|
|
|
### sprunge ###
|
|
|
|
function sprunge_paste() {
|
|
|
|
echo "Paste your code: "
|
|
|
|
cat - | curl -F 'sprunge=<-' http://sprunge.us
|
|
|
|
}
|
|
|
|
|
|
|
|
### Starship ###
|
|
|
|
eval "$(starship init zsh)"
|