shell: add oh-my-posh, zoxide and fzf
This commit is contained in:
parent
3afa33f28e
commit
a4906177a3
3
shell/.stow-local-ignore
Normal file
3
shell/.stow-local-ignore
Normal file
@ -0,0 +1,3 @@
|
||||
^/\.git.*
|
||||
.*.bak$
|
||||
readme.md
|
||||
@ -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")"
|
||||
|
||||
80
shell/dot-config/oh-my-posh.toml
Normal file
80
shell/dot-config/oh-my-posh.toml
Normal file
@ -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'
|
||||
Loading…
x
Reference in New Issue
Block a user