dotfiles-server/.bashrc

101 lines
2 KiB
Bash
Raw Permalink Normal View History

2024-07-24 03:43:21 -04:00
case $- in
*i*) ;;
*) return ;;
2024-07-24 03:43:21 -04:00
esac
2024-07-24 04:13:14 -04:00
# Shell options
shopt -s dotglob
shopt -s nocaseglob
shopt -s autocd
shopt -s cdspell
shopt -s histappend
shopt -s histverify
2024-07-24 03:43:21 -04:00
# Default options
alias ls='ls --color=auto -AF'
alias grep='grep --color=auto'
2024-07-24 15:57:46 -04:00
alias wget='wget --no-hsts'
2024-07-24 03:43:21 -04:00
# Shorthands
alias l='ls'
alias c='cd'
alias v='vim'
2024-07-24 15:57:46 -04:00
alias d='docker'
alias ff='fastfetch'
2024-07-24 15:57:46 -04:00
alias g='git'
2024-07-24 03:43:21 -04:00
# Corrections
alias nvim='vim'
2024-07-24 15:57:46 -04:00
# Other options and commands
2024-07-24 03:43:21 -04:00
alias ll='ls -l'
alias gf='git config'
2024-07-24 15:57:46 -04:00
alias ga='git add'
alias gs='git status'
2024-07-24 15:57:46 -04:00
alias gc='git commit'
alias gp='git push'
2024-07-24 15:59:02 -04:00
alias gl='git pull'
alias gd='git diff'
2024-07-24 15:57:46 -04:00
alias dc='docker compose'
# Common files and directories
alias M='cd ~/compose'
alias D='cd ~/dotfiles'
alias S='cd ~/.ssh'
C() {
case "$HOSTNAME" in
blizzard) cd ~/compose/caddy ;;
*) printf '%s' "Did you mean to be on blizzard?" ;;
2024-07-24 15:57:46 -04:00
esac
}
alias R='vim ~/.bashrc'
alias P='vim ~/.bash_profile'
alias V='vim ~/.vim/vimrc'
alias G='vim ~/.gitconfig'
2024-07-24 03:43:21 -04:00
# List files on 'cd'
cd() {
builtin cd "$@" && ls
2024-07-24 03:43:21 -04:00
}
# Prompt
parse_git_dirty() {
2024-07-24 15:29:18 -04:00
[ -n "$(git status --porcelain 2>/dev/null)" ] && printf "*"
2024-07-24 03:43:21 -04:00
}
parse_git_branch() {
2024-07-24 15:57:46 -04:00
command -v git >/dev/null 2>&1 || return
while IFS= read -r line; do
[ -z "$line" ] && return
printf '%s' " (${line#* }$(parse_git_dirty))"
done <<EOF
$(git branch --no-color 2>/dev/null)
EOF
2024-07-24 03:43:21 -04:00
}
export PS1="\n\[\e[36m\]\t\[\e[m\] \[\e[31m\]\h\[\e[m\] \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
2024-07-24 15:57:46 -04:00
# Startup screen
case "$HOSTNAME" in
blizzard)
printf '%s' "\
_ _ _ _
| |__ | (_)__________ _ _ __ __| |
| '_ \\| | |_ /_ / _\` | '__/ _\` |
| |_) | | |/ / / / (_| | | | (_| |
|_.__/|_|_/___/___\\__,_|_| \\__,_|
"
;;
glacier)
printf '%s' "\
_ _
__ _| | __ _ ___(_) ___ _ __
/ _\` | |/ _\` |/ __| |/ _ \\ '__|
| (_| | | (_| | (__| | __/ |
\\__, |_|\\__,_|\\___|_|\\___|_|
|___/
"
;;
esac