improved profile to 2.6.3
This commit is contained in:
@@ -17,15 +17,18 @@
|
|||||||
# 16/01/2020 Version 2.3.1 : [bugfix] non-interactive 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->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
|
# 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,
|
||||||
# : improved utaz, removed showdiskmap, removed remaining French,
|
# : improved utaz, removed showdiskmap
|
||||||
|
# : removed remaining French,
|
||||||
# : added license information for future publication
|
# : added license information for future publication
|
||||||
# 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
|
||||||
|
# 18/10/2021 Version 2.6.3 : changed PS1 for status bar style version
|
||||||
|
# few minor improvements
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# 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.
|
||||||
@@ -61,7 +64,7 @@
|
|||||||
# * OF SUCH DAMAGE.
|
# * OF SUCH DAMAGE.
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
export PROFVERSION="2.6.2"
|
export PROFVERSION="2.6.3"
|
||||||
|
|
||||||
export DEFAULT_CITY="Toulouse"
|
export DEFAULT_CITY="Toulouse"
|
||||||
|
|
||||||
@@ -170,31 +173,32 @@ set_prompt ()
|
|||||||
Checkmark='\342\234\223'
|
Checkmark='\342\234\223'
|
||||||
|
|
||||||
# Begin with time
|
# 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
|
# Add a bright white exit status for the last command
|
||||||
|
|
||||||
# If it was successful, print a green check mark. Otherwise, print
|
# If it was successful, print a green check mark. Otherwise, print
|
||||||
# a red X.
|
# a red X.
|
||||||
if [[ $Last_Command == 0 ]]; then
|
if [[ $Last_Command == 0 ]]; then
|
||||||
PS1+="$White$OnBlue[ \$Last_Command "
|
PS1+="$White$OnBlue [ \$Last_Command "
|
||||||
PS1+="$Green$Checkmark "
|
PS1+="$Green$Checkmark "
|
||||||
else
|
else
|
||||||
PS1+="$White$OnRed[ \$Last_Command "
|
PS1+="$White$OnRed [ \$Last_Command "
|
||||||
PS1+="$Yellow$FancyX "
|
PS1+="$Yellow$FancyX "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add the ellapsed time and current date
|
# Add the ellapsed time and current date
|
||||||
timer_stop
|
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
|
# If root, just print the host in red. Otherwise, print the current user
|
||||||
# and host in green.
|
# and host in green.
|
||||||
if [[ $EUID -eq 0 ]]; then
|
if [[ $EUID -eq 0 ]]; then
|
||||||
PS1+="$Red\\u$Green@\\h "
|
PS1+="$Red\\u$Green@\\h"
|
||||||
else
|
else
|
||||||
PS1+="$Green\\u@\\h "
|
PS1+="$Green\\u@\\h"
|
||||||
fi
|
fi
|
||||||
|
PS1+="\e[K\e[u$Default"
|
||||||
# Print the working directory and prompt marker in blue, and reset
|
# Print the working directory and prompt marker in blue, and reset
|
||||||
# the text color to the default.
|
# the text color to the default.
|
||||||
PS1+="$ICyan\\w \\\$$Default "
|
PS1+="$ICyan\\w \\\$$Default "
|
||||||
@@ -208,7 +212,6 @@ ver ()
|
|||||||
echo "Profile version $PROFVERSION."
|
echo "Profile version $PROFVERSION."
|
||||||
}
|
}
|
||||||
export ver
|
export ver
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Change locale to French
|
# Change locale to French
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@@ -342,17 +345,18 @@ ssr ()
|
|||||||
done
|
done
|
||||||
|
|
||||||
[[ ! $1 ]] &&
|
[[ ! $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
|
local srv=$1 && shift
|
||||||
|
|
||||||
ssh -y root@$srv $@
|
ssh -Y root@$srv $@
|
||||||
}
|
}
|
||||||
export ssr
|
export ssr
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Look for a package within installed one
|
# Look for a package within installed one
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
dpkgs ()
|
dpkgs ()
|
||||||
{
|
{
|
||||||
local count=0
|
local count=0
|
||||||
@@ -375,31 +379,36 @@ dpkgs ()
|
|||||||
local pkg=$1 && shift
|
local pkg=$1 && shift
|
||||||
count=$(( $count + 1 ))
|
count=$(( $count + 1 ))
|
||||||
[[ $count -gt 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
|
esac
|
||||||
done
|
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
|
dpkg -l | grep $pkg
|
||||||
}
|
}
|
||||||
export dpkgs
|
export dpkgs
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Search processes matching the given string
|
# Search processes matching the given string
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
ppg ()
|
ppg ()
|
||||||
{
|
{
|
||||||
ps -edf | grep $@ | grep -v "grep $@"
|
ps -edf | grep $@ | grep -v "grep $@"
|
||||||
}
|
}
|
||||||
export ppg
|
export ppg
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Create a directory then goes inside
|
# Create a directory then goes inside
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
mcd () {
|
mcd () {
|
||||||
if [[ ! $# -eq 1 ]] ; then
|
if [[ ! $# -eq 1 ]] ; then
|
||||||
echo "Create a directory then goes inside."
|
echo "Create a directory then goes inside."
|
||||||
@@ -410,9 +419,9 @@ mcd () {
|
|||||||
}
|
}
|
||||||
export mcd
|
export mcd
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Get PID list of the given process name
|
# Get PID list of the given process name
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
gpid () {
|
gpid () {
|
||||||
[[ $# -eq 1 ]] && local single=1
|
[[ $# -eq 1 ]] && local single=1
|
||||||
for pid in $@; do
|
for pid in $@; do
|
||||||
@@ -427,9 +436,9 @@ gpid () {
|
|||||||
}
|
}
|
||||||
export gpid
|
export gpid
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Remove host from know_host (name and IP) for the active user
|
# Remove host from know_host (name and IP) for the active user
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
rmhost () {
|
rmhost () {
|
||||||
if [[ "$#" -ne 1 ]]; then
|
if [[ "$#" -ne 1 ]]; then
|
||||||
echo "Error: incorrect number of parameters."
|
echo "Error: incorrect number of parameters."
|
||||||
@@ -448,9 +457,9 @@ rmhost () {
|
|||||||
}
|
}
|
||||||
export rmhost
|
export rmhost
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Rename all files in current directory to replace spaces with _
|
# Rename all files in current directory to replace spaces with _
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
rmspc () {
|
rmspc () {
|
||||||
local lst=""
|
local lst=""
|
||||||
for opt in $@ ; do
|
for opt in $@ ; do
|
||||||
@@ -520,9 +529,9 @@ rmspc () {
|
|||||||
}
|
}
|
||||||
export rmspc
|
export rmspc
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Smartly uncompress archives (zip only)
|
# Smartly uncompress archives (zip only)
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
utaz()
|
utaz()
|
||||||
{
|
{
|
||||||
for opt in $@ ; do
|
for opt in $@ ; do
|
||||||
@@ -621,9 +630,9 @@ utaz()
|
|||||||
}
|
}
|
||||||
export utaz
|
export utaz
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Compress directories or files into one or more archive
|
# Compress directories or files into one or more archive
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
taz()
|
taz()
|
||||||
{
|
{
|
||||||
_doxz()
|
_doxz()
|
||||||
@@ -734,7 +743,7 @@ taz()
|
|||||||
for opt in $@ ; do
|
for opt in $@ ; do
|
||||||
case $opt in
|
case $opt in
|
||||||
"-h"|"--help")
|
"-h"|"--help")
|
||||||
echo "taz : archive all files of a directory."
|
echo "taz: archive all files of a directory."
|
||||||
echo
|
echo
|
||||||
echo "Usage: taz [option] [--parallel=<n>] [--format=<format>] [directory1 ... directoryN]"
|
echo "Usage: taz [option] [--parallel=<n>] [--format=<format>] [directory1 ... directoryN]"
|
||||||
echo
|
echo
|
||||||
@@ -841,12 +850,13 @@ taz()
|
|||||||
|
|
||||||
echo "--- Done"
|
echo "--- Done"
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
export taz
|
export taz
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Display system genal information
|
# Display system genal information
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
showinfo() {
|
showinfo() {
|
||||||
echo ""
|
echo ""
|
||||||
figlet $(hostname) -t -k
|
figlet $(hostname) -t -k
|
||||||
@@ -855,9 +865,9 @@ showinfo() {
|
|||||||
}
|
}
|
||||||
export showinfo
|
export showinfo
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Save or restore Konsle session manually
|
# Save or restore Konsle session manually
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
ksession() {
|
ksession() {
|
||||||
# Configuration
|
# Configuration
|
||||||
local command=''
|
local command=''
|
||||||
@@ -866,12 +876,10 @@ ksession() {
|
|||||||
|
|
||||||
# Restore if asked to
|
# Restore if asked to
|
||||||
if [[ "$1" = "restore" ]]; then
|
if [[ "$1" = "restore" ]]; then
|
||||||
|
|
||||||
echo "Restoring..."
|
echo "Restoring..."
|
||||||
konsole --tabs-from-file $savefile -e 'bash -c exit' &
|
konsole --tabs-from-file $savefile -e 'bash -c exit' &
|
||||||
|
|
||||||
elif [[ "$1" = "save" ]]; then
|
elif [[ "$1" = "save" ]]; then
|
||||||
|
|
||||||
pid=$(pgrep konsole -u $USER)
|
pid=$(pgrep konsole -u $USER)
|
||||||
if [[ $pid ]]; then
|
if [[ $pid ]]; then
|
||||||
echo "# Most recent session list " $(date) > $savefile
|
echo "# Most recent session list " $(date) > $savefile
|
||||||
@@ -925,11 +933,12 @@ export ksession
|
|||||||
if [[ $EUID -eq 0 ]] ; then
|
if [[ $EUID -eq 0 ]] ; then
|
||||||
pathappend /sbin:/usr/sbin
|
pathappend /sbin:/usr/sbin
|
||||||
fi
|
fi
|
||||||
[[ -d ~/.gem/ruby/2.3.0/bin ]] && pathappend ~/.gem/ruby/2.3.0/bin
|
|
||||||
[[ -d /share/services/gestparc ]] && pathappend /share/services/gestparc
|
[[ -d /share/services/gestparc ]] && pathappend /share/services/gestparc
|
||||||
|
[[ -d ~/bin ]] && pathappend ~/bin
|
||||||
|
[[ -d ~/.local/bin ]] && pathappend ~/.local/bin
|
||||||
|
|
||||||
# Set bash history
|
# Set bash history
|
||||||
export HISTSIZE=10000
|
export HISTSIZE=50000
|
||||||
export HISTIGNORE="&:[bf]g:exit"
|
export HISTIGNORE="&:[bf]g:exit"
|
||||||
|
|
||||||
# Set default pager
|
# Set default pager
|
||||||
@@ -966,7 +975,7 @@ if [[ $INTERACTIVE ]]; then
|
|||||||
alias mkck='make check'
|
alias mkck='make check'
|
||||||
alias mkin='make install'
|
alias mkin='make install'
|
||||||
alias mkdin='make DESTDIR=$PWD/dest-install 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 wget='wget -c' # resume mode by default
|
||||||
alias myip='curl ip.appspot.com'
|
alias myip='curl ip.appspot.com'
|
||||||
|
|||||||
Reference in New Issue
Block a user