From a4906177a340b02d3868a6f09f795e36e9a6a18e Mon Sep 17 00:00:00 2001 From: LailaTheElf Date: Sun, 17 Aug 2025 17:45:24 +0200 Subject: [PATCH] shell: add oh-my-posh, zoxide and fzf --- shell/.stow-local-ignore | 3 ++ shell/dot-bashrc | 47 +++++++------------ shell/dot-config/oh-my-posh.toml | 80 ++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 30 deletions(-) create mode 100644 shell/.stow-local-ignore create mode 100644 shell/dot-config/oh-my-posh.toml diff --git a/shell/.stow-local-ignore b/shell/.stow-local-ignore new file mode 100644 index 0000000..5f8721f --- /dev/null +++ b/shell/.stow-local-ignore @@ -0,0 +1,3 @@ +^/\.git.* +.*.bak$ +readme.md diff --git a/shell/dot-bashrc b/shell/dot-bashrc index 1de9777..c501109 100644 --- a/shell/dot-bashrc +++ b/shell/dot-bashrc @@ -9,36 +9,11 @@ alias ls='ls --color=auto' alias la='ls --color=auto -plhA' alias grep='grep --color=auto' -parse_git_branch() { - local b=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') - if [ "$b" != "" ] - then - local behind=$(git rev-list HEAD...@{u} --ignore-submodules --count 2>/dev/null) - local ahead=$(git rev-list @{u}...HEAD --ignore-submodules --count 2>/dev/null) - git diff --cached --exit-code &> /dev/null || b="${b}+" - git diff --exit-code &> /dev/null || b="${b}*" - if [[ "$behind" > 0 || "$ahead" > 0 ]] - then - b="$b ☁ " - if [[ "$ahead" > 0 ]] - then - b="$b+$ahead" - fi - if [[ "$behind" > 0 ]] - then - b="$b-$behind" - fi - fi - fi - echo -n "$b" -} -# \e[0;$(e=$?;((e))&& echo "91" || echo "0"))m\]\$\[\e[0m\] -PS1='\n\[\e[35m\]\h \[\e[32m\]\w \[\e[35m\]$(parse_git_branch)\[\e[0m\]\n$ ' - export PATH="$PATH:$HOME/.local/bin" export EDITOR=vim + +# quartus export QSYS_ROOTDIR="$HOME/.local/intelFPGA_lite/18.1/quartus/sopc_builder/bin" -. "$HOME/.cargo/env" # start ssh-agent if [[ ! -f "$HOME/.ssh/agent.env" ]] @@ -53,6 +28,18 @@ export SSH_AGENT_PID; export SSH_AUTH_SOCK; # rust -export RUSTUP_HOME="$HOME/.local/rust/rustup" -export CARGO_HOME="$HOME/.local/rust/cargo" -. $HOME/.local/rust/cargo +# export RUSTUP_HOME="$HOME/.local/rust/rustup" +# export CARGO_HOME="$HOME/.local/rust/cargo" +# . $HOME/.local/rust/cargo +. "$HOME/.cargo/env" + +# better tools +export FZF_CTRL_T_OPTS=" + --walker-skip .git,node_modules,target,.var + --preview 'bat -n --color=always {}' + --bind 'ctrl-/:change-preview-window(down|hidden|)'" +eval "$(fzf --bash)" +eval "$(zoxide init bash --cmd cd)" + +# prompt +eval "$(oh-my-posh init bash --config "$HOME/.config/oh-my-posh.toml")" diff --git a/shell/dot-config/oh-my-posh.toml b/shell/dot-config/oh-my-posh.toml new file mode 100644 index 0000000..e87ebb0 --- /dev/null +++ b/shell/dot-config/oh-my-posh.toml @@ -0,0 +1,80 @@ +console_title_template = '{{ .Shell }} in {{ .Folder }}' +version = 3 +final_space = true + +[secondary_prompt] + template = '❯❯ ' + foreground = 'magenta' + background = 'transparent' + +## does not work in bash +# [transient_prompt] +# template = '❯ ' +# foreground_templates = ['{{if gt .Code 0}}red{{end}}', '{{if eq .Code 0}}default{{end}}'] +# background = 'transparent' + +[[blocks]] + type = 'prompt' + alignment = 'left' + newline = true + + [[blocks.segments]] + type = 'session' + template = '{{ if .SSHSession }}⇄ {{ end }}{{ .HostName }}' + style = 'plain' + foreground_templates = ['{{if .Root }}red{{else}}magenta{{end}}'] + background = 'transparent' + + [[blocks.segments]] + type = 'path' + template = ' {{ .Path }}' + style = 'plain' + foreground = 'green' + background = 'transparent' + + [blocks.segments.properties] + style = 'full' + + [[blocks.segments]] + type = 'git' + template = ' {{ .HEAD }}{{ if (.Working.Changed) }}*{{ end }}{{ if (.Staging.Changed) }}+{{ end }}{{ if or (gt .Behind 0) (gt .Ahead 0) }} ☁ {{ if gt .Behind 0 }}-{{ .Behind }}{{ end }}{{ if gt .Ahead 0 }}+{{ .Ahead }}{{ end }}{{ end }}' + style = 'plain' + foreground = 'magenta' + background = 'transparent' + + [blocks.segments.properties] + branch_icon = '' + commit_icon = '@' + fetch_status = true + [blocks.segments.properties.ignore_submodules] + '*' = 'none' + +[[blocks]] + type = 'rprompt' + overflow = 'hidden' + + [[blocks.segments]] + template = '{{ .FormattedMs }}' + foreground = 'yellow' + background = 'transparent' + type = 'executiontime' + style = 'plain' + + [blocks.segments.properties] + cache_duration = 'none' + threshold = 5000 + +[[blocks]] + type = 'prompt' + alignment = 'left' + newline = true + + [[blocks.segments]] + template = '❯' + background = 'transparent' + type = 'text' + style = 'plain' + foreground_templates = ['{{if gt .Code 0}}red{{end}}', '{{if eq .Code 0}}magenta{{end}}'] + + [blocks.segments.properties] + cache_duration = 'none'