From 8b49c1b8a584baf1620ef00679cc99309cfcf922 Mon Sep 17 00:00:00 2001 From: Luis Freixial <48995671+lfreixial@users.noreply.github.com> Date: Thu, 10 Jul 2025 21:53:23 +0100 Subject: [PATCH] update-zsh --- zsh/.zsh_alias | 12 ++++++++- zsh/.zsh_functions | 67 +++++++++++++++++++++++++++++++++++++++++++++- zsh/.zsh_mac | 8 +++--- zsh/.zshrc | 9 ++++++- 4 files changed, 90 insertions(+), 6 deletions(-) diff --git a/zsh/.zsh_alias b/zsh/.zsh_alias index 63ccee8..c22a252 100644 --- a/zsh/.zsh_alias +++ b/zsh/.zsh_alias @@ -13,4 +13,14 @@ alias dk=docker_kill_fzf alias zs='nvim ~/.zshrc' alias sz='source ~/.zshrc' alias ls="eza --color=always --long --git --no-filesize --icons=always --no-time --no-user --no-permissions" -alias gk="gitkraken" +alias ghb='gh browse' +alias ghs='gh status' +alias ghl='gh pr list' +alias ghw='gh pr view --web' +alias prs='select_and_open_pr' +alias pr='select_and_open_pr_web_only' +alias e='exit' +alias ta='tmux-attach' +alias tn='tmux-new' +alias tk='tmux-kill' +alias st='tmux source-file ~/.tmux.conf' diff --git a/zsh/.zsh_functions b/zsh/.zsh_functions index f673878..688dc2a 100644 --- a/zsh/.zsh_functions +++ b/zsh/.zsh_functions @@ -30,4 +30,69 @@ fzf-cd-widget() { local dir dir=$(find ${1:-.} -path '*/\.*' -prune -o -type d -print 2> /dev/null | fzf +m) && cd "$dir" zle reset-prompt -} \ No newline at end of file +} + +select_and_open_pr() { + local pr_info=$(gh pr list --state open --json number,title | jq -r '.[] | "\(.number) \(.title)"' | fzf -1) + + if [[ -n "$pr_info" ]]; then + local pr_number=$(echo "$pr_info" | awk '{print $1}') + gh pr checkout "$pr_number" + else + echo "No PR selected." + fi +} + +select_and_open_pr_web_only() { + local pr_info=$(gh pr list --state open --json number,title | jq -r '.[] | "\(.number) \(.title)"' | fzf -1) + + if [[ -n "$pr_info" ]]; then + local pr_number=$(echo "$pr_info" | awk '{print $1}') + gh pr view --web + else + echo "No PR selected." + fi +} + +tmux-attach() { + local session + session=$(tmux ls -F "#{session_name}" 2>/dev/null | fzf) + [[ -n "$session" ]] && tmux attach -t "$session" +} + +tmux-new() { + read "session?Enter new tmux session name: " + if [[ -z "$session" ]]; then + echo "No session name entered." + return 1 + fi + + if tmux has-session -t "$session" 2>/dev/null; then + echo "Session '$session' already exists." + return 1 + fi + + tmux new -s "$session" +} + +tmux-kill() { + local session + session=$(tmux ls -F "#{session_name}" 2>/dev/null | fzf --prompt="Kill session: ") + [[ -n "$session" ]] && tmux kill-session -t "$session" +} + + +tmux_start_music() { + local session="music" + + if ! tmux has-session -t "$session" 2>/dev/null; then + tmux new-session -d -s "$session" + + tmux send-keys -t "$session":1 'clear' C-m + tmux split-window -v -t "$session":1 -p 8 + tmux send-keys -t "$session":1.2 'spotify_player' C-m + tmux select-pane -t "$session":1.1 + fi + + tmux attach -t "$session" +} diff --git a/zsh/.zsh_mac b/zsh/.zsh_mac index 2e690c4..2fbf7ea 100644 --- a/zsh/.zsh_mac +++ b/zsh/.zsh_mac @@ -1,11 +1,13 @@ if [[ -f "/opt/homebrew/bin/brew" ]]; then eval "$(/opt/homebrew/bin/brew shellenv)" fi - + export PATH="/Library/Developer/CommandLineTools/usr/bin:$PATH" alias f='selected=$(find . -type f | fzf --preview "bat --style=numbers --color=always {}") && [ -n "$selected" ] && vim "$selected"' - + alias ghostty_config='v $HOME/Library/Application\ Support/com.mitchellh.ghostty/config' + alias cat='bat' export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin" - #source $(brew --prefix powerlevel10k)/powerlevel10k.zsh-theme + export PATH="$PATH:/Users/luisfreixial/.cargo/bin" + #source $(brew --prefix powerlevel10k)/powerlevel10k.zsh-theme export GOPATH=$HOME/go export GOROOT="$(brew --prefix golang)/libexec" alias python=/usr/bin/python3 diff --git a/zsh/.zshrc b/zsh/.zshrc index 3487e12..c4597f7 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -86,6 +86,11 @@ zle -N fzf-cd-widget source ~/.zsh_exports fi +# Secrets +if [ -f ~/.zsh_secrets ]; then + source ~/.zsh_secrets +fi + # OS-specific configurations if [[ "$OSTYPE" == "linux-gnu"* ]]; then if [ -f ~/.zsh_debian ]; then @@ -100,4 +105,6 @@ fi # Initialize other tools eval "$(zoxide init --cmd cd zsh)" eval "$(rbenv init -)" -eval "$(starship init zsh)" \ No newline at end of file +eval "$(starship init zsh)" +eval "$(gh copilot alias -- zsh)" +eval "$(/Users/luisfreixial/.local/bin/mise activate zsh)"