Change prompt, add args

This commit is contained in:
buffet 2022-07-22 17:57:09 +00:00
parent 6cd4ffeb91
commit b440d44574

View file

@ -22,38 +22,27 @@ t() {
fmt() { fmt() {
[ -f .clang-format ] && { [ -f .clang-format ] && {
find src -type f -name '*.[ch]' -print | xargs -d '\n' clang-format -i find src -type f -name '*.[ch]' -print | xargs -d '\n' clang-format -i "$@"
return return
} }
[ -f Cargo.toml ] && { [ -f Cargo.toml ] && {
cargo fmt cargo fmt "$@"
return return
} }
} }
__prompt() { __prompt() {
case $? in case $? in
0) PS1='\[\e[34m\]' ;; 0) PS1='; ' ;;
*) PS1='\[\e[31m\]' ;; *) PS1='\[\e[31m\]; \[\e[0m\]' ;;
esac esac
if [[ "$PWD" == "$HOME" ]]; then
PS1+='~'
elif [[ "$PWD" == / ]]; then
PS1+=/
else
PS1+="${PWD##*/}"
fi
PS1+='\[\e[0m\] '
} }
PROMPT_COMMAND="__prompt;$PROMPT_COMMAND" PROMPT_COMMAND="__prompt;$PROMPT_COMMAND"
. "$HOME/.cargo/env" . "$HOME/.cargo/env"
eval "$(direnv hook bash)" eval "$(direnv hook bash)"
pgrep -u "$USER" -x ssh-agent >/dev/null || ssh-agent -t 5m >"$XDG_RUNTIME_DIR/ssh-agent.env" pgrep -u "$USER" -x ssh-agent >/dev/null || ssh-agent -t 5m >"$XDG_RUNTIME_DIR/ssh-agent.env"
[[ "$SSH_AUTH_SOCK" ]] || . "$XDG_RUNTIME_DIR/ssh-agent.env" >/dev/null [[ "$SSH_AUTH_SOCK" ]] || . "$XDG_RUNTIME_DIR/ssh-agent.env" >/dev/null
head -n 10 ~/todo/todo