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

111 lines
2.3 KiB
Bash
Raw Normal View History

2022-01-25 09:22:12 +01:00
# 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
2022-01-25 12:49:18 +01:00
# Shell customization
[[ -z $ZIO_SHELL_CARET ]] && ZIO_SHELL_CARET="➜ "
2022-01-25 12:49:18 +01:00
# Bash options
2022-01-25 09:22:12 +01:00
HISTCONTROL=ignoreboth
# Helpers
function color() {
code=$1
style=$2
[[ -z $style ]] && style="0"
if [[ -z $code ]]; then
2022-01-25 11:20:46 +01:00
echo "\033[0m"
2022-01-25 09:22:12 +01:00
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)"
2022-01-25 09:22:12 +01:00
else
echo -e " 👋 Hello $(color 33 1)$USER$(color), I am $(color 33 1)$(hostname -f)$(color)."
2022-01-25 09:22:12 +01:00
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
2022-01-25 12:49:18 +01:00
# less: make friendly for non-text input files
2022-01-25 09:22:12 +01:00
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
2022-01-25 12:49:18 +01:00
# ls: color support
2022-01-25 09:22:12 +01:00
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
2022-01-25 12:49:18 +01:00
# Prompt
2022-01-25 09:22:12 +01:00
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)\] "
2022-01-25 09:22:12 +01:00
else
2022-01-25 11:20:46 +01:00
PS1="\h:\W > "
2022-01-25 09:22:12 +01:00
fi
2022-01-25 12:49:18 +01:00
# Aliases
2022-01-25 09:22:12 +01:00
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
2022-01-25 12:49:18 +01:00
# Completions
2022-01-25 09:22:12 +01:00
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!
2022-01-25 13:31:44 +01:00
if [[ -z $SUDO_USER ]]; then
clear
print_header
fi
update_bashrc