2
0
Fork 0
rootfs/etc/skel/.bashrc

119 lines
2.5 KiB
Bash

# DO NOT EDIT THIS FILE!
#
# Everytime this is sourced, a new version is pulled from /etc/skel/.bashrc,
# rendering any changes you make here overwritten the next time you launch Bash.
#
# Put any extra aliases, functions, or other mess into ~/.bash_aliases.
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# Shell customization
if [[ -z $ZIO_SHELL_CARET ]]; then
if [[ $SUDO_USER == "astra" ]] || [[ $USER == "astra" ]]; then
ZIO_SHELL_CARET="$"
else
ZIO_SHELL_CARET="➜ "
fi
fi
# Bash options
HISTCONTROL=ignoreboth
# Helpers
function color() {
code=$1
style=$2
[[ -z $style ]] && style="0"
if [[ -z $code ]]; then
echo "\033[0m"
else
echo "\033[0${style};${code}m"
fi
}
function get_caret_color() {
caret_color_code="36"
[[ $USER == "root" ]] && caret_color_code="31"
echo "$caret_color_code"
}
function print_header() {
echo -e "$(color 31 1) ______
|__ (_) ___
/ /| |/ _ \\
/ /_| | (_) |
/____|_|\\___/$(color)"
echo " "
if [[ $USER == "root" ]]; then
echo -e "$(color 33 1) 🔥 Here be dragons.$(color)"
else
echo -e " 👋 Hello $(color 33 1)$USER$(color), I am $(color 33 1)$(hostname -f)$(color)."
fi
echo " "
}
function update_bashrc() {
cp -f /etc/skel/.bashrc ~/.bashrc
}
# A dash of color?
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# less: make friendly for non-text input files
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# ls: color support
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# Prompt
if [ "$color_prompt" = yes ]; then
PS1="\[$(color 32 1)\]\h\[$(color 37)\]:\[$(color 32 1)\]\W\[$(color 37)\] \[$(color $(get_caret_color))\]$ZIO_SHELL_CARET\[$(color)\] "
else
PS1="\h:\W > "
fi
# Aliases
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# Completions
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
# Hello, world!
if [[ -z $SUDO_USER ]]; then
clear
print_header
fi
if [[ $UID != 0 ]]; then
update_bashrc
fi