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
# Begin profile
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Initial version from Beyond Linux From Scratch by
# * James Robertson <jameswrobertson@earthlink.net>
# * Dagmar d'Surreal <rivyqntzne@pbzpnfg.arg>
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Current version from Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# 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)
# 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
# 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)
# 08/01/2020 Version 2.3.0 : Added use of figlet and neofetch as an equivalent to motd
# 16/01/2020 Version 2.3.1 : [bugfix] non-interactive mode were blocked with some functions
# 31/01/2020 Version 2.3.2 : Figlet : changed default font to ansi_shadow
# 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 a motd replace
# 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
# 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
# 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,
@@ -26,7 +26,7 @@
# 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
# 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>
# Protected by the BSD3 license. Please read bellow for details.
#
@@ -59,15 +59,15 @@
# * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# * OF SUCH DAMAGE.
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
export PROFVERSION="2.6.1"
export PROFVERSION="2.6.2"
export DEFAULT_CITY="Toulouse"
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# path* : private functions for PATH variable management
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
pathremove ()
{
local ifs=':'
@@ -96,9 +96,9 @@ pathappend ()
export $pathvar="${!pathvar:+${!pathvar}:}$1"
}
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# expandlist : treat wildcards in a file/directory list
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
expandlist()
{
local result=""
@@ -110,9 +110,9 @@ expandlist()
echo $result
}
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# timer_* functions : internal timing function for prompt
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
function timer_now
{
date +%s%N
@@ -132,20 +132,27 @@ function timer_stop
local m=$(((delta_us / 60000000) % 60))
local h=$((delta_us / 3600000000))
# Goal: always show around 3 digits of accuracy
if ((h > 0)); then timer_show=${h}h${m}m
elif ((m > 0)); then timer_show=${m}m${s}s
elif ((s >= 10)); then timer_show=${s}.$((ms / 100))s
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
if ((h > 0)); then
timer_show=${h}h${m}m
elif ((m > 0)); then
timer_show=${m}m${s}s
elif ((s >= 10)); then
timer_show=${s}.$((ms / 100))s
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
unset timer_start
}
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Function triguered internaly by bash : defining prompt
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
set_prompt ()
{
Last_Command=$? # Must come first!
@@ -193,17 +200,18 @@ set_prompt ()
PS1+="$ICyan\\w \\\$$Default "
}
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Show profile version
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
ver ()
{
echo "Profile version $PROFVERSION."
}
export ver
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Change locale to French
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
setfr ()
{
# Set fr locale definitions
@@ -213,9 +221,9 @@ setfr ()
}
export setfr
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Change locale to C standard
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
setc ()
{
# Locale definitions
@@ -225,9 +233,9 @@ setc ()
}
export setc
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Change locale to US (needed by Steam)
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
setus ()
{
# Locale definitions
@@ -237,9 +245,9 @@ setus ()
}
export setc
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Display weather of the given city (or default one)
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
meteo ()
{
cities=$@
@@ -251,9 +259,9 @@ meteo ()
}
export meteo
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Clean a directory or a tree from temporary or backup files
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
clean ()
{
for opt in $@ ; do
@@ -263,11 +271,11 @@ clean ()
;;
"-h"|"--help")
echo "clean : erase backup files in the given directories."
echo "clean: erase backup files in the given directories."
echo
echo "Usage : clean [option] [directory1] [...[directoryX]]"
echo "Usage: clean [option] [directory1] [...[directoryX]]"
echo
echo "Options :"
echo "Options:"
echo " -h, --help Display that help screen"
echo " -r, --recurs Do a recursive cleaning"
echo " -f, --force Do not ask for confirmation (use with care)"
@@ -303,7 +311,8 @@ clean ()
unset recursive force
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
if [[ ! $outshell ]]; then
rm $rmopt $f
@@ -316,9 +325,9 @@ clean ()
}
export clean
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Login root via SSH on the given machine
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
ssr ()
{
for opt in $@ ; do
@@ -326,7 +335,7 @@ ssr ()
"-h"|"--help")
echo "ssr: do a root user ssh login."
echo
echo "Usage : ssr <server [ssh options]>"
echo "Usage: ssr <server [ssh options]>"
return 0
;;
esac
@@ -337,7 +346,7 @@ ssr ()
local srv=$1 && shift
ssh -x root@$srv $@
ssh -y root@$srv $@
}
export ssr
@@ -394,7 +403,7 @@ export ppg
mcd () {
if [[ ! $# -eq 1 ]] ; then
echo "Create a directory then goes inside."
echo "Usage : mcd <directory>"
echo "Usage: mcd <directory>"
return 1
fi
mkdir -pv $1 && cd $1
@@ -447,11 +456,11 @@ rmspc () {
for opt in $@ ; do
case $opt in
"-h"|"--help")
echo "rmspc : remove spaces from all filenames in current directories"
echo "rmspc: remove spaces from all filenames in current directories"
echo
echo "Usage : rmspc [option]"
echo "Usage: rmspc [option]"
echo
echo "Options :"
echo "Options:"
echo " -h, --help Display that help screen"
echo " -r, --recursive Treat subdiretories of the given directories"
echo " -c, --subst-char Change the replacement character (default is underscore)"
@@ -519,12 +528,12 @@ utaz()
for opt in $@ ; do
case $opt in
"-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
echo "Usage : utaz [option] [directorie(s)|file(s)]"
echo "Usage: utaz [option] [directorie(s)|file(s)]"
echo
echo "Options :"
echo "Options:"
echo " -h, --help Display that help screen"
echo " -d, --delete If decompression success, delete the source file"
echo " -c, --create-dir Always create a host directory"
@@ -649,7 +658,7 @@ taz()
local procopt=""
[[ $2 -gt 1 ]] &&
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"
@@ -673,7 +682,7 @@ taz()
local procopt=""
[[ $2 -gt 1 ]] &&
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"
@@ -697,7 +706,7 @@ taz()
local procopt=""
[[ $2 -gt 1 ]] &&
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"
@@ -832,7 +841,6 @@ taz()
echo "--- Done"
done
}
export taz
@@ -885,7 +893,6 @@ ksession() {
fi
done
fi
else
echo "ksession: save and restore KDE's Konsole sessions"
echo
@@ -895,11 +902,11 @@ ksession() {
export ksession
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------
# **************************************** MAIN PROGRAM ************************************
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# ********************************** MAIN PROGRAM ******************************
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Former PS1, stopped for much better function
# Set the prompt look'n'feel