refactor: Update zsh configuration and plugins
This commit restructures the zsh configuration by: • Introducing Antidote for plugin management via .zsh_plugins.txt. • Setting up the pure prompt theme. • Adding FZF options for a TokyoNight theme. • Removing deprecated/unnecessary shell scripts (aws.sh, kubectl.sh, toolbox.sh, utilities.sh). • Adding a gmsg function for AI-assisted commit message generation. • Updating aliases for better workflow (e.g., fl, lt).
This commit is contained in:
4
zsh/.gitignore
vendored
Normal file
4
zsh/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
completion/
|
||||
histfile
|
||||
.antidote
|
||||
.zsh_plugins.zsh
|
||||
28
zsh/.zsh_plugins.txt
Normal file
28
zsh/.zsh_plugins.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
# OMZ Support
|
||||
getantidote/use-omz
|
||||
ohmyzsh/ohmyzsh path:lib
|
||||
|
||||
# Core Plugins
|
||||
zsh-users/zsh-completions path:src kind:fpath
|
||||
zsh-users/zsh-autosuggestions
|
||||
zdharma-continuum/fast-syntax-highlighting
|
||||
|
||||
# OMZ Plugins
|
||||
ohmyzsh/ohmyzsh path:plugins/fancy-ctrl-z
|
||||
ohmyzsh/ohmyzsh path:plugins/aws
|
||||
|
||||
# Completions
|
||||
mattmc3/ez-compinit
|
||||
zsh-users/zsh-history-substring-search
|
||||
belak/zsh-utils path:completion/functions kind:autoload post:compstyle_zshzoo_setup
|
||||
|
||||
# Prompt
|
||||
sindresorhus/pure kind:fpath
|
||||
|
||||
# History
|
||||
belak/zsh-utils path:history
|
||||
|
||||
# Utilities
|
||||
belak/zsh-utils path:utility
|
||||
MichaelAquilina/zsh-you-should-use
|
||||
ohmyzsh/ohmyzsh path:plugins/zoxide
|
||||
45
zsh/.zshrc
Normal file
45
zsh/.zshrc
Normal file
@@ -0,0 +1,45 @@
|
||||
HISTFILE=$ZDOTDIR/histfile
|
||||
|
||||
source $ZDOTDIR/.antidote/antidote.zsh
|
||||
antidote load
|
||||
|
||||
autoload -Uz promptinit
|
||||
promptinit
|
||||
|
||||
zstyle :prompt:pure:path color '#eeeeee'
|
||||
zstyle :prompt:pure:git:branch color '#ffe599'
|
||||
zstyle :prompt:pure:prompt:success color '#8fce00'
|
||||
zstyle :prompt:pure:prompt:error color '#f44336'
|
||||
prompt pure
|
||||
|
||||
source $ZDOTDIR/tokyonight_night.zsh
|
||||
source $ZDOTDIR/aliases.zsh
|
||||
source $ZDOTDIR/functions.sh
|
||||
|
||||
# go setup
|
||||
export PATH=$PATH:/usr/local/go/bin
|
||||
|
||||
# python setup
|
||||
export PATH=$PATH:/home/brenozd/.local/bin
|
||||
|
||||
#pulumi setup
|
||||
export PATH=$PATH:/home/brenozd/.pulumi/bin
|
||||
|
||||
# pyenv setup
|
||||
PYENV_ROOT="$HOME/.pyenv"
|
||||
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
|
||||
eval "$(pyenv init - zsh)"
|
||||
|
||||
#pipx completions
|
||||
eval "$(register-python-argcomplete pipx)"
|
||||
|
||||
# FZF Setup
|
||||
source <(fzf --zsh)
|
||||
|
||||
# zoxide completions
|
||||
eval "$(zoxide init zsh --cmd cd)"
|
||||
|
||||
source ~/.profile
|
||||
|
||||
# add Pulumi to the PATH
|
||||
export PATH=$PATH:/home/brenozd/.pulumi/bin
|
||||
@@ -1,16 +1,18 @@
|
||||
#!/bin/sh
|
||||
#!/bin/zsh
|
||||
|
||||
alias findfiles="fd --type file --type symlink --strip-cwd-prefix | fzf --ansi --prompt=' ' --header=' Find file' --preview='bat --style header,grid,numbers --color always {}'"
|
||||
alias findtext="rg --smart-case --field-match-separator ' ' --line-number --with-filename --no-heading --color=always . | fzf -d ' ' -n 2.. --ansi --prompt=' ' --header=' Find Text' --preview 'bat --color=always {1} --highlight-line {2}' --preview-window ~8,+{2}-5"
|
||||
alias ff=findfiles
|
||||
alias ft=findtext
|
||||
alias fl="fzf --tac --wrap --exact --highlight-line --multi --no-sort --marker '═' --marker-multi-line '╔║╚' --marker ' '"
|
||||
alias cd="z"
|
||||
alias ls="eza --icons auto"
|
||||
alias ll="eza -lah --icons auto"
|
||||
alias lt="eza -lah --icons auto --tree --no-git --total-size"
|
||||
alias cat="bat"
|
||||
alias tree="eza -Tah --icons auto"
|
||||
alias vim="nvim"
|
||||
alias man="batman"
|
||||
alias clc="clipcopy"
|
||||
alias clp="clippaste"
|
||||
|
||||
alias ca="code-assistant"
|
||||
alias man="batman"
|
||||
20
zsh/aws.sh
20
zsh/aws.sh
@@ -1,20 +0,0 @@
|
||||
#!/bin/sh
|
||||
function assume-role() {
|
||||
OUT=$(aws sts assume-role --role-arn $1 --role-session-name $2)
|
||||
if [ "$?" -ne 0 ]; then
|
||||
return 1
|
||||
fi
|
||||
export AWS_ACCESS_KEY_ID=$(echo $OUT | jq -r '.Credentials''.AccessKeyId')
|
||||
export AWS_SECRET_ACCESS_KEY=$(echo $OUT | jq -r '.Credentials''.SecretAccessKey')
|
||||
export AWS_SESSION_TOKEN=$(echo $OUT | jq -r '.Credentials''.SessionToken')
|
||||
export AWS_DEFAULT_REGION=$2;
|
||||
return 0
|
||||
}
|
||||
|
||||
function resign-role() {
|
||||
unset AWS_ACCESS_KEY_ID
|
||||
unset AWS_SECRET_ACCESS_KEY
|
||||
unset AWS_SESSION_TOKEN
|
||||
unset AWS_DEFAULT_REGION
|
||||
}
|
||||
|
||||
55
zsh/functions.sh
Normal file
55
zsh/functions.sh
Normal file
@@ -0,0 +1,55 @@
|
||||
_gmsg_generate() {
|
||||
local diff_input="$1"
|
||||
local prompt="Analyze the following git diff and generate a concise git commit message in Conventional Commits style.
|
||||
Rules:
|
||||
- Use type: short description (max 50 chars). Types: feat, fix, refactor, docs, chore.
|
||||
- Optionally include a body (max 72 chars per line) explaining:
|
||||
- What was changed
|
||||
- Why it was changed
|
||||
- Any side effects or notes
|
||||
- Use present tense and imperative mood.
|
||||
- Focus only on actual code changes; do not guess intentions beyond the diff.
|
||||
|
||||
Example output:
|
||||
feat: add JWT token refresh
|
||||
* Added refresh endpoint
|
||||
* Updated token validation"
|
||||
|
||||
echo "$diff_input" | sgpt "$prompt"
|
||||
}
|
||||
|
||||
gmsg() {
|
||||
local diff_output=""
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
# Original behavior: staged diff
|
||||
diff_output="$(git diff --cached)"
|
||||
elif [[ $# -eq 1 ]]; then
|
||||
# Compare current HEAD to the provided branch
|
||||
diff_output="$(git diff $1 HEAD)"
|
||||
elif [[ $# -eq 2 ]]; then
|
||||
# Compare two arbitrary branches
|
||||
diff_output="$(git diff $1 $2)"
|
||||
else
|
||||
echo "Usage: gmsg [branch] | [branchA branchB]"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ -z "$diff_output" ]]; then
|
||||
echo "No diff detected. Nothing to commit or compare."
|
||||
return 1
|
||||
fi
|
||||
|
||||
local commit_message
|
||||
commit_message="$(_gmsg_generate "$diff_output")"
|
||||
|
||||
printf "\nGenerated commit message:\n%s\n\n" "$commit_message"
|
||||
printf "Use this commit message? [y/N] "
|
||||
read -r response
|
||||
|
||||
if [[ $response =~ ^[Yy]$ ]]; then
|
||||
git commit -F <(echo "$commit_message")
|
||||
else
|
||||
echo "Commit cancelled."
|
||||
fi
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
klogs() {
|
||||
# Definir um manipulador de sinal para SIGINT
|
||||
trap 'echo "Interrompido. Parando todos os logs..."; kill $(jobs -pr); exit' SIGINT
|
||||
|
||||
# Obter todos os pods em todos os namespaces
|
||||
pods=$(kubectl get pods --all-namespaces -o jsonpath='{range .items[*]}{.metadata.namespace}{" "}{.metadata.name}{"\n"}{end}')
|
||||
|
||||
# Usar fzf para selecionar múltiplos pods com preview dos logs
|
||||
selected_pods=$(echo "$pods" | fzf --multi --preview 'kubectl logs --namespace $(echo {} | cut -d" " -f1) $(echo {} | cut -d" " -f2) -n 20')
|
||||
|
||||
# Verificar se algum pod foi selecionado
|
||||
if [ -n "$selected_pods" ]; then
|
||||
# Para cada pod selecionado, exibir os logs em paralelo
|
||||
echo "$selected_pods" | while read -r line; do
|
||||
namespace=$(echo "$line" | cut -d' ' -f1)
|
||||
pod=$(echo "$line" | cut -d' ' -f2)
|
||||
|
||||
# Exibir os logs em paralelo
|
||||
kubectl logs --namespace "$namespace" "$pod" -f &
|
||||
done
|
||||
# Aguardar todos os comandos de logs
|
||||
wait
|
||||
else
|
||||
echo "Nenhum pod selecionado."
|
||||
fi
|
||||
}
|
||||
25
zsh/tokyonight_night.zsh
Normal file
25
zsh/tokyonight_night.zsh
Normal file
@@ -0,0 +1,25 @@
|
||||
export FZF_DEFAULT_OPTS="--highlight-line \
|
||||
--info=inline-right \
|
||||
--ansi \
|
||||
--layout=reverse \
|
||||
--border=none \
|
||||
--color=bg+:#283457 \
|
||||
--color=bg:#16161e \
|
||||
--color=border:#27a1b9 \
|
||||
--color=fg:#c0caf5 \
|
||||
--color=gutter:#16161e \
|
||||
--color=header:#ff9e64 \
|
||||
--color=hl+:#2ac3de \
|
||||
--color=hl:#2ac3de \
|
||||
--color=info:#545c7e \
|
||||
--color=marker:#ff007c \
|
||||
--color=pointer:#ff007c \
|
||||
--color=prompt:#2ac3de \
|
||||
--color=query:#c0caf5:regular \
|
||||
--color=scrollbar:#27a1b9 \
|
||||
--color=separator:#ff9e64 \
|
||||
--color=spinner:#ff007c \
|
||||
--prompt=' ' \
|
||||
--pointer='' \
|
||||
--marker=' ' \
|
||||
--track --gap 1"
|
||||
@@ -1,79 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. "$HOME/.config/zsh/utilities.sh"
|
||||
|
||||
TOOLBOXES_DIR="$HOME/.toolboxes"
|
||||
|
||||
_get_container_id() {
|
||||
_ret_var=${1:-"CONTAINER_ID"}
|
||||
_container_id=$(grep '^id=' /run/.containerenv | sed -e 's/^id="\(.*\)"$/\1/')
|
||||
eval "$_ret_var='$_container_id'"
|
||||
}
|
||||
|
||||
_get_container_name() {
|
||||
_ret_var=${1:-"CONTAINER_NAME"}
|
||||
_container_name=$(grep '^name=' /run/.containerenv | sed -e 's/^name="\(.*\)"$/\1/')
|
||||
eval "$_ret_var='$_container_name'"
|
||||
}
|
||||
|
||||
_setup_toolbox_sysroot() {
|
||||
mkdir -p "$_env_location"/bin
|
||||
mkdir -p "$_env_location"/lib
|
||||
|
||||
# Setup podman to use host engine
|
||||
ln -sf "$(which podman-remote)" "$_env_location"/bin/podman
|
||||
ln -sf "$(which podman-remote)" "$_env_location"/bin/docker
|
||||
|
||||
# Setup python venv
|
||||
virtualenv "$SYSROOT"
|
||||
|
||||
}
|
||||
|
||||
_toolbox_entrypoint() {
|
||||
_get_container_id "CONTAINER_ID"
|
||||
_get_container_name "CONTAINER_NAME"
|
||||
|
||||
_env_location="$TOOLBOXES_DIR/$CONTAINER_NAME"
|
||||
|
||||
# Setup environment variables to use container env
|
||||
SYSROOT="$_env_location"
|
||||
BIN="$_env_location/bin"
|
||||
LIB="$_env_location/lib"
|
||||
|
||||
if [ ! -d "$_env_location" ]; then
|
||||
_setup_toolbox_sysroot
|
||||
fi
|
||||
|
||||
podman-remote system connection add "$USER" unix:///run/user/"$(id -u)"/podman/podman.sock
|
||||
|
||||
# Activating venv
|
||||
# Do not need to manually add path, virtualenv does it for us
|
||||
# _path_add "$BIN"
|
||||
_library_path_add "$LIB"
|
||||
. "$SYSROOT/bin/activate"
|
||||
|
||||
# Setup GOPATH
|
||||
export GOPATH="$SYSROOT"
|
||||
}
|
||||
|
||||
_toolbox_exitpoint() {
|
||||
[ -n "${SYSROOT+x}" ] && unset ROOT
|
||||
[ -n "${BIN+x}" ] && unset BIN
|
||||
[ -n "${LIB+x}" ] && unset LIB
|
||||
}
|
||||
|
||||
change_python_version() {
|
||||
_version=${1:?"change_python_version requires a version"}
|
||||
|
||||
# Check if the desired Python version is installed
|
||||
if ! rpm -q "python$_version" &>/dev/null; then
|
||||
# Install the requested Python version if not installed
|
||||
echo "Python $_version not found. Installing..."
|
||||
sudo dnf install -y "python$_version" "python$_version-devel"
|
||||
else
|
||||
echo "Python $_version is already installed."
|
||||
fi
|
||||
|
||||
# Create the virtual environment with the specified Python version
|
||||
virtualenv --clear --python "$(which "python$_version")" "$SYSROOT"
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
_path_add() {
|
||||
case ":${PATH:=$1}:" in
|
||||
*:"$1":*)
|
||||
;;
|
||||
*)
|
||||
PATH="$1:$PATH"
|
||||
;;
|
||||
esac;
|
||||
}
|
||||
|
||||
_library_path_add() {
|
||||
case ":${LD_LIBRARY_PATH:=$1}:" in
|
||||
*:"$1":*)
|
||||
;;
|
||||
*)
|
||||
LD_LIBRARY_PATH="$1:$LD_LIBRARY_PATH"
|
||||
;;
|
||||
esac;
|
||||
}
|
||||
|
||||
_path_remove() {
|
||||
path_to_remove=$1
|
||||
new_path=""
|
||||
|
||||
# Convert PATH to a list by splitting on colon
|
||||
old_ifs=$IFS
|
||||
IFS=":"
|
||||
for path in $PATH; do
|
||||
# Append path to new_path if it does not match path_to_remove
|
||||
if [ "$path" != "$path_to_remove" ]; then
|
||||
if [ -n "$new_path" ]; then
|
||||
new_path="$new_path:$path"
|
||||
else
|
||||
new_path="$path"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
IFS=$old_ifs
|
||||
|
||||
# Update PATH
|
||||
PATH="$new_path"
|
||||
}
|
||||
|
||||
_library_path_remove() {
|
||||
path_to_remove=$1
|
||||
new_path=""
|
||||
|
||||
# Convert LD_LIBRARY_PATH to a list by splitting on colon
|
||||
old_ifs=$IFS
|
||||
IFS=":"
|
||||
for path in $LD_LIBRARY_PATH; do
|
||||
# Append path to new_path if it does not match path_to_remove
|
||||
if [ "$path" != "$path_to_remove" ]; then
|
||||
if [ -n "$new_path" ]; then
|
||||
new_path="$new_path:$path"
|
||||
else
|
||||
new_path="$path"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
IFS=$old_ifs
|
||||
|
||||
# Update PATH
|
||||
LD_LIBRARY_PATH="$new_path"
|
||||
}
|
||||
|
||||
open() {
|
||||
_path=${1:-$PWD}
|
||||
xdg-open "$_path"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user