From aaf220e382a1df9997570969235f70d3caf0f9c9 Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Sun, 10 Aug 2025 11:37:13 +0100 Subject: [PATCH] Various improvemnts mainly around sheldon usage --- jmb.omp.toml | 106 ------------------------------- sheldon.toml | 31 +++++---- zsh/plugins/aliases.plugin.zsh | 5 +- zsh/plugins/fnm.plugin.zsh | 6 -- zsh/plugins/functions.plugin.zsh | 18 ------ zshrc.zsh | 30 +++++++-- 6 files changed, 45 insertions(+), 151 deletions(-) delete mode 100644 jmb.omp.toml delete mode 100644 zsh/plugins/fnm.plugin.zsh diff --git a/jmb.omp.toml b/jmb.omp.toml deleted file mode 100644 index 66fc130..0000000 --- a/jmb.omp.toml +++ /dev/null @@ -1,106 +0,0 @@ -#:schema https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json - -version = 2 -final_space = true -console_title_template = '{{ .Folder }}' - -[[blocks]] - type = 'prompt' - alignment = 'left' - - [[blocks.segments]] - type = 'os' - style = 'diamond' - powerline_symbol = '' - foreground = '#ffffff' - background = '#546e7a' - leading_diamond = '' - template = '{{.Icon}} ' - - [[blocks.segments]] - type = 'path' - style = 'powerline' - powerline_symbol = '' - foreground = '#ffffff' - background = '#0080ff' - template = '  {{ .Path }} ' - - [blocks.segments.properties] - style = 'full' - - [[blocks.segments]] - type = 'git' - style = 'powerline' - powerline_symbol = '' - foreground = '#000000' - background = '#5cec8b' - background_templates = ['{{ if or (.Working.Changed) (.Staging.Changed) }}#FFEB3B{{ end }}', '{{ if and (gt .Ahead 0) (gt .Behind 0) }}#FFA300{{ end }}', '{{ if gt .Ahead 0 }}#FF7070{{ end }}', '{{ if gt .Behind 0 }}#90F090{{ end }}'] - template = ' {{ .UpstreamIcon }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }}  {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }}  {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }}  {{ .StashCount }}{{ end }} ' - - [blocks.segments.properties] - fetch_stash_count = true - fetch_status = true - fetch_upstream_icon = true - branch_icon = ' ' - - [[blocks.segments]] - type = 'status' - style = 'diamond' - foreground = '#ffffff' - background = '#2e9599' - background_templates = ['{{ if gt .Code 0 }}#f1184c{{ end }}'] - trailing_diamond = '' - template = ' ' - - [blocks.segments.properties] - always_enabled = true - -[[blocks]] - type = 'rprompt' - alignment = 'left' - - [[blocks.segments]] - type = "text" - style = "plain" - foreground = "default" - background = "transparent" - template = "{{ if .Env.SHELL_LOADING }} loading {{ end }}" - - [[blocks.segments]] - type = "executiontime" - style = "diamond" - leading_diamond = '' - trailing_diamond = '' - foreground = "lightRed" - background = "black" - template = "󱦟 {{ .FormattedMs }} " - - [blocks.segments.properties] - threshold = 2000 - style = "austin" - -[[blocks]] - type = 'prompt' - alignment = 'left' - newline = true - - [[blocks.segments]] - type = 'root' - style = 'plain' - foreground = 'yellow' - template = ' ' - - [[blocks.segments]] - type = 'text' - style = 'plain' - foreground = 'default' - template = ' ' - -[transient_prompt] - foreground_templates = [ - "{{if gt .Code 0}}red{{end}}", - "{{if eq .Code 0}}default{{end}}", - ] - background = 'transparent' - template = '$ ' - diff --git a/sheldon.toml b/sheldon.toml index d00be71..4bfef21 100644 --- a/sheldon.toml +++ b/sheldon.toml @@ -7,8 +7,16 @@ shell = "zsh" [templates] -defer = """{{ hooks?.pre | nl }}{% for file in files %}zsh-defer source "{{ file }}"\n{% endfor %}{{ hooks?.post | nl }}""" -defer-more = """{{ hooks?.pre | nl }}{% for file in files %}zsh-defer -t 0.5 source "{{ file }}"\n{% endfor %}{{ hooks?.post | nl }}""" +defer = ''' + {{- hooks?.pre | nl }} + {%- for file in files %}zsh-defer source "{{ file }}"{{ "\n" }} + {%- endfor %} + {{- hooks?.post | nl }}''' +defer-more = ''' + {{- hooks?.pre | nl }} + {%- for file in files %}zsh-defer -t 0.5 source "{{ file }}"{{ "\n" }} + {%- endfor %} + {{- hooks?.post | nl }}''' # Loading indicator # ----------------- @@ -19,23 +27,18 @@ local = "~/.zsh/plugins/loading" # Completions # ----------- -[plugins.fzf-tab] -github = "Aloxaf/fzf-tab" - [plugins.zsh-completions] github = "zsh-users/zsh-completions" # Sourced # ------- -[plugins.zsh-defer] -github = "romkatv/zsh-defer" - -# Some of the functions may get used elsewhere -# so we do not defer loading [plugins.functions] local = "~/.zsh/plugins" +[plugins.zsh-defer] +github = "romkatv/zsh-defer" + # Deferred plugins # ---------------- @@ -48,6 +51,10 @@ github = "junegunn/fzf" use = ["shell/completion.zsh", "shell/key-bindings.zsh"] apply = ["defer"] +[plugins.fzf-tab] +github = "Aloxaf/fzf-tab" +apply = ["defer"] + [plugins.fzf-completions] local = "~/.zsh/plugins" apply = ["defer"] @@ -71,8 +78,9 @@ github = "wfxr/forgit" apply = ["defer"] [plugins.fnm] -local = "~/.zsh/plugins" +github = "dominik-schwabe/zsh-fnm" apply = ["defer"] +hooks.pre = 'export ZSH_FNM_ENV_EXTRA_ARGS="--use-on-cd"' [plugins.zoxide] github = "ajeetdsouza/zoxide" @@ -84,6 +92,7 @@ apply = ["defer"] [plugins.zsh-ssh] github = 'sunlei/zsh-ssh' +apply = ["defer"] [plugins.zsh-syntax-highlighting] github = "zsh-users/zsh-syntax-highlighting" diff --git a/zsh/plugins/aliases.plugin.zsh b/zsh/plugins/aliases.plugin.zsh index 5d9fe81..f9123bd 100644 --- a/zsh/plugins/aliases.plugin.zsh +++ b/zsh/plugins/aliases.plugin.zsh @@ -4,11 +4,8 @@ alias bubc="brew upgrade && brew cleanup" alias bubo="brew update && brew outdated" -# See which user or profile we are authneticated as in aws-cli -alias aws-whoami="aws sts get-caller-identity" - # Use eza instead of ls -alias als="eza --oneline --long --classify --icons --header" +alias eza="eza --oneline --long --classify --icons --header" # Laravel Sail alias sail="[ -f sail ] && bash sail || bash vendor/bin/sail" diff --git a/zsh/plugins/fnm.plugin.zsh b/zsh/plugins/fnm.plugin.zsh deleted file mode 100644 index e93876a..0000000 --- a/zsh/plugins/fnm.plugin.zsh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env zsh - -# Setup Fast Node Manager -if (( ${+commands[fnm]} )); then - eval "$(fnm env --use-on-cd --shell zsh)" -fi diff --git a/zsh/plugins/functions.plugin.zsh b/zsh/plugins/functions.plugin.zsh index ab5d867..44056f0 100644 --- a/zsh/plugins/functions.plugin.zsh +++ b/zsh/plugins/functions.plugin.zsh @@ -100,21 +100,3 @@ function stop-proxy() { ssh -S $socket_dir/ssh-proxy-control -O exit $SSH_PROXY_HOST } -# Get the system appearance -function get-system-appearance() { - if ! type defaults &>/dev/null; then - echo "" - fi - - local darkMode=true; - - if [[ $(defaults read -g AppleInterfaceStyle 2> /dev/null) != 'Dark' ]]; then - darkMode=false - fi - - if [[ $darkMode == true ]]; then - echo "dark" - else - echo "light" - fi -} diff --git a/zshrc.zsh b/zshrc.zsh index 69b7610..ef543c5 100644 --- a/zshrc.zsh +++ b/zshrc.zsh @@ -14,7 +14,7 @@ export LANG=en_GB.UTF-8 # Preferred editor for local and remote sessions export EDITOR=nvim -# Autoadd to PATH (neede for MacTex) +# Auto-add to PATH (needed for MacTex) # It prepends to $PATH, so we do it first then add our own if [[ -f /usr/libexec/path_helper ]]; then eval $(/usr/libexec/path_helper) @@ -31,7 +31,7 @@ export PATH="$HOME/.local/bin:$PATH" # credit Paul Irish: https://github.com/paulirish/dotfiles/blob/606d85f083eb53853789ce9dcaf31a49756471bd/.zshrc#L80 # Automatically list directory contents on `cd`. -# Switched to using `exa` instead of `ls`. +# Switched to using `eza` instead of `ls`. ezacd () { emulate -L zsh; @@ -93,12 +93,25 @@ if (( ${+commands[brew]} )); then fi -# Load plugins via Sheldon -if (( ${+commands[sheldon]} )); then - eval "$(sheldon source)" -fi # Detect system appearance +function get-system-appearance() { + if ! type defaults &>/dev/null; then + echo "" + fi + + local darkMode=true; + + if [[ $(defaults read -g AppleInterfaceStyle 2> /dev/null) != 'Dark' ]]; then + darkMode=false + fi + + if [[ $darkMode == true ]]; then + echo "dark" + else + echo "light" + fi +} export MACOS_APPEARANCE=`get-system-appearance` # Colourised output for `ls` @@ -124,6 +137,11 @@ test -e $HOME/.extra && source $HOME/.extra autoload -U url-quote-magic zle -N self-insert url-quote-magic +# Load plugins via Sheldon +if (( ${+commands[sheldon]} )); then + eval "$(sheldon source)" +fi + # Set the prompt # We need zsh git integration # Autoload zsh's `add-zsh-hook` and `vcs_info` functions