fixed profile tabs

This commit is contained in:
levasseur
2021-09-22 17:11:42 +02:00
parent 6f27a126a7
commit d8ed68edcb

View File

@@ -1,23 +1,23 @@
#!/bin/bash #!/bin/bash
# Begin profile # Begin profile
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Initial version from Beyond Linux From Scratch by # Initial version from Beyond Linux From Scratch by
# * James Robertson <jameswrobertson@earthlink.net> # * James Robertson <jameswrobertson@earthlink.net>
# * Dagmar d'Surreal <rivyqntzne@pbzpnfg.arg> # * Dagmar d'Surreal <rivyqntzne@pbzpnfg.arg>
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Current version from Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Current version from Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# 16/02/2013 Version 1.0.0 : Initial version # 16/02/2013 Version 1.0.0 : Initial version
# 24/10/2015 Version 2.0.0 : Added some advanced functionnalities (clean, srr, etc.) # 24/10/2015 Version 2.0.0 : Added advanced functionnalities (clean, srr, etc.)
# 04/02/2017 Version 2.0.1 : clean improvements (--shell) # 04/02/2017 Version 2.0.1 : clean improvements (--shell)
# 16/09/2018 Version 2.1.0 : Added rmhost, setc, setfr, review of locales management # 16/09/2018 Version 2.1.0 : Added rmhost, setc, setfr, more locales management
# 23/09/2019 Version 2.1.1 : [bugfix] dpkgs # 23/09/2019 Version 2.1.1 : [bugfix] dpkgs
# 24/09/2019 Version 2.1.2 : [bugfix] bug in profile version display # 24/09/2019 Version 2.1.2 : [bugfix] bug in profile version display
# 16/12/2019 Version 2.2.0 : Added showinfo, primary write of showdiskmap (to be finished) # 16/12/2019 Version 2.2.0 : Added showinfo, primary write of showdiskmap
# 08/01/2020 Version 2.3.0 : Added use of figlet and neofetch as an equivalent to motd # 08/01/2020 Version 2.3.0 : Added use of figlet and neofetch as a motd replace
# 16/01/2020 Version 2.3.1 : [bugfix] non-interactive mode were blocked with some functions # 16/01/2020 Version 2.3.1 : [bugfix] non-interactive were blocked with some functions
# 31/01/2020 Version 2.3.2 : Figlet : changed default font to ansi_shadow # 31/01/2020 Version 2.3.2 : Figlet: changed default font to ansi_shadow
# 02/03/2020 Version 2.4.0 : Added command auzip # 02/03/2020 Version 2.4.0 : Added command auzip
# 03/03/2020 Version 2.5.0 : Added command taz and rmspc, auzip renamed utaz and improved # 03/03/2020 Version 2.5.0 : Added command taz and rmspc, auzip->utaz improved
# 05/03/2020 Version 2.5.1 : Language consistancy fix, added pigz support in taz # 05/03/2020 Version 2.5.1 : Language consistancy fix, added pigz support in taz
# 06/03/2020 Version 2.5.2 : Few aliases sorted out # 06/03/2020 Version 2.5.2 : Few aliases sorted out
# 11/09/2020 Version 2.5.3 : Few more aliases, improved code consistancy and typo, # 11/09/2020 Version 2.5.3 : Few more aliases, improved code consistancy and typo,
@@ -26,7 +26,7 @@
# 24/10/2020 Version 2.6.0 : Added session save and restore for Konsole # 24/10/2020 Version 2.6.0 : Added session save and restore for Konsole
# 25/12/2020 Version 2.6.1 : Add check on rmhost, improvements rmspc, created expendlist # 25/12/2020 Version 2.6.1 : Add check on rmhost, improvements rmspc, created expendlist
# 26/02/2021 Version 2.6.2 : taz: corrected bug with trailing slash on directories # 26/02/2021 Version 2.6.2 : taz: corrected bug with trailing slash on directories
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Copyright (c) 2013-2020 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2013-2020 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# Protected by the BSD3 license. Please read bellow for details. # Protected by the BSD3 license. Please read bellow for details.
# #
@@ -59,15 +59,15 @@
# * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# * OF SUCH DAMAGE. # * OF SUCH DAMAGE.
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
export PROFVERSION="2.6.1" export PROFVERSION="2.6.2"
export DEFAULT_CITY="Toulouse" export DEFAULT_CITY="Toulouse"
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# path* : private functions for PATH variable management # path* : private functions for PATH variable management
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
pathremove () pathremove ()
{ {
local ifs=':' local ifs=':'
@@ -96,9 +96,9 @@ pathappend ()
export $pathvar="${!pathvar:+${!pathvar}:}$1" export $pathvar="${!pathvar:+${!pathvar}:}$1"
} }
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# expandlist : treat wildcards in a file/directory list # expandlist : treat wildcards in a file/directory list
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
expandlist() expandlist()
{ {
local result="" local result=""
@@ -110,9 +110,9 @@ expandlist()
echo $result echo $result
} }
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# timer_* functions : internal timing function for prompt # timer_* functions : internal timing function for prompt
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
function timer_now function timer_now
{ {
date +%s%N date +%s%N
@@ -132,20 +132,27 @@ function timer_stop
local m=$(((delta_us / 60000000) % 60)) local m=$(((delta_us / 60000000) % 60))
local h=$((delta_us / 3600000000)) local h=$((delta_us / 3600000000))
# Goal: always show around 3 digits of accuracy # Goal: always show around 3 digits of accuracy
if ((h > 0)); then timer_show=${h}h${m}m if ((h > 0)); then
elif ((m > 0)); then timer_show=${m}m${s}s timer_show=${h}h${m}m
elif ((s >= 10)); then timer_show=${s}.$((ms / 100))s elif ((m > 0)); then
elif ((s > 0)); then timer_show=${s}.$(printf %03d $ms)s timer_show=${m}m${s}s
elif ((ms >= 100)); then timer_show=${ms}ms elif ((s >= 10)); then
elif ((ms > 0)); then timer_show=${ms}.$((us / 100))ms timer_show=${s}.$((ms / 100))s
else timer_show=${us}us elif ((s > 0)); then
timer_show=${s}.$(printf %03d $ms)s
elif ((ms >= 100)); then
timer_show=${ms}ms
elif ((ms > 0)); then
timer_show=${ms}.$((us / 100))ms
else
timer_show=${us}us
fi fi
unset timer_start unset timer_start
} }
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Function triguered internaly by bash : defining prompt # Function triguered internaly by bash : defining prompt
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
set_prompt () set_prompt ()
{ {
Last_Command=$? # Must come first! Last_Command=$? # Must come first!
@@ -193,17 +200,18 @@ set_prompt ()
PS1+="$ICyan\\w \\\$$Default " PS1+="$ICyan\\w \\\$$Default "
} }
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Show profile version # Show profile version
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
ver () ver ()
{ {
echo "Profile version $PROFVERSION." echo "Profile version $PROFVERSION."
} }
export ver export ver
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Change locale to French # Change locale to French
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
setfr () setfr ()
{ {
# Set fr locale definitions # Set fr locale definitions
@@ -213,9 +221,9 @@ setfr ()
} }
export setfr export setfr
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Change locale to C standard # Change locale to C standard
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
setc () setc ()
{ {
# Locale definitions # Locale definitions
@@ -225,9 +233,9 @@ setc ()
} }
export setc export setc
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Change locale to US (needed by Steam) # Change locale to US (needed by Steam)
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
setus () setus ()
{ {
# Locale definitions # Locale definitions
@@ -237,9 +245,9 @@ setus ()
} }
export setc export setc
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Display weather of the given city (or default one) # Display weather of the given city (or default one)
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
meteo () meteo ()
{ {
cities=$@ cities=$@
@@ -251,9 +259,9 @@ meteo ()
} }
export meteo export meteo
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Clean a directory or a tree from temporary or backup files # Clean a directory or a tree from temporary or backup files
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
clean () clean ()
{ {
for opt in $@ ; do for opt in $@ ; do
@@ -263,11 +271,11 @@ clean ()
;; ;;
"-h"|"--help") "-h"|"--help")
echo "clean : erase backup files in the given directories." echo "clean: erase backup files in the given directories."
echo echo
echo "Usage : clean [option] [directory1] [...[directoryX]]" echo "Usage: clean [option] [directory1] [...[directoryX]]"
echo echo
echo "Options :" echo "Options:"
echo " -h, --help Display that help screen" echo " -h, --help Display that help screen"
echo " -r, --recurs Do a recursive cleaning" echo " -r, --recurs Do a recursive cleaning"
echo " -f, --force Do not ask for confirmation (use with care)" echo " -f, --force Do not ask for confirmation (use with care)"
@@ -303,7 +311,8 @@ clean ()
unset recursive force unset recursive force
for dir in $dirlist; do for dir in $dirlist; do
local dellist=$(find $dir $findopt -type f -name "*~" -o -name "#*#" -o -name "*.bak" -o -name ".~*#") local dellist=$(find $dir $findopt -type f -name "*~" -o -name "#*#" \
-o -name "*.bak" -o -name ".~*#")
for f in $dellist; do for f in $dellist; do
if [[ ! $outshell ]]; then if [[ ! $outshell ]]; then
rm $rmopt $f rm $rmopt $f
@@ -316,9 +325,9 @@ clean ()
} }
export clean export clean
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Login root via SSH on the given machine # Login root via SSH on the given machine
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
ssr () ssr ()
{ {
for opt in $@ ; do for opt in $@ ; do
@@ -326,7 +335,7 @@ ssr ()
"-h"|"--help") "-h"|"--help")
echo "ssr: do a root user ssh login." echo "ssr: do a root user ssh login."
echo echo
echo "Usage : ssr <server [ssh options]>" echo "Usage: ssr <server [ssh options]>"
return 0 return 0
;; ;;
esac esac
@@ -337,7 +346,7 @@ ssr ()
local srv=$1 && shift local srv=$1 && shift
ssh -x root@$srv $@ ssh -y root@$srv $@
} }
export ssr export ssr
@@ -394,7 +403,7 @@ export ppg
mcd () { mcd () {
if [[ ! $# -eq 1 ]] ; then if [[ ! $# -eq 1 ]] ; then
echo "Create a directory then goes inside." echo "Create a directory then goes inside."
echo "Usage : mcd <directory>" echo "Usage: mcd <directory>"
return 1 return 1
fi fi
mkdir -pv $1 && cd $1 mkdir -pv $1 && cd $1
@@ -447,11 +456,11 @@ rmspc () {
for opt in $@ ; do for opt in $@ ; do
case $opt in case $opt in
"-h"|"--help") "-h"|"--help")
echo "rmspc : remove spaces from all filenames in current directories" echo "rmspc: remove spaces from all filenames in current directories"
echo echo
echo "Usage : rmspc [option]" echo "Usage: rmspc [option]"
echo echo
echo "Options :" echo "Options:"
echo " -h, --help Display that help screen" echo " -h, --help Display that help screen"
echo " -r, --recursive Treat subdiretories of the given directories" echo " -r, --recursive Treat subdiretories of the given directories"
echo " -c, --subst-char Change the replacement character (default is underscore)" echo " -c, --subst-char Change the replacement character (default is underscore)"
@@ -519,12 +528,12 @@ utaz()
for opt in $@ ; do for opt in $@ ; do
case $opt in case $opt in
"-h"|"--help") "-h"|"--help")
echo "utaz : uncompress all the given files and/or the ones found in the given" echo "utaz: uncompress all the given files and/or the ones found in the given"
echo " directories creating an host directory where needed." echo " directories creating an host directory where needed."
echo echo
echo "Usage : utaz [option] [directorie(s)|file(s)]" echo "Usage: utaz [option] [directorie(s)|file(s)]"
echo echo
echo "Options :" echo "Options:"
echo " -h, --help Display that help screen" echo " -h, --help Display that help screen"
echo " -d, --delete If decompression success, delete the source file" echo " -d, --delete If decompression success, delete the source file"
echo " -c, --create-dir Always create a host directory" echo " -c, --create-dir Always create a host directory"
@@ -649,7 +658,7 @@ taz()
local procopt="" local procopt=""
[[ $2 -gt 1 ]] && [[ $2 -gt 1 ]] &&
echo -e "\t! Warning: lzip doesn't support multithreading, falling back to 1 thread." && echo -e "\t! Warning: lzip doesn't support multithreading, falling back to 1 thread." &&
exho -e "\t* Consitder installing plzip to obtain multithreading abilities." echo -e "\t* Consitder installing plzip to obtain multithreading abilities."
} }
[[ $4 ]] && local verb="-vv" [[ $4 ]] && local verb="-vv"
@@ -673,7 +682,7 @@ taz()
local procopt="" local procopt=""
[[ $2 -gt 1 ]] && [[ $2 -gt 1 ]] &&
echo -e "\t! Warning: gzip doesn't support multithreading, falling back to 1 thread." && echo -e "\t! Warning: gzip doesn't support multithreading, falling back to 1 thread." &&
exho -e "\t* Consitder installing pigz to obtain multithreading abilities." echo -e "\t* Consitder installing pigz to obtain multithreading abilities."
} }
[[ $4 ]] && local verb="--verbose" [[ $4 ]] && local verb="--verbose"
@@ -697,7 +706,7 @@ taz()
local procopt="" local procopt=""
[[ $2 -gt 1 ]] && [[ $2 -gt 1 ]] &&
echo -e "\t! Warning: bzip2 doesn't support multithreading, falling back to 1 thread." && echo -e "\t! Warning: bzip2 doesn't support multithreading, falling back to 1 thread." &&
exho -e "\t* Consitder installing pbzip2 to obtain multithreading abilities." echo -e "\t* Consitder installing pbzip2 to obtain multithreading abilities."
} }
[[ $4 ]] && local verb="-v" [[ $4 ]] && local verb="-v"
@@ -832,7 +841,6 @@ taz()
echo "--- Done" echo "--- Done"
done done
} }
export taz export taz
@@ -885,7 +893,6 @@ ksession() {
fi fi
done done
fi fi
else else
echo "ksession: save and restore KDE's Konsole sessions" echo "ksession: save and restore KDE's Konsole sessions"
echo echo
@@ -895,11 +902,11 @@ ksession() {
export ksession export ksession
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# **************************************** MAIN PROGRAM ************************************ # ********************************** MAIN PROGRAM ******************************
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Former PS1, stopped for much better function # Former PS1, stopped for much better function
# Set the prompt look'n'feel # Set the prompt look'n'feel