summaryrefslogtreecommitdiff
path: root/.yashrc
diff options
context:
space:
mode:
Diffstat (limited to '.yashrc')
-rw-r--r--.yashrc83
1 files changed, 83 insertions, 0 deletions
diff --git a/.yashrc b/.yashrc
new file mode 100644
index 0000000..4cf14c5
--- /dev/null
+++ b/.yashrc
@@ -0,0 +1,83 @@
+_ps1_prompt() {
+ cmd_status=$?
+ cmd_duration=$((CMD_DURATION / 1000))
+ CMD_DURATION=0
+ is_git=$(git rev-parse --is-inside-work-tree 2>/dev/null)
+
+ printf '\n\\foc.'
+ if [ "$is_git" ]; then
+ printf '%s' "$(git rev-parse --show-toplevel | awk -F/ '{ print $NF }')"
+ git_path=$(git rev-parse --show-prefix)
+ git_path="${git_path%/}"
+ [ "$git_path" ] && printf '/%s' "$git_path"
+ else
+ printf '%s' "$(pwd | sed "s#^$HOME#~#")"
+ fi
+ printf '\\fD.'
+
+ if [ "$is_git" ]; then
+ printf ' on \\fom. %s' "$(git branch --show-current)"
+
+ stat=
+ s=$(git status --porcelain -b)
+ echo "$s" | grep -q '^U[UDA]|^AA|^DD|^[DA]U' && stat="$stat="
+ git rev-parse --verify refs/stash >/dev/null 2>&1 && stat="$stat\$"
+ echo "$s" | grep -q '^[MARCDU ]D|^D[ UM]' && stat="$stat✘"
+ echo "$s" | grep -q '^R[ MD]' && stat="$stat»"
+ echo "$s" | grep -q '^[ MARC]M' && stat="$stat!"
+ echo "$s" | grep -q '^A[ MDAU]|^M[ MD]|^UA' && stat="$stat+"
+ echo "$s" | grep -q '^\?\?' && stat="$stat?"
+
+ ahead=
+ behind=
+ echo "$s" | grep -q '^## [^ ]\+ .*ahead' && ahead=1
+ echo "$s" | grep -q '^## [^ ]\+ .*behind' && behind=1
+ if [ "$ahead" ] && [ "$behind" ]; then
+ stat="$stat⇕"
+ elif [ "$ahead" ]; then
+ stat="$stat⇡"
+ elif [ "$behind" ]; then
+ stat="$stat⇣"
+ fi
+
+ if [ "$stat" ]; then
+ printf '\\for. [%s]' "$stat"
+ fi
+ fi
+
+ if [ "$cmd_duration" -gt 1 ]; then
+ printf ' took\\foy.'
+
+ secs=$((cmd_duration % 60))
+ mins=$((cmd_duration / 60 % 60))
+ hours=$((cmd_duration / 3600))
+
+ [ "$hours" -gt 0 ] && printf ' %dh' "$hours"
+ [ "$mins" -gt 0 ] && printf ' %dm' "$mins"
+ [ "$secs" -gt 0 ] && printf ' %ds' "$secs"
+ fi
+ printf '\\fD.\n'
+
+ n_jobs="$(jobs 2>/dev/null | wc -l)"
+ if [ "$n_jobs" -gt 0 ]; then
+ printf '\\fob.✦ '
+ [ "$n_jobs" -gt 1 ] && printf '%d ' "$n_jobs"
+ printf '\\fD.'
+ fi
+
+ if [ "$cmd_status" -eq 0 ]; then
+ printf '\\fg.'
+ else
+ printf '\\fr.'
+ fi
+ printf '❯ \\fD.'
+}
+
+export PS1='$(_ps1_prompt)'
+
+export HISTSIZE=100000
+export HISTRMDUP=10
+
+set le-predict
+
+alias cfg='git --git-dir ~/.cfg --work-tree ~'