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-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-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-02-28 17:59:44 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tmux-new () {
|
2025-03-12 05:09:03 -05:00
|
|
|
local dir=${1:-}
|
2025-03-13 14:36:04 -05:00
|
|
|
|
2025-03-12 05:09:03 -05:00
|
|
|
[ -z "${dir}" ] && local dir=$(find $HOME/Documents/gitlab -mindepth 1 -maxdepth 1 -type d| awk -F/ '{print $(NF-1)"/"$NF " " $0}' | fzf --with-nth=1 | awk '{print $2}')
|
2025-03-07 06:14:50 -06:00
|
|
|
[ -z "$dir" ] && return 1
|
|
|
|
|
|
2025-03-13 14:36:04 -05:00
|
|
|
|
2025-03-07 06:14:50 -06:00
|
|
|
local name=$(basename "$dir")
|
2025-03-12 05:09:03 -05:00
|
|
|
|
|
|
|
|
if [[ $name == .* ]]; then
|
|
|
|
|
name=${name#.}
|
|
|
|
|
fi
|
|
|
|
|
|
2025-03-13 14:36:04 -05:00
|
|
|
tmux has-session -t ${name} > /dev/null && { tmux switch-client -t ${name}; return; }
|
2025-03-07 06:14:50 -06:00
|
|
|
tmux new-session -d -s "$name" -c "$dir"
|
|
|
|
|
|
|
|
|
|
RIGHT_PANE_WIDTH=60
|
|
|
|
|
BOTTOM_PANE_WIDTH=15
|
|
|
|
|
|
|
|
|
|
tmux split-window -h -t "$name:1" -c "$dir"
|
|
|
|
|
tmux resize-pane -t "$name:1.2" -x $RIGHT_PANE_WIDTH
|
|
|
|
|
|
|
|
|
|
tmux split-window -v -t "$name:1.1" -c "$dir"
|
|
|
|
|
tmux resize-pane -t "$name:1.1" -y $(($(tmux display -p '#{window_height}') - $BOTTOM_PANE_WIDTH))
|
|
|
|
|
|
|
|
|
|
tmux new-window "$name" -n lazygit -c "$dir"
|
|
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
|
tmux send-keys -t "$name:1.1" 'nvim -c "Neotree filesystem reveal left"' C-m
|
|
|
|
|
|
|
|
|
|
sleep 0.1
|
2025-03-12 05:36:58 -05:00
|
|
|
tmux send-keys -t "$name:1.3" 'set-env; nvim +CodeCompanionChat -c only' C-m
|
2025-03-07 06:14:50 -06:00
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
|
tmux send-keys -t "$name:2" 'lg' C-m
|
|
|
|
|
|
|
|
|
|
tmux select-window -t "$name:1"
|
|
|
|
|
tmux select-pane -t "$name:1.1"
|
2025-03-13 14:36:04 -05:00
|
|
|
|
2025-03-07 06:14:50 -06:00
|
|
|
tmux switch-client -t "$name"
|
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 .
|
|
|
|
|
}
|