fix padding length when changing working dir; fix alias

This commit is contained in:
François
2026-04-19 11:07:03 +02:00
parent 85081ecec3
commit 494dd030ba
2 changed files with 15 additions and 14 deletions

View File

@@ -27,10 +27,9 @@ help() {
} }
alias v=nvim alias v=nvim
if [ -f $XDG_CONFIG_HOME/ssh/config ]; then if [ -f "$XDG_CONFIG_HOME/ssh/config" ]; then
alias ssh="ssh -A -F $XDG_CONFIG_HOME/ssh/config" alias ssh="ssh -A -F $XDG_CONFIG_HOME/ssh/config"
else
alias ssh="ssh -A"
fi fi
alias ssh-add="ssh-add -t 4h" alias ssh-add="ssh-add -t 4h"
alias run-ssh-agent="eval $(ssh-agent)" alias run-ssh-agent="eval $(ssh-agent)"

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# color stuff # color stuff
# return contrasted color # return contrasted color
@@ -117,14 +118,15 @@ PROMPT_PAD="."
PROMPT_EXTRA_WIDTH=73 PROMPT_EXTRA_WIDTH=73
precmd() { precmd() {
if (($COLUMNS > PROMPT_EXTRA_WIDTH)); then local prompt_ln="${#${${PWD}/${HOME}/~}}" # len of path where $HOME is susbtiued by ~ (and is counted as 1)
if (($COLUMNS > PROMPT_EXTRA_WIDTH + prompt_ln)); then
local exec_ts=$(($(date +%s%N) - STARTCMD_TS)) local exec_ts=$(($(date +%s%N) - STARTCMD_TS))
local seconds=$(echo "scale=9; $exec_ts / 1000000000" | bc) local seconds=$(echo "scale=9; $exec_ts / 1000000000" | bc)
local hours=$((seconds / 3600)) local hours=$((seconds / 3600))
local minutes=$(((seconds % 3600) / 60)) local minutes=$(((seconds % 3600) / 60))
seconds=$((seconds % 60)) seconds=$((seconds % 60))
local exec_str=$(printf "%02d:%02d:%06.3f" hours minutes seconds) local exec_str=$(printf "%02d:%02d:%06.3f" hours minutes seconds)
local padding=$(printf %$(($COLUMNS - 73))s | tr ' ' $PROMPT_PAD) local padding=$(printf %$(($COLUMNS - PROMPT_EXTRA_WIDTH - prompt_ln))s | tr ' ' $PROMPT_PAD)
extra_prompt="%k%f${padding}${POWERLINE_STOP_INV}%K{${FG3}}%F{${BG3}}${POWERLINE_SEPARATOR}%K{${BG3}}%F{${FG3}} took ${exec_str} \uf252%K{${BG3}}%F{${BG2}}${POWERLINE_SEPARATOR}%K{${BG2}}%F{${FG2}}at $(date +%H:%M:%S) \uf017 %k%F{${BG2}}${POWERLINE_START_INV}" extra_prompt="%k%f${padding}${POWERLINE_STOP_INV}%K{${FG3}}%F{${BG3}}${POWERLINE_SEPARATOR}%K{${BG3}}%F{${FG3}} took ${exec_str} \uf252%K{${BG3}}%F{${BG2}}${POWERLINE_SEPARATOR}%K{${BG2}}%F{${FG2}}at $(date +%H:%M:%S) \uf017 %k%F{${BG2}}${POWERLINE_START_INV}"
else else
extra_prompt="" extra_prompt=""