Initial commit

This commit is contained in:
2026-01-21 14:52:43 +01:00
committed by GianLuca Vagnuzzi
commit d1f1a1de70
2 changed files with 104 additions and 0 deletions

3
README.md Normal file
View File

@@ -0,0 +1,3 @@
# zzzz-profile
A custom profile.sh

101
zzzz-profile.sh Executable file
View File

@@ -0,0 +1,101 @@
export EDITOR="vim"
export LC_CTYPE=it_IT.UTF-8
export LANG=it_IT.UTF-8
HISTTIMEFORMAT="%d/%m/%y %T "
HISTSIZE=1000000
HISTFILESIZE=2000000
# HISTCONTROL
# ignorespace = lines which begin with a space character are not saved in the history list.
# ignoredups = causes lines matching the previous history entry to not be saved (default)
# ignoreboth = shorthand for ignorespace and ignoredups.
HISTCONTROL=ignoreboth
alias iftop="iftop -n -N -P"
alias ping8="ping 8.8.8.8"
alias pingw="ping www.google.it"
alias ll="ls -l"
alias myip="curl -4 ifconfig.io"
alias df="df -x tmpfs -x overlay"
alias dd="dd bs=4M status=progress conv=fsync"
# custom prompt PS1
# obtain domain from resolv.conf
domain_full="$(cat /etc/resolv.conf | grep ^search | cut -d" " -f2)"
# set only 2nd level domain
domain="${domain_full%%.*}"
# if domain is null, set nodomain
[[ -z $domain ]] && domain="nodomain"
# randomize path color
#clrs_nbrs="90 91 92 93 94 95 96 97"
#rnd_nbr=$(shuf -e ${clrs_nbrs} -n 1)
rnd_nbr=$((RANDOM % 8 + 90))
case "$TERM" in
xterm-color|*-256color)
color_prompt=yes
if [ "$(id -u)" -eq 0 ]; then
# hostRED.domainRANDOM pathGREY
export PS1="\[\e[35m\][\[\e[31m\]\h\[\e[35m\].\[\e[${rnd_nbr}m\]${domain} \[\e[90m\]\W\[\e[35m\]]\[\e[31m\] >\[\e[m\] "
# domainRED pathRANDOM
#export PS1="\[\e[35m\][\[\e[31m\]${domain} \[\e[${rnd_nbr}m\]\w\[\e[35m\]]\[\e[31m\] >\[\e[m\] "
else
# userGREEN@hostORANGE.domainRANDOM pathGREY
export PS1="\[\e[35m\][\[\e[32m\]\u\[\e[35m\]@\[\e[33m\]\h\[\e[35m\].\[\e[33m\]${domain} \[\e[90m\]\W\[\e[35m\]]\[\e[32m\] >\[\e[m\] "
# domainGREEN pathRANDOM
#export PS1="\[\e[35m\][\[\e[32m\]${domain} \[\e[${rnd_nbr}m\]\w\[\e[35m\]]\[\e[32m\] >\[\e[m\] "
fi
;;
esac
# Change the window title of X terminals
case ${TERM} in
xterm*|rxvt*|Eterm*|aterm|kterm|gnome*|interix|konsole*)
PROMPT_COMMAND="echo -ne \"\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007\""
;;
screen*)
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\033\\"'
;;
esac
## add personal setting to ~/.vimrc
[[ ! -e ~/.vimrc ]] && touch ~/.vimrc
grep -q "syntax on" ~/.vimrc || echo "syntax on" >> ~/.vimrc
grep -q "backspace" ~/.vimrc || echo "set backspace=indent,eol,start" >> ~/.vimrc
## add ~/.screenrc & "startup_message off" if not present:
[[ ! -e ~/.screenrc ]] && touch ~/.screenrc
grep -q "startup_message off" ~/.screenrc || echo "startup_message off" >> ~/.screenrc
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
function ex {
if [ -f "$1" ] ; then
case "$1" in
*.tar.bz2) tar xjf "$1" ;;
*.tar.gz) tar xzf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) unrar x "$1" ;;
*.gz) gunzip "$1" ;;
*.tar) tar xf "$1" ;;
*.tbz2) tar xjf "$1" ;;
*.tgz) tar xzf "$1" ;;
*.zip) unzip "$1" ;;
*.Z) uncompress "$1" ;;
*.7z) 7z x "$1" ;;
*.tar.xz) tar --xz -xf "$1" ;;
*.xz) unxz "$1" ;;
*) echo "'$1' cannot be extracted via ex()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}