dotfiles/.config/shell/functions.zsh

73 lines
2.1 KiB
Bash
Raw Normal View History

2025-06-15 09:35:27 -05:00
isSet() { [ ! -z "${1}" ]; }
isNotSet() { [ -z "${1}" ]; }
2025-03-12 05:36:58 -05:00
set-cred ()
2025-02-28 17:59:44 -06:00
{
export BW_SESSION="$(bw unlock $(secret-tool lookup drive bitwarden) --raw)"
2025-04-02 05:52:16 -05:00
bw sync
2025-03-12 05:36:58 -05:00
printf "$(bw get password cli-gitlab)" | secret-tool store --label='Gitlab Token for CLI' 'token' 'GITLAB_TOKEN'
printf "$(bw get password cli-ollama-token)" | secret-tool store --label='Ollama Token for CLI' 'token' 'OLLAMA_TOKEN'
2025-04-01 06:20:33 -05:00
printf "$(bw get password cli-litellm-token)" | secret-tool store --label='LiteLLM Token for CLI' 'token' 'LITELLM_TOKEN'
2025-04-05 07:00:35 -05:00
printf "$(bw get password cli-openai)" | secret-tool store --label='OpenAI Token for CLI' 'token' 'OPENAI_TOKEN'
2025-05-02 06:09:07 -05:00
printf "$(bw get password GEMINI_TOKEN)" | secret-tool store --label='Gemini Token for CLI' 'token' 'GEMINI_TOKEN'
2025-09-27 07:13:57 -05:00
printf "$(bw get password cli-anthropic)" | secret-tool store --label='Anthropic Token for CLI' 'token' 'ANTHROPIC_TOKEN'
2025-03-12 05:36:58 -05:00
unset BW_SESSION
2025-02-28 17:59:44 -06:00
}
2025-03-12 05:36:58 -05:00
set-env ()
{
export GITLAB_TOKEN="$(secret-tool lookup token GITLAB_TOKEN)"
export OLLAMA_TOKEN="$(secret-tool lookup token OLLAMA_TOKEN)"
2025-04-01 06:20:33 -05:00
export LITELLM_TOKEN="$(secret-tool lookup token LITELLM_TOKEN)"
2025-04-05 07:00:35 -05:00
export OPENAI_TOKEN="$(secret-tool lookup token OPENAI_TOKEN)"
2025-05-02 06:09:07 -05:00
export GEMINI_TOKEN="$(secret-tool lookup token GEMINI_TOKEN)"
2025-09-27 07:13:57 -05:00
export ANTHROPIC_TOKEN="$(secret-tool lookup token ANTHROPIC_TOKEN)"
2025-03-12 05:36:58 -05:00
}
clear-env ()
2025-02-28 17:59:44 -06:00
{
unset GITLAB_TOKEN
unset OLLAMA_TOKEN
2025-04-01 06:20:33 -05:00
unset LITELLM_TOKEN
2025-04-05 07:00:35 -05:00
unset OPENAI_TOKEN
2025-05-02 06:09:07 -05:00
unset GEMINI_TOKEN
2025-02-28 17:59:44 -06:00
}
tmux-new () {
2025-04-06 15:37:33 -05:00
~/.config/scripts/sessions.sh new $1
2025-02-28 17:59:44 -06:00
}
2025-04-13 09:03:39 -05:00
goland-new () {
~/.config/scripts/sessions.sh goland-new $1
}
2025-02-28 17:59:44 -06:00
load-profile () {
ansible-playbook /home/user/.dotfiles/ansible/.config/ansible/local.yml -K
}
2025-03-28 14:47:40 -05:00
decode_base64_url() {
local len=$((${#1} % 4))
local result="$1"
if [ $len -eq 2 ]; then result="$1"'=='
elif [ $len -eq 3 ]; then result="$1"'='
fi
echo "$result" | tr '_-' '/+' | openssl enc -d -base64
}
decode-jwtpayload(){
decode_base64_url $(echo -n $1 | cut -d "." -f '2') | jq .
}
decode-jwtheader(){
decode_base64_url $(echo -n $1 | cut -d "." -f '1') | jq .
}
2025-05-02 06:09:07 -05:00
nvim-new () {
~/.config/scripts/nvim.sh $1
}
2025-07-17 06:47:25 -05:00
ai () {
set-env
nvim +CodeCompanionChat -c only
}