From c0e15e7e2a465d7e7cdf0037bdd6b9ee12ac2b84 Mon Sep 17 00:00:00 2001 From: levasseur Date: Mon, 18 Oct 2021 18:48:54 +0200 Subject: [PATCH] improved profile to 2.6.3 --- repo/common/profile | 103 ++++++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 47 deletions(-) diff --git a/repo/common/profile b/repo/common/profile index be68da7..74754d3 100644 --- a/repo/common/profile +++ b/repo/common/profile @@ -17,15 +17,18 @@ # 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->utaz 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, -# : improved utaz, removed showdiskmap, removed remaining French, -# : added license information for future publication +# : improved utaz, removed showdiskmap +# : removed remaining French, +# : added license information for future publication # 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 +# 18/10/2021 Version 2.6.3 : changed PS1 for status bar style version +# few minor improvements # ------------------------------------------------------------------------------ # Copyright (c) 2013-2020 Geoffray Levasseur # Protected by the BSD3 license. Please read bellow for details. @@ -61,7 +64,7 @@ # * OF SUCH DAMAGE. # ------------------------------------------------------------------------------ -export PROFVERSION="2.6.2" +export PROFVERSION="2.6.3" export DEFAULT_CITY="Toulouse" @@ -170,31 +173,32 @@ set_prompt () Checkmark='\342\234\223' # Begin with time - PS1="$Blue$OnGrey[ \t ]$Default " + PS1="\[\e[s\e[1;1H$Blue$OnGrey [ \t ] $OnBlue" # Add a bright white exit status for the last command # If it was successful, print a green check mark. Otherwise, print # a red X. if [[ $Last_Command == 0 ]]; then - PS1+="$White$OnBlue[ \$Last_Command " + PS1+="$White$OnBlue [ \$Last_Command " PS1+="$Green$Checkmark " else - PS1+="$White$OnRed[ \$Last_Command " + PS1+="$White$OnRed [ \$Last_Command " PS1+="$Yellow$FancyX " fi # Add the ellapsed time and current date timer_stop - PS1+="($timer_show)$White ]$Default " + PS1+="($timer_show)$White ] $OnBlue " # If root, just print the host in red. Otherwise, print the current user # and host in green. if [[ $EUID -eq 0 ]]; then - PS1+="$Red\\u$Green@\\h " + PS1+="$Red\\u$Green@\\h" else - PS1+="$Green\\u@\\h " + PS1+="$Green\\u@\\h" fi + PS1+="\e[K\e[u$Default" # Print the working directory and prompt marker in blue, and reset # the text color to the default. PS1+="$ICyan\\w \\\$$Default " @@ -208,7 +212,6 @@ ver () echo "Profile version $PROFVERSION." } export ver - # ------------------------------------------------------------------------------ # Change locale to French # ------------------------------------------------------------------------------ @@ -337,22 +340,23 @@ ssr () echo echo "Usage: ssr " return 0 - ;; + ;; esac done [[ ! $1 ]] && - echo "Please specify the server you want to log in." && return 1 + echo "Please specify the server you want to log in." && + return 1 local srv=$1 && shift - ssh -y root@$srv $@ + ssh -Y root@$srv $@ } export ssr -# ------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ # Look for a package within installed one -# ------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ dpkgs () { local count=0 @@ -375,31 +379,36 @@ dpkgs () local pkg=$1 && shift count=$(( $count + 1 )) [[ $count -gt 1 ]] && - echo "*** Error: Please specify a package name, without space, eventually partial." && return 1 - + echo "*** Error: Please specify a package name, without space, eventually partial." && + return 1 + ;; esac done - [[ $count -lt 1 ]] && echo "*** Error: Please specify a package name, without space, eventually partial." && return 1 + [[ $count -lt 1 ]] && + echo "*** Error: Please specify a package name, without space, eventually partial." && + return 1 - [[ -x /usr/sbin/dpkg ]] && "*** Error: dpkg command seems unavialable." && return 2 + [[ -x /usr/sbin/dpkg ]] && + echo "*** Error: dpkg command seems unavialable." && + return 2 dpkg -l | grep $pkg } export dpkgs -# ------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ # Search processes matching the given string -# ------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ ppg () { ps -edf | grep $@ | grep -v "grep $@" } export ppg -# ------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ # Create a directory then goes inside -# ------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ mcd () { if [[ ! $# -eq 1 ]] ; then echo "Create a directory then goes inside." @@ -410,9 +419,9 @@ mcd () { } export mcd -# ------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ # Get PID list of the given process name -# ------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ gpid () { [[ $# -eq 1 ]] && local single=1 for pid in $@; do @@ -427,9 +436,9 @@ gpid () { } export gpid -# ------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ # Remove host from know_host (name and IP) for the active user -# ------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ rmhost () { if [[ "$#" -ne 1 ]]; then echo "Error: incorrect number of parameters." @@ -448,9 +457,9 @@ rmhost () { } export rmhost -# ------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ # Rename all files in current directory to replace spaces with _ -# ------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ rmspc () { local lst="" for opt in $@ ; do @@ -520,9 +529,9 @@ rmspc () { } export rmspc -# ------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ # Smartly uncompress archives (zip only) -# ------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ utaz() { for opt in $@ ; do @@ -621,9 +630,9 @@ utaz() } export utaz -# ------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ # Compress directories or files into one or more archive -# ------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ taz() { _doxz() @@ -667,7 +676,7 @@ taz() $command $verb $procopt --keep -$3 $1 return $? } - + _dogz() { local procopt="--processes $2" @@ -734,7 +743,7 @@ taz() for opt in $@ ; do case $opt in "-h"|"--help") - echo "taz : archive all files of a directory." + echo "taz: archive all files of a directory." echo echo "Usage: taz [option] [--parallel=] [--format=] [directory1 ... directoryN]" echo @@ -791,7 +800,7 @@ taz() ;; esac done - + [[ ! $compform ]] && compform=lz # safe and efficient (unless data are already compressed) [[ ! $nproc ]] && nproc=1 [[ ! $complevel ]] && complevel=6 @@ -841,12 +850,13 @@ taz() echo "--- Done" done + } export taz -# ------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ # Display system genal information -# ------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ showinfo() { echo "" figlet $(hostname) -t -k @@ -855,23 +865,21 @@ showinfo() { } export showinfo -# ------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ # Save or restore Konsle session manually -# ------------------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ ksession() { # Configuration local command='' local savepath="${HOME}/.konsole/" local savefile="$savepath/current-tabs" - + # Restore if asked to if [[ "$1" = "restore" ]]; then - echo "Restoring..." konsole --tabs-from-file $savefile -e 'bash -c exit' & elif [[ "$1" = "save" ]]; then - pid=$(pgrep konsole -u $USER) if [[ $pid ]]; then echo "# Most recent session list " $(date) > $savefile @@ -925,11 +933,12 @@ export ksession if [[ $EUID -eq 0 ]] ; then pathappend /sbin:/usr/sbin fi -[[ -d ~/.gem/ruby/2.3.0/bin ]] && pathappend ~/.gem/ruby/2.3.0/bin [[ -d /share/services/gestparc ]] && pathappend /share/services/gestparc +[[ -d ~/bin ]] && pathappend ~/bin +[[ -d ~/.local/bin ]] && pathappend ~/.local/bin # Set bash history -export HISTSIZE=10000 +export HISTSIZE=50000 export HISTIGNORE="&:[bf]g:exit" # Set default pager @@ -966,7 +975,7 @@ if [[ $INTERACTIVE ]]; then alias mkck='make check' alias mkin='make install' alias mkdin='make DESTDIR=$PWD/dest-install install' - alias ssh='ssh -x' + alias ssh='ssh -Y' alias wget='wget -c' # resume mode by default alias myip='curl ip.appspot.com'