rice/bash/.bashrc

60 lines
1.2 KiB
Bash
Raw Normal View History

2021-04-26 15:37:11 +00:00
# exit if not run interactively
[[ $- != *i* ]] && return
2017-12-15 11:01:42 +00:00
shopt -s cdspell checkjobs extglob globstar histappend nocaseglob
2022-05-02 08:25:42 +00:00
HISTSIZE=50000
2017-12-15 11:01:42 +00:00
HISTCONTROL=erasedups:ignorespace
2021-06-03 14:26:34 +00:00
alias ..='cd ..'
alias cd..='cd ..'
2017-12-15 11:01:42 +00:00
alias htop='htop -t'
alias mkdir='mkdir -p'
alias rg='rg -S'
2021-06-03 15:04:33 +00:00
alias v='f -e nvim'
2017-12-15 11:01:42 +00:00
2021-08-18 18:53:02 +00:00
t() {
case $1 in
u*) git -C ~/todo commit -am 'docs: update' && git -C ~/todo push ;;
p*) git -C ~/todo pull ;;
2022-05-02 08:25:42 +00:00
*) "$EDITOR" ~/todo/todo ;;
2021-08-18 18:53:02 +00:00
esac
}
2017-12-15 11:01:42 +00:00
2022-05-23 11:37:09 +00:00
fmt() {
[ -f .clang-format ] && {
find src -type f -name '*.[ch]' -print | xargs -d '\n' clang-format -i
return
}
[ -f Cargo.toml ] && {
cargo fmt
return
}
}
2017-12-15 11:01:42 +00:00
__prompt() {
case $? in
2021-06-03 15:33:38 +00:00
0) PS1='\[\e[34m\]' ;;
*) PS1='\[\e[31m\]' ;;
2017-12-15 11:01:42 +00:00
esac
2021-10-25 17:30:54 +00:00
if [[ "$PWD" == "$HOME" ]]; then
2021-06-03 15:33:38 +00:00
PS1+='~'
2021-10-25 17:30:54 +00:00
elif [[ "$PWD" == / ]]; then
PS1+=/
2021-06-03 15:33:38 +00:00
else
PS1+="${PWD##*/}"
fi
2021-06-03 15:04:33 +00:00
2021-06-03 15:33:38 +00:00
PS1+='\[\e[0m\] '
}
PROMPT_COMMAND="__prompt;$PROMPT_COMMAND"
2022-05-02 08:25:42 +00:00
. "$HOME/.cargo/env"
eval "$(direnv hook bash)"
2022-05-23 11:37:09 +00:00
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
head -n 10 ~/todo/todo