summaryrefslogtreecommitdiff
path: root/.config
diff options
context:
space:
mode:
authorJacob McDonnell <jacob@jacobmcdonnell.com>2026-02-20 21:29:45 -0500
committerJacob McDonnell <jacob@jacobmcdonnell.com>2026-02-20 21:29:45 -0500
commit4f0ce1701ad4419745a56131f254efa77c526f1e (patch)
treefcfefd0d8b5268be3e33da160c2054deeb31a241 /.config
parentc1bf6040ccafe23af438fcf98815edd120539efb (diff)
feat(zsh): Print remote repo and branch
When a git repository the remote repo name and branch name will be included in the zsh prompt as repo::branch.
Diffstat (limited to '.config')
-rw-r--r--.config/nvim/lua/plugins/lsp.lua2
-rw-r--r--.config/shells/zsh/.zshrc19
2 files changed, 19 insertions, 2 deletions
diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua
index 84d4aec..fe571e3 100644
--- a/.config/nvim/lua/plugins/lsp.lua
+++ b/.config/nvim/lua/plugins/lsp.lua
@@ -1,3 +1,3 @@
-- Enable preconfigured LSP's
-vim.lsp.enable({"clangd", "gopls", "texlab"})
+vim.lsp.enable({"clangd", "gopls", "texlab", "rust-analyzer"})
diff --git a/.config/shells/zsh/.zshrc b/.config/shells/zsh/.zshrc
index aef99aa..b9c5a1f 100644
--- a/.config/shells/zsh/.zshrc
+++ b/.config/shells/zsh/.zshrc
@@ -2,6 +2,23 @@ if command -v tmux &> /dev/null && [ -n "$PS1" ] && [[ ! "$TERM" =~ screen ]] &&
exec tmux
fi
+color_wrap() {
+ printf "%s%s%s" %{$fg_bold[$1]%} $2 %{$reset_color%}
+}
+
+git_good() {
+ REPO="$(git config --get remote.origin.url 2>/dev/null | sed -n -E 's|.*/(.*)\.git|\1|p' | tr -d '\n' )"
+ BRANCH="$(git branch 2>/dev/null | sed -n -E 's/\* (.*)/\1/p' | tr -d '\n')"
+ [[ -n $BRANCH ]] && color_wrap cyan "[$REPO::$BRANCH] "
+}
+
+error_code() {
+ if [[ $1 != 0 ]];
+ then
+ color_wrap red "["$1"]"
+ fi
+}
+
source ~/.zprofile
export SHELLDIR="$XDG_CONFIG_HOME/shells"
export ZSH="$SHELLDIR/zsh"
@@ -19,7 +36,7 @@ SAVEHIST=100
HISTSIZE=5000
setopt prompt_subst
autoload -U colors && colors
-PROMPT='%{$fg_bold[$shColor]%}$comSym%{$reset_color%} in %{$fg_bold[$shColor]%}%c%{$reset_color%} $(ret=$?; [[ $ret != 0 ]] && printf "%s[%d]%s " %{$fg_bold[red]%} $ret %{$reset_color%})
+PROMPT='%{$fg_bold[$shColor]%}$comSym%{$reset_color%} in %{$fg_bold[$shColor]%}%c%{$reset_color%} $(ret=$?; git_good ; error_code $ret)
→ '
source $ZSH/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source $ZSH/plugins/fzf-tab/fzf-tab.zsh