From 1e2f09ab3191443a1e30f7d0bb929db82f721218 Mon Sep 17 00:00:00 2001 From: Tovi Jaeschke-Rogers Date: Mon, 10 Jun 2024 18:58:40 +0930 Subject: [PATCH] feat: add oh-my-posh --- .config/nvim/lua/tovi/plugins/formatting.lua | 24 +++--- .config/oh-my-posh/zen.toml | 72 ++++++++++++++++++ .zshrc | 78 +++++++------------- 3 files changed, 109 insertions(+), 65 deletions(-) create mode 100644 .config/oh-my-posh/zen.toml diff --git a/.config/nvim/lua/tovi/plugins/formatting.lua b/.config/nvim/lua/tovi/plugins/formatting.lua index e499973..4980822 100644 --- a/.config/nvim/lua/tovi/plugins/formatting.lua +++ b/.config/nvim/lua/tovi/plugins/formatting.lua @@ -18,16 +18,16 @@ return { rust = { "rustfmt" }, shell = { "shfmt", "shellcheck" }, python = { "isort", "black" }, - php = { "phpcbf" } - }, - format_on_save = { - lsp_fallback = true, - async = false, - timeout_ms = 500, - }, - format_after_save = { - lsp_fallback = true, + php = { "phpcbf" }, }, + -- format_on_save = { + -- lsp_fallback = true, + -- async = false, + -- timeout_ms = 500, + -- }, + -- format_after_save = { + -- lsp_fallback = true, + -- }, log_level = vim.log.levels.WARN, notify_on_error = false, }) @@ -40,8 +40,8 @@ return { }) end) - conform.formatters.phpcbf = { - prepend_args = { "--standard=~/.config/phpcs.xml" } - } + conform.formatters.phpcbf = { + prepend_args = { "--standard=~/.config/phpcs.xml" }, + } end, } diff --git a/.config/oh-my-posh/zen.toml b/.config/oh-my-posh/zen.toml new file mode 100644 index 0000000..2cb0656 --- /dev/null +++ b/.config/oh-my-posh/zen.toml @@ -0,0 +1,72 @@ +#:schema https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json + +version = 2 +final_space = true +console_title_template = '{{ .Shell }} in {{ .Folder }}' + +[[blocks]] + type = 'prompt' + alignment = 'left' + newline = true + + [[blocks.segments]] + type = 'path' + style = 'plain' + background = 'transparent' + foreground = 'blue' + template = '{{ .Path }}' + + [blocks.segments.properties] + style = 'full' + + [[blocks.segments]] + type = 'git' + style = 'plain' + foreground = 'p:grey' + background = 'transparent' + template = ' {{ .HEAD }}{{ if or (.Working.Changed) (.Staging.Changed) }}*{{ end }} {{ if gt .Behind 0 }}⇣{{ end }}{{ if gt .Ahead 0 }}⇡{{ end }}' + + [blocks.segments.properties] + fetch_status = true + +[[blocks]] + type = 'rprompt' + overflow = 'hidden' + + [[blocks.segments]] + type = 'executiontime' + style = 'plain' + foreground = 'yellow' + background = 'transparent' + template = '{{ .FormattedMs }}' + + [blocks.segments.properties] + threshold = 5000 + +[[blocks]] + type = 'prompt' + alignment = 'left' + newline = true + + [[blocks.segments]] + type = 'text' + style = 'plain' + foreground_templates = [ + "{{if gt .Code 0}}red{{end}}", + "{{if eq .Code 0}}magenta{{end}}", + ] + background = 'transparent' + template = '❯' + +[transient_prompt] + foreground_templates = [ + "{{if gt .Code 0}}red{{end}}", + "{{if eq .Code 0}}magenta{{end}}", + ] + background = 'transparent' + template = '❯ ' + +[secondary_prompt] + foreground = 'magenta' + background = 'transparent' + template = '❯❯ ' diff --git a/.zshrc b/.zshrc index 05f16bf..ad7a6fe 100644 --- a/.zshrc +++ b/.zshrc @@ -7,12 +7,31 @@ fi # Disable the log builtin, so we don't conflict with /usr/bin/log disable log +# Save command history +HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history +HISTSIZE=99999999 +SAVEHIST=$HISTSIZE + +# Variables export CASE_SENSITIVE="true" +export EDITOR=nvim +export GIT_EDITOR=nvim +export PATH="${HOME}/.local/bin/:${HOME}/go/bin:${HOME}/.cargo/bin:${PATH}" + +if [[ $(uname) == 'Darwin' ]]; then + export HOMEBREW_NO_AUTO_UPDATE=1 + + export PATH="/opt/homebrew/lib/ruby/gems/3.3.0:$PATH" + export PATH="/opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0:$PATH" + + eval "$(rbenv init - zsh)" +fi + +# Auto complete case insensitive zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' # Load colors autoload -U colors && colors -PROMPT="%{$fg[blue]%}%1~ %{$fg[green]%}>%{$reset_color%} " # Automatically cd into typed directory. setopt autocd @@ -28,13 +47,6 @@ fpath=(~/.zsh $fpath) bindkey -v export KEYTIMEOUT=1 -# Use vim keys in tab complete menu: -# bindkey -M menuselect 'h' vi-backward-char -# bindkey -M menuselect 'k' vi-up-line-or-history -# bindkey -M menuselect 'l' vi-forward-char -# bindkey -M menuselect 'j' vi-down-line-or-history -# bindkey -v '^?' backward-delete-char - # Edit line in vim with ctrl-e: autoload edit-command-line; zle -N edit-command-line bindkey '^e' edit-command-line @@ -44,15 +56,6 @@ up () { cd $(printf "%0.0s../" $(seq 1 $1)); } -function cdv () { - if [[ $(uname) == 'Darwin' ]]; then - cd $(pbpaste) - return - fi - - cd $(xclip -selection clipboard -o) -} - function cdf () { cd $(find . -type d -print | fzf) } @@ -60,20 +63,8 @@ function cdf () { # Load aliases source ~/.config/aliasrc -export EDITOR=nvim -export GIT_EDITOR=nvim - -# Save command history -HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history -HISTSIZE=99999999 -SAVEHIST=$HISTSIZE - - -if [[ $(uname) == 'Darwin' ]]; then -fi - +# Android dev config export ANDROID_HOME="$HOME/Android/Sdk" - if [[ $(uname) == 'Darwin' ]]; then export ANDROID_HOME="$HOME/Library/Android/sdk" export PATH="/opt/homebrew/opt/openjdk/bin:$PATH" @@ -81,29 +72,10 @@ fi export PATH="${PATH}:${ANDROID_HOME}/platform-tools:$ANDROID_HOME/cmdline-tools/latest/bin" -# FNM variables -export PATH="/run/user/1000/fnm_multishells/20590_1663546026606/bin":$PATH -export FNM_MULTISHELL_PATH="/run/user/1000/fnm_multishells/20590_1663546026606" -export FNM_VERSION_FILE_STRATEGY="local" -export FNM_DIR="/home/tovi/.local/share/fnm" -export FNM_LOGLEVEL="info" -export FNM_NODE_DIST_MIRROR="https://nodejs.org/dist" -export FNM_ARCH="x64" -rehash - -if [[ $(uname) == 'Darwin' ]]; then - export HOMEBREW_NO_AUTO_UPDATE=1 - - export PATH="/opt/homebrew/lib/ruby/gems/3.3.0:$PATH" - export PATH="/opt/homebrew/Cellar/ruby/3.3.0/lib/ruby/gems/3.3.0:$PATH" - - eval "$(rbenv init - zsh)" -fi - -export PATH="${HOME}/.local/bin/:${HOME}/go/bin:${HOME}/.cargo/bin:${PATH}" - -source <(fzf --zsh) - export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +source <(fzf --zsh) + +eval "$(oh-my-posh init zsh --config $HOME/.config/oh-my-posh/zen.toml)"