shell: update ps1

This commit is contained in:
2024-06-10 11:02:34 +02:00
parent 6c9d18c7c1
commit 40cab168f9
2 changed files with 8 additions and 17 deletions

View File

@@ -12,11 +12,7 @@ esac
git_branch() { git_branch() {
if $(git rev-parse --git-dir > /dev/null 2>&1); then if $(git rev-parse --git-dir > /dev/null 2>&1); then
local branch_name=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') local branch_name=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
if [[ $(uname) == "OpenBSD" ]]; then echo "${branch_name} "
echo "(${branch_name}) "
else
echo "(${branch_name} ) "
fi
fi fi
} }
@@ -34,26 +30,21 @@ NEWLINE=$'\n'
PROMPT_COMMAND=__prompt_command PROMPT_COMMAND=__prompt_command
__prompt_command() { __prompt_command() {
local EXIT="$?" local EXIT="$?"
# Shorten $PWD, if it's too long
if [ $COLUMNS -lt 80 ]; then if [ $COLUMNS -lt 80 ]; then
export PROMPT_DIRTRIM=1 export PROMPT_DIRTRIM=1
else else
export PROMPT_DIRTRIM=0 export PROMPT_DIRTRIM=0
fi fi
export PS1="${HOST} ${DIR} ${GIT_NIX}${NEWLINE}"
if [[ $(uname) == "OpenBSD" ]]; then export PS1="${HOST} ${DIR} ${GIT_NIX}${NEWLINE}"
local red_lambda='\[\033[0;31m\]>\[\033[00m\] '
local green_lambda='\[\033[0;32m\]>\[\033[00m\] '
else
local red_lambda='\[\033[0;31m\]󱞩\[\033[00m\] '
local green_lambda='\[\033[0;32m\]󱞩\[\033[00m\] '
fi
if [ $EXIT != 0 ] if [ $EXIT != 0 ]
then then
PS1+=$red_lambda PS1+='\[\033[0;31m\]$\[\033[00m\] '
else else
PS1+=$green_lambda PS1+='\[\033[0;32m\]$\[\033[00m\] '
fi fi
} }

View File

@@ -22,7 +22,7 @@ alias dh1='du . -h -d1'
alias dhs='du . -hs' alias dhs='du . -hs'
alias diff_dir='diff -qr' alias diff_dir='diff -qr'
alias g='git' alias g='git'
alias l='eza --icons --hyperlink' alias l='ls --color --hyperlink'
alias nd="nix develop ." alias nd="nix develop ."
alias nssh='SSH_AUTH_SOCK= ssh' alias nssh='SSH_AUTH_SOCK= ssh'
alias s='kitten ssh' alias s='kitten ssh'
@@ -57,7 +57,7 @@ ocr() {
return return
fi fi
name=${file%%.*} name=${file%%.*}
ocrmypdf -l ger+eng --output-type pdf $file ${name}.ocr.pdf ocrmypdf -l deu+eng --output-type pdf $file ${name}.ocr.pdf
} }
# private laptop acpi magic # private laptop acpi magic