Add synth-shell config
This commit is contained in:
parent
e67ee04e3a
commit
01d9eddb23
|
@ -0,0 +1,476 @@
|
|||
##!/bin/bash
|
||||
|
||||
## +-----------------------------------+-----------------------------------+
|
||||
## | |
|
||||
## | Copyright (c) 2014-2021, https://github.com/andresgongora/synth-shell |
|
||||
## | Visit the above URL for details of license and authorship. |
|
||||
## | |
|
||||
## | This program is free software: you can redistribute it and/or modify |
|
||||
## | it under the terms of the GNU General Public License as published by |
|
||||
## | the Free Software Foundation, either version 3 of the License, or |
|
||||
## | (at your option) any later version. |
|
||||
## | |
|
||||
## | This program is distributed in the hope that it will be useful, |
|
||||
## | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
## | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
## | GNU General Public License for more details. |
|
||||
## | |
|
||||
## | You should have received a copy of the GNU General Public License |
|
||||
## | along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
||||
## | |
|
||||
## +-----------------------------------------------------------------------+
|
||||
##
|
||||
##
|
||||
## =======================
|
||||
## WARNING!!
|
||||
## DO NOT EDIT THIS FILE!!
|
||||
## =======================
|
||||
##
|
||||
## This file was generated by an installation script.
|
||||
## If you edit this file, it might be overwritten without warning
|
||||
## and you will lose all your changes.
|
||||
##
|
||||
## Visit for instructions and more information:
|
||||
## https://github.com/andresgongora/synth-shell/
|
||||
##
|
||||
|
||||
|
||||
|
||||
loadConfigFile() {
|
||||
local config_file=$1
|
||||
if [ ! -f $config_file ]; then
|
||||
exit
|
||||
fi
|
||||
while IFS="" read -r p || [ -n "$p" ]
|
||||
do
|
||||
local line=$(echo "$p" |\
|
||||
sed -e '/^$/d;
|
||||
/^[ \t]*\#/d;
|
||||
s/[ \t][ \t]*\#.*//g;
|
||||
s/^[ \t]*//g;
|
||||
s/[ \t]*$//g')
|
||||
local line_end_trimmed=$(echo "$line" | sed -n 's/[ \t]*\\$//p')
|
||||
if [ -z "$line_end_trimmed" ]; then
|
||||
local is_multiline_next=false
|
||||
else
|
||||
local is_multiline_next=true
|
||||
local line=$line_end_trimmed
|
||||
fi
|
||||
set -- $( echo "$line" | sed -e 's/\\//g;s/".*"/X/g' )
|
||||
if [ ! -z "$line" ] && [ "$#" -gt 1 ]; then
|
||||
local config_key_name=$1
|
||||
local config_param=$(echo "$line" |\
|
||||
sed -e "s/$config_key_name\s*//g" |\
|
||||
sed -e "s/^\"//g;s/\"$//g")
|
||||
eval config_key_current_value=\$$config_key_name
|
||||
if [ ! -z "$config_key_current_value" ]; then
|
||||
export "${config_key_name}"="$config_param"
|
||||
fi
|
||||
elif [ "$#" -eq 1 ] && $is_multiline ; then
|
||||
local line_end_trimmed=$(echo $line |\
|
||||
sed -n 's/[ \t]*\\$//p')
|
||||
if [ -z "$line_end_trimmed" ]; then
|
||||
local multi_line=false
|
||||
else
|
||||
echo ":) $line_end_trimmed"
|
||||
local multi_line=true
|
||||
local line=$line_end_trimmed
|
||||
fi
|
||||
local config_param_old=$config_param
|
||||
local config_param=$(echo "$line" |\
|
||||
sed "s/^\"//g;s/\"$//g")
|
||||
eval config_key_current_value=\$$config_key_name
|
||||
if [ ! -z "$config_key_current_value" ]; then
|
||||
export "${config_key_name}"="$config_key_current_value$config_param"
|
||||
fi
|
||||
fi
|
||||
local is_multiline=$is_multiline_next
|
||||
done < $config_file
|
||||
}
|
||||
get8bitCode()
|
||||
{
|
||||
CODE=$1
|
||||
case $CODE in
|
||||
default)
|
||||
echo 9
|
||||
;;
|
||||
none)
|
||||
echo 9
|
||||
;;
|
||||
black)
|
||||
echo 0
|
||||
;;
|
||||
red)
|
||||
echo 1
|
||||
;;
|
||||
green)
|
||||
echo 2
|
||||
;;
|
||||
yellow)
|
||||
echo 3
|
||||
;;
|
||||
blue)
|
||||
echo 4
|
||||
;;
|
||||
magenta|purple|pink)
|
||||
echo 5
|
||||
;;
|
||||
cyan)
|
||||
echo 6
|
||||
;;
|
||||
light-gray)
|
||||
echo 7
|
||||
;;
|
||||
dark-gray)
|
||||
echo 60
|
||||
;;
|
||||
light-red)
|
||||
echo 61
|
||||
;;
|
||||
light-green)
|
||||
echo 62
|
||||
;;
|
||||
light-yellow)
|
||||
echo 63
|
||||
;;
|
||||
light-blue)
|
||||
echo 64
|
||||
;;
|
||||
light-magenta|light-purple)
|
||||
echo 65
|
||||
;;
|
||||
light-cyan)
|
||||
echo 66
|
||||
;;
|
||||
white)
|
||||
echo 67
|
||||
;;
|
||||
*)
|
||||
echo 0
|
||||
esac
|
||||
}
|
||||
getColorCode()
|
||||
{
|
||||
COLOR=$1
|
||||
if [ $COLOR -eq $COLOR ] 2> /dev/null; then
|
||||
if [ $COLOR -gt 0 -a $COLOR -lt 256 ]; then
|
||||
echo "38;5;$COLOR"
|
||||
else
|
||||
echo 0
|
||||
fi
|
||||
else
|
||||
BITCODE=$(get8bitCode $COLOR)
|
||||
COLORCODE=$(($BITCODE + 30))
|
||||
echo $COLORCODE
|
||||
fi
|
||||
}
|
||||
getBackgroundCode()
|
||||
{
|
||||
COLOR=$1
|
||||
if [ $COLOR -eq $COLOR ] 2> /dev/null; then
|
||||
if [ $COLOR -gt 0 -a $COLOR -lt 256 ]; then
|
||||
echo "48;5;$COLOR"
|
||||
else
|
||||
echo 0
|
||||
fi
|
||||
else
|
||||
BITCODE=$(get8bitCode $COLOR)
|
||||
COLORCODE=$(($BITCODE + 40))
|
||||
echo $COLORCODE
|
||||
fi
|
||||
}
|
||||
getEffectCode()
|
||||
{
|
||||
EFFECT=$1
|
||||
NONE=0
|
||||
case $EFFECT in
|
||||
none)
|
||||
echo $NONE
|
||||
;;
|
||||
default)
|
||||
echo $NONE
|
||||
;;
|
||||
bold)
|
||||
echo 1
|
||||
;;
|
||||
bright)
|
||||
echo 1
|
||||
;;
|
||||
dim)
|
||||
echo 2
|
||||
;;
|
||||
underline)
|
||||
echo 4
|
||||
;;
|
||||
blink)
|
||||
echo 5
|
||||
;;
|
||||
reverse)
|
||||
echo 7
|
||||
;;
|
||||
hidden)
|
||||
echo 8
|
||||
;;
|
||||
strikeout)
|
||||
echo 9
|
||||
;;
|
||||
*)
|
||||
echo $NONE
|
||||
esac
|
||||
}
|
||||
getFormattingSequence()
|
||||
{
|
||||
START='\e[0;'
|
||||
MIDLE=$1
|
||||
END='m'
|
||||
echo -n "$START$MIDLE$END"
|
||||
}
|
||||
applyCodeToText()
|
||||
{
|
||||
local RESET=$(getFormattingSequence $(getEffectCode none))
|
||||
TEXT=$1
|
||||
CODE=$2
|
||||
echo -n "$CODE$TEXT$RESET"
|
||||
}
|
||||
getFormatCode()
|
||||
{
|
||||
local RESET=$(getFormattingSequence $(getEffectCode none))
|
||||
if [ "$#" -eq 0 ]; then
|
||||
echo -n "$RESET"
|
||||
elif [ "$#" -eq 1 ]; then
|
||||
TEXT_COLOR=$(getFormattingSequence $(getColorCode $1))
|
||||
echo -n "$TEXT_COLOR"
|
||||
else
|
||||
FORMAT=""
|
||||
while [ "$1" != "" ]; do
|
||||
TYPE=$1
|
||||
ARGUMENT=$2
|
||||
case $TYPE in
|
||||
-c)
|
||||
CODE=$(getColorCode $ARGUMENT)
|
||||
;;
|
||||
-b)
|
||||
CODE=$(getBackgroundCode $ARGUMENT)
|
||||
;;
|
||||
-e)
|
||||
CODE=$(getEffectCode $ARGUMENT)
|
||||
;;
|
||||
*)
|
||||
CODE=""
|
||||
esac
|
||||
if [ "$FORMAT" != "" ]; then
|
||||
FORMAT="$FORMAT;"
|
||||
fi
|
||||
FORMAT="$FORMAT$CODE"
|
||||
shift
|
||||
shift
|
||||
done
|
||||
FORMAT_CODE=$(getFormattingSequence $FORMAT)
|
||||
echo -n "${FORMAT_CODE}"
|
||||
fi
|
||||
}
|
||||
formatText()
|
||||
{
|
||||
local RESET=$(getFormattingSequence $(getEffectCode none))
|
||||
if [ "$#" -eq 0 ]; then
|
||||
echo -n "${RESET}"
|
||||
elif [ "$#" -eq 1 ]; then
|
||||
TEXT=$1
|
||||
echo -n "${TEXT}${RESET}"
|
||||
else
|
||||
TEXT=$1
|
||||
FORMAT_CODE=$(getFormatCode "${@:2}")
|
||||
applyCodeToText "$TEXT" "$FORMAT_CODE"
|
||||
fi
|
||||
}
|
||||
removeColorCodes()
|
||||
{
|
||||
printf "$1" | sed 's/\x1b\[[0-9;]*m//g'
|
||||
}
|
||||
shortenPath()
|
||||
{
|
||||
local path=$1
|
||||
local max_length=$2
|
||||
local default_max_length=25
|
||||
local trunc_symbol=".."
|
||||
if [ -z "$path" ]; then
|
||||
echo ""
|
||||
exit
|
||||
elif [ -z "$max_length" ]; then
|
||||
local max_length=$default_max_length
|
||||
fi
|
||||
local path=${path/#$HOME/\~}
|
||||
local dir=${path##*/}
|
||||
local dir_length=${#dir}
|
||||
local path_length=${#path}
|
||||
local print_length=$(( ( max_length < dir_length ) ? dir_length : max_length ))
|
||||
if [ $path_length -gt $print_length ]; then
|
||||
local offset=$(( $path_length - $print_length ))
|
||||
local truncated_path=${path:$offset}
|
||||
local clean_path=${truncated_path#*/}
|
||||
local short_path=${trunc_symbol}/${clean_path}
|
||||
else
|
||||
local short_path=$path
|
||||
fi
|
||||
echo $short_path
|
||||
}
|
||||
enableTerminalLineWrap()
|
||||
{
|
||||
printf '\e[?7h'
|
||||
}
|
||||
disableTerminalLineWrap()
|
||||
{
|
||||
printf '\e[?7l'
|
||||
}
|
||||
saveCursorPosition()
|
||||
{
|
||||
printf "\e[s"
|
||||
}
|
||||
moveCursorToSavedPosition()
|
||||
{
|
||||
printf "\e[u"
|
||||
}
|
||||
moveCursorToRowCol()
|
||||
{
|
||||
local row=$1
|
||||
local col=$2
|
||||
printf "\e[${row};${col}H"
|
||||
}
|
||||
moveCursorHome()
|
||||
{
|
||||
printf "\e[;H"
|
||||
}
|
||||
moveCursorUp()
|
||||
{
|
||||
local inc=$1
|
||||
if [ -z "$inc" ]; then
|
||||
printf "\e[1A"
|
||||
elif [ $inc -gt 0 ]; then
|
||||
printf "\e[${inc}A"
|
||||
fi
|
||||
}
|
||||
moveCursorDown()
|
||||
{
|
||||
local inc=$1
|
||||
if [ -z "$inc" ]; then
|
||||
printf "\e[1B"
|
||||
elif [ $inc -gt 0 ]; then
|
||||
printf "\e[${inc}B"
|
||||
fi
|
||||
}
|
||||
moveCursorRight()
|
||||
{
|
||||
local inc=$1
|
||||
if [ -z "$inc" ]; then
|
||||
printf "\e[1C"
|
||||
elif [ $inc -gt 0 ]; then
|
||||
printf "\e[${inc}D"
|
||||
fi
|
||||
}
|
||||
moveCursorLeft()
|
||||
{
|
||||
local inc=$1
|
||||
if [ -z "$inc" ]; then
|
||||
printf "\e[1D"
|
||||
elif [ $inc -gt 0 ]; then
|
||||
printf "\e[${inc}C"
|
||||
fi
|
||||
}
|
||||
getTerminalNumRows()
|
||||
{
|
||||
tput lines
|
||||
}
|
||||
getTerminalNumCols()
|
||||
{
|
||||
tput cols
|
||||
}
|
||||
getTextNumRows()
|
||||
{
|
||||
local rows=$(echo -e "$1" | wc -l )
|
||||
echo "$rows"
|
||||
}
|
||||
getTextNumCols()
|
||||
{
|
||||
local columns=$(echo -e "$1" | sed 's/\x1b\[[0-9;]*m//g' | wc -L )
|
||||
echo "$columns"
|
||||
}
|
||||
getTextShape()
|
||||
{
|
||||
echo "$(getTextNumRows) $(getTextNumCols)"
|
||||
}
|
||||
printWithOffset()
|
||||
{
|
||||
local row=$1
|
||||
local col=$2
|
||||
local text=${@:3}
|
||||
moveCursorDown "$row"
|
||||
if [ $col -gt 0 ]; then
|
||||
col_spacer="\\\\e[${col}C"
|
||||
local text=$(echo "$text" |\
|
||||
sed "s/^/$col_spacer/g;s/\\\\n/\\\\n$col_spacer/g")
|
||||
fi
|
||||
disableTerminalLineWrap
|
||||
echo -e "${text}"
|
||||
enableTerminalLineWrap
|
||||
}
|
||||
printTwoElementsSideBySide()
|
||||
{
|
||||
local element_1=$1
|
||||
local element_2=$2
|
||||
local print_cols_max=$3
|
||||
local term_cols=$(getTerminalNumCols)
|
||||
if [ ! -z "$print_cols_max" ]; then
|
||||
local term_cols=$(( ( $term_cols > $print_cols_max ) ?\
|
||||
$print_cols_max : $term_cols ))
|
||||
fi
|
||||
local e_1_cols=$(getTextNumCols "$element_1")
|
||||
local e_1_rows=$(getTextNumRows "$element_1")
|
||||
local e_2_cols=$(getTextNumCols "$element_2")
|
||||
local e_2_rows=$(getTextNumRows "$element_2")
|
||||
local free_cols=$(( $term_cols - $e_1_cols - $e_2_cols ))
|
||||
if [ $free_cols -lt 1 ]; then
|
||||
local free_cols=0
|
||||
fi
|
||||
if [ $e_1_cols -gt 0 ] && [ $e_2_cols -gt 0 ]; then
|
||||
local h_pad=$(( $free_cols/3 ))
|
||||
local e_1_h_pad=$h_pad
|
||||
local e_2_h_pad=$(( $e_1_cols + 2*$h_pad ))
|
||||
elif [ $e_1_cols -gt 0 ]; then
|
||||
local h_pad=$(( $free_cols/2 ))
|
||||
local e_1_h_pad=$h_pad
|
||||
local e_2_h_pad=0
|
||||
elif [ $e_2_cols -gt 0 ]; then
|
||||
local h_pad=$(( $free_cols/2 ))
|
||||
local e_1_h_pad=0
|
||||
local e_2_h_pad=$h_pad
|
||||
else
|
||||
local e_1_h_pad=0
|
||||
local e_2_h_pad=0
|
||||
fi
|
||||
local e_1_v_pad=$(( ( $e_1_rows > $e_2_rows ) ?\
|
||||
0 : (( ($e_2_rows - $e_1_rows)/2 )) ))
|
||||
local e_2_v_pad=$(( ( $e_2_rows > $e_1_rows ) ?\
|
||||
0 : (( ($e_1_rows - $e_2_rows)/2 )) ))
|
||||
local max_rows=$(( ( $e_1_rows > $e_2_rows ) ? $e_1_rows : $e_2_rows ))
|
||||
for i in `seq $max_rows`; do printf "\n"; done
|
||||
moveCursorUp $max_rows
|
||||
saveCursorPosition
|
||||
printWithOffset $e_1_v_pad $e_1_h_pad "$element_1"
|
||||
moveCursorToSavedPosition
|
||||
printWithOffset $e_2_v_pad $e_2_h_pad "$element_2"
|
||||
moveCursorToSavedPosition
|
||||
moveCursorDown $(( $max_rows ))
|
||||
}
|
||||
alias grep='\grep --color=auto'
|
||||
alias pacman='\pacman --color=auto'
|
||||
alias tree='\tree --dirsfirst -C'
|
||||
alias dmesg='\dmesg --color=auto --reltime --human --nopager --decode'
|
||||
alias free='\free -mht'
|
||||
take() {
|
||||
mkdir -p -- "$1" &&
|
||||
cd -P -- "$1"
|
||||
}
|
||||
alias sudo='\sudo '
|
||||
if [ "$PS1" ]; then
|
||||
complete -cf sudo
|
||||
fi
|
|
@ -0,0 +1,475 @@
|
|||
##!/bin/bash
|
||||
|
||||
## +-----------------------------------+-----------------------------------+
|
||||
## | |
|
||||
## | Copyright (c) 2014-2021, https://github.com/andresgongora/synth-shell |
|
||||
## | Visit the above URL for details of license and authorship. |
|
||||
## | |
|
||||
## | This program is free software: you can redistribute it and/or modify |
|
||||
## | it under the terms of the GNU General Public License as published by |
|
||||
## | the Free Software Foundation, either version 3 of the License, or |
|
||||
## | (at your option) any later version. |
|
||||
## | |
|
||||
## | This program is distributed in the hope that it will be useful, |
|
||||
## | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
## | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
## | GNU General Public License for more details. |
|
||||
## | |
|
||||
## | You should have received a copy of the GNU General Public License |
|
||||
## | along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
||||
## | |
|
||||
## +-----------------------------------------------------------------------+
|
||||
##
|
||||
##
|
||||
## =======================
|
||||
## WARNING!!
|
||||
## DO NOT EDIT THIS FILE!!
|
||||
## =======================
|
||||
##
|
||||
## This file was generated by an installation script.
|
||||
## If you edit this file, it might be overwritten without warning
|
||||
## and you will lose all your changes.
|
||||
##
|
||||
## Visit for instructions and more information:
|
||||
## https://github.com/andresgongora/synth-shell/
|
||||
##
|
||||
|
||||
|
||||
|
||||
loadConfigFile() {
|
||||
local config_file=$1
|
||||
if [ ! -f $config_file ]; then
|
||||
exit
|
||||
fi
|
||||
while IFS="" read -r p || [ -n "$p" ]
|
||||
do
|
||||
local line=$(echo "$p" |\
|
||||
sed -e '/^$/d;
|
||||
/^[ \t]*\#/d;
|
||||
s/[ \t][ \t]*\#.*//g;
|
||||
s/^[ \t]*//g;
|
||||
s/[ \t]*$//g')
|
||||
local line_end_trimmed=$(echo "$line" | sed -n 's/[ \t]*\\$//p')
|
||||
if [ -z "$line_end_trimmed" ]; then
|
||||
local is_multiline_next=false
|
||||
else
|
||||
local is_multiline_next=true
|
||||
local line=$line_end_trimmed
|
||||
fi
|
||||
set -- $( echo "$line" | sed -e 's/\\//g;s/".*"/X/g' )
|
||||
if [ ! -z "$line" ] && [ "$#" -gt 1 ]; then
|
||||
local config_key_name=$1
|
||||
local config_param=$(echo "$line" |\
|
||||
sed -e "s/$config_key_name\s*//g" |\
|
||||
sed -e "s/^\"//g;s/\"$//g")
|
||||
eval config_key_current_value=\$$config_key_name
|
||||
if [ ! -z "$config_key_current_value" ]; then
|
||||
export "${config_key_name}"="$config_param"
|
||||
fi
|
||||
elif [ "$#" -eq 1 ] && $is_multiline ; then
|
||||
local line_end_trimmed=$(echo $line |\
|
||||
sed -n 's/[ \t]*\\$//p')
|
||||
if [ -z "$line_end_trimmed" ]; then
|
||||
local multi_line=false
|
||||
else
|
||||
echo ":) $line_end_trimmed"
|
||||
local multi_line=true
|
||||
local line=$line_end_trimmed
|
||||
fi
|
||||
local config_param_old=$config_param
|
||||
local config_param=$(echo "$line" |\
|
||||
sed "s/^\"//g;s/\"$//g")
|
||||
eval config_key_current_value=\$$config_key_name
|
||||
if [ ! -z "$config_key_current_value" ]; then
|
||||
export "${config_key_name}"="$config_key_current_value$config_param"
|
||||
fi
|
||||
fi
|
||||
local is_multiline=$is_multiline_next
|
||||
done < $config_file
|
||||
}
|
||||
get8bitCode()
|
||||
{
|
||||
CODE=$1
|
||||
case $CODE in
|
||||
default)
|
||||
echo 9
|
||||
;;
|
||||
none)
|
||||
echo 9
|
||||
;;
|
||||
black)
|
||||
echo 0
|
||||
;;
|
||||
red)
|
||||
echo 1
|
||||
;;
|
||||
green)
|
||||
echo 2
|
||||
;;
|
||||
yellow)
|
||||
echo 3
|
||||
;;
|
||||
blue)
|
||||
echo 4
|
||||
;;
|
||||
magenta|purple|pink)
|
||||
echo 5
|
||||
;;
|
||||
cyan)
|
||||
echo 6
|
||||
;;
|
||||
light-gray)
|
||||
echo 7
|
||||
;;
|
||||
dark-gray)
|
||||
echo 60
|
||||
;;
|
||||
light-red)
|
||||
echo 61
|
||||
;;
|
||||
light-green)
|
||||
echo 62
|
||||
;;
|
||||
light-yellow)
|
||||
echo 63
|
||||
;;
|
||||
light-blue)
|
||||
echo 64
|
||||
;;
|
||||
light-magenta|light-purple)
|
||||
echo 65
|
||||
;;
|
||||
light-cyan)
|
||||
echo 66
|
||||
;;
|
||||
white)
|
||||
echo 67
|
||||
;;
|
||||
*)
|
||||
echo 0
|
||||
esac
|
||||
}
|
||||
getColorCode()
|
||||
{
|
||||
COLOR=$1
|
||||
if [ $COLOR -eq $COLOR ] 2> /dev/null; then
|
||||
if [ $COLOR -gt 0 -a $COLOR -lt 256 ]; then
|
||||
echo "38;5;$COLOR"
|
||||
else
|
||||
echo 0
|
||||
fi
|
||||
else
|
||||
BITCODE=$(get8bitCode $COLOR)
|
||||
COLORCODE=$(($BITCODE + 30))
|
||||
echo $COLORCODE
|
||||
fi
|
||||
}
|
||||
getBackgroundCode()
|
||||
{
|
||||
COLOR=$1
|
||||
if [ $COLOR -eq $COLOR ] 2> /dev/null; then
|
||||
if [ $COLOR -gt 0 -a $COLOR -lt 256 ]; then
|
||||
echo "48;5;$COLOR"
|
||||
else
|
||||
echo 0
|
||||
fi
|
||||
else
|
||||
BITCODE=$(get8bitCode $COLOR)
|
||||
COLORCODE=$(($BITCODE + 40))
|
||||
echo $COLORCODE
|
||||
fi
|
||||
}
|
||||
getEffectCode()
|
||||
{
|
||||
EFFECT=$1
|
||||
NONE=0
|
||||
case $EFFECT in
|
||||
none)
|
||||
echo $NONE
|
||||
;;
|
||||
default)
|
||||
echo $NONE
|
||||
;;
|
||||
bold)
|
||||
echo 1
|
||||
;;
|
||||
bright)
|
||||
echo 1
|
||||
;;
|
||||
dim)
|
||||
echo 2
|
||||
;;
|
||||
underline)
|
||||
echo 4
|
||||
;;
|
||||
blink)
|
||||
echo 5
|
||||
;;
|
||||
reverse)
|
||||
echo 7
|
||||
;;
|
||||
hidden)
|
||||
echo 8
|
||||
;;
|
||||
strikeout)
|
||||
echo 9
|
||||
;;
|
||||
*)
|
||||
echo $NONE
|
||||
esac
|
||||
}
|
||||
getFormattingSequence()
|
||||
{
|
||||
START='\e[0;'
|
||||
MIDLE=$1
|
||||
END='m'
|
||||
echo -n "$START$MIDLE$END"
|
||||
}
|
||||
applyCodeToText()
|
||||
{
|
||||
local RESET=$(getFormattingSequence $(getEffectCode none))
|
||||
TEXT=$1
|
||||
CODE=$2
|
||||
echo -n "$CODE$TEXT$RESET"
|
||||
}
|
||||
getFormatCode()
|
||||
{
|
||||
local RESET=$(getFormattingSequence $(getEffectCode none))
|
||||
if [ "$#" -eq 0 ]; then
|
||||
echo -n "$RESET"
|
||||
elif [ "$#" -eq 1 ]; then
|
||||
TEXT_COLOR=$(getFormattingSequence $(getColorCode $1))
|
||||
echo -n "$TEXT_COLOR"
|
||||
else
|
||||
FORMAT=""
|
||||
while [ "$1" != "" ]; do
|
||||
TYPE=$1
|
||||
ARGUMENT=$2
|
||||
case $TYPE in
|
||||
-c)
|
||||
CODE=$(getColorCode $ARGUMENT)
|
||||
;;
|
||||
-b)
|
||||
CODE=$(getBackgroundCode $ARGUMENT)
|
||||
;;
|
||||
-e)
|
||||
CODE=$(getEffectCode $ARGUMENT)
|
||||
;;
|
||||
*)
|
||||
CODE=""
|
||||
esac
|
||||
if [ "$FORMAT" != "" ]; then
|
||||
FORMAT="$FORMAT;"
|
||||
fi
|
||||
FORMAT="$FORMAT$CODE"
|
||||
shift
|
||||
shift
|
||||
done
|
||||
FORMAT_CODE=$(getFormattingSequence $FORMAT)
|
||||
echo -n "${FORMAT_CODE}"
|
||||
fi
|
||||
}
|
||||
formatText()
|
||||
{
|
||||
local RESET=$(getFormattingSequence $(getEffectCode none))
|
||||
if [ "$#" -eq 0 ]; then
|
||||
echo -n "${RESET}"
|
||||
elif [ "$#" -eq 1 ]; then
|
||||
TEXT=$1
|
||||
echo -n "${TEXT}${RESET}"
|
||||
else
|
||||
TEXT=$1
|
||||
FORMAT_CODE=$(getFormatCode "${@:2}")
|
||||
applyCodeToText "$TEXT" "$FORMAT_CODE"
|
||||
fi
|
||||
}
|
||||
removeColorCodes()
|
||||
{
|
||||
printf "$1" | sed 's/\x1b\[[0-9;]*m//g'
|
||||
}
|
||||
shortenPath()
|
||||
{
|
||||
local path=$1
|
||||
local max_length=$2
|
||||
local default_max_length=25
|
||||
local trunc_symbol=".."
|
||||
if [ -z "$path" ]; then
|
||||
echo ""
|
||||
exit
|
||||
elif [ -z "$max_length" ]; then
|
||||
local max_length=$default_max_length
|
||||
fi
|
||||
local path=${path/#$HOME/\~}
|
||||
local dir=${path##*/}
|
||||
local dir_length=${#dir}
|
||||
local path_length=${#path}
|
||||
local print_length=$(( ( max_length < dir_length ) ? dir_length : max_length ))
|
||||
if [ $path_length -gt $print_length ]; then
|
||||
local offset=$(( $path_length - $print_length ))
|
||||
local truncated_path=${path:$offset}
|
||||
local clean_path=${truncated_path#*/}
|
||||
local short_path=${trunc_symbol}/${clean_path}
|
||||
else
|
||||
local short_path=$path
|
||||
fi
|
||||
echo $short_path
|
||||
}
|
||||
enableTerminalLineWrap()
|
||||
{
|
||||
printf '\e[?7h'
|
||||
}
|
||||
disableTerminalLineWrap()
|
||||
{
|
||||
printf '\e[?7l'
|
||||
}
|
||||
saveCursorPosition()
|
||||
{
|
||||
printf "\e[s"
|
||||
}
|
||||
moveCursorToSavedPosition()
|
||||
{
|
||||
printf "\e[u"
|
||||
}
|
||||
moveCursorToRowCol()
|
||||
{
|
||||
local row=$1
|
||||
local col=$2
|
||||
printf "\e[${row};${col}H"
|
||||
}
|
||||
moveCursorHome()
|
||||
{
|
||||
printf "\e[;H"
|
||||
}
|
||||
moveCursorUp()
|
||||
{
|
||||
local inc=$1
|
||||
if [ -z "$inc" ]; then
|
||||
printf "\e[1A"
|
||||
elif [ $inc -gt 0 ]; then
|
||||
printf "\e[${inc}A"
|
||||
fi
|
||||
}
|
||||
moveCursorDown()
|
||||
{
|
||||
local inc=$1
|
||||
if [ -z "$inc" ]; then
|
||||
printf "\e[1B"
|
||||
elif [ $inc -gt 0 ]; then
|
||||
printf "\e[${inc}B"
|
||||
fi
|
||||
}
|
||||
moveCursorRight()
|
||||
{
|
||||
local inc=$1
|
||||
if [ -z "$inc" ]; then
|
||||
printf "\e[1C"
|
||||
elif [ $inc -gt 0 ]; then
|
||||
printf "\e[${inc}D"
|
||||
fi
|
||||
}
|
||||
moveCursorLeft()
|
||||
{
|
||||
local inc=$1
|
||||
if [ -z "$inc" ]; then
|
||||
printf "\e[1D"
|
||||
elif [ $inc -gt 0 ]; then
|
||||
printf "\e[${inc}C"
|
||||
fi
|
||||
}
|
||||
getTerminalNumRows()
|
||||
{
|
||||
tput lines
|
||||
}
|
||||
getTerminalNumCols()
|
||||
{
|
||||
tput cols
|
||||
}
|
||||
getTextNumRows()
|
||||
{
|
||||
local rows=$(echo -e "$1" | wc -l )
|
||||
echo "$rows"
|
||||
}
|
||||
getTextNumCols()
|
||||
{
|
||||
local columns=$(echo -e "$1" | sed 's/\x1b\[[0-9;]*m//g' | wc -L )
|
||||
echo "$columns"
|
||||
}
|
||||
getTextShape()
|
||||
{
|
||||
echo "$(getTextNumRows) $(getTextNumCols)"
|
||||
}
|
||||
printWithOffset()
|
||||
{
|
||||
local row=$1
|
||||
local col=$2
|
||||
local text=${@:3}
|
||||
moveCursorDown "$row"
|
||||
if [ $col -gt 0 ]; then
|
||||
col_spacer="\\\\e[${col}C"
|
||||
local text=$(echo "$text" |\
|
||||
sed "s/^/$col_spacer/g;s/\\\\n/\\\\n$col_spacer/g")
|
||||
fi
|
||||
disableTerminalLineWrap
|
||||
echo -e "${text}"
|
||||
enableTerminalLineWrap
|
||||
}
|
||||
printTwoElementsSideBySide()
|
||||
{
|
||||
local element_1=$1
|
||||
local element_2=$2
|
||||
local print_cols_max=$3
|
||||
local term_cols=$(getTerminalNumCols)
|
||||
if [ ! -z "$print_cols_max" ]; then
|
||||
local term_cols=$(( ( $term_cols > $print_cols_max ) ?\
|
||||
$print_cols_max : $term_cols ))
|
||||
fi
|
||||
local e_1_cols=$(getTextNumCols "$element_1")
|
||||
local e_1_rows=$(getTextNumRows "$element_1")
|
||||
local e_2_cols=$(getTextNumCols "$element_2")
|
||||
local e_2_rows=$(getTextNumRows "$element_2")
|
||||
local free_cols=$(( $term_cols - $e_1_cols - $e_2_cols ))
|
||||
if [ $free_cols -lt 1 ]; then
|
||||
local free_cols=0
|
||||
fi
|
||||
if [ $e_1_cols -gt 0 ] && [ $e_2_cols -gt 0 ]; then
|
||||
local h_pad=$(( $free_cols/3 ))
|
||||
local e_1_h_pad=$h_pad
|
||||
local e_2_h_pad=$(( $e_1_cols + 2*$h_pad ))
|
||||
elif [ $e_1_cols -gt 0 ]; then
|
||||
local h_pad=$(( $free_cols/2 ))
|
||||
local e_1_h_pad=$h_pad
|
||||
local e_2_h_pad=0
|
||||
elif [ $e_2_cols -gt 0 ]; then
|
||||
local h_pad=$(( $free_cols/2 ))
|
||||
local e_1_h_pad=0
|
||||
local e_2_h_pad=$h_pad
|
||||
else
|
||||
local e_1_h_pad=0
|
||||
local e_2_h_pad=0
|
||||
fi
|
||||
local e_1_v_pad=$(( ( $e_1_rows > $e_2_rows ) ?\
|
||||
0 : (( ($e_2_rows - $e_1_rows)/2 )) ))
|
||||
local e_2_v_pad=$(( ( $e_2_rows > $e_1_rows ) ?\
|
||||
0 : (( ($e_1_rows - $e_2_rows)/2 )) ))
|
||||
local max_rows=$(( ( $e_1_rows > $e_2_rows ) ? $e_1_rows : $e_2_rows ))
|
||||
for i in `seq $max_rows`; do printf "\n"; done
|
||||
moveCursorUp $max_rows
|
||||
saveCursorPosition
|
||||
printWithOffset $e_1_v_pad $e_1_h_pad "$element_1"
|
||||
moveCursorToSavedPosition
|
||||
printWithOffset $e_2_v_pad $e_2_h_pad "$element_2"
|
||||
moveCursorToSavedPosition
|
||||
moveCursorDown $(( $max_rows ))
|
||||
}
|
||||
betterHistory()
|
||||
{
|
||||
local blue="\033[0;34m"
|
||||
local nocolor="\033[0m"
|
||||
export HISTTIMEFORMAT=`echo -e ${blue}[%F %T] $nocolor `
|
||||
export HISTSIZE=-1
|
||||
export HISTFILESIZE=-1
|
||||
export HISTCONTROL=ignoreboth
|
||||
shopt -s cmdhist
|
||||
shopt -s lithist
|
||||
}
|
||||
betterHistory
|
|
@ -0,0 +1,498 @@
|
|||
##!/bin/bash
|
||||
|
||||
## +-----------------------------------+-----------------------------------+
|
||||
## | |
|
||||
## | Copyright (c) 2014-2021, https://github.com/andresgongora/synth-shell |
|
||||
## | Visit the above URL for details of license and authorship. |
|
||||
## | |
|
||||
## | This program is free software: you can redistribute it and/or modify |
|
||||
## | it under the terms of the GNU General Public License as published by |
|
||||
## | the Free Software Foundation, either version 3 of the License, or |
|
||||
## | (at your option) any later version. |
|
||||
## | |
|
||||
## | This program is distributed in the hope that it will be useful, |
|
||||
## | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
## | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
## | GNU General Public License for more details. |
|
||||
## | |
|
||||
## | You should have received a copy of the GNU General Public License |
|
||||
## | along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
||||
## | |
|
||||
## +-----------------------------------------------------------------------+
|
||||
##
|
||||
##
|
||||
## =======================
|
||||
## WARNING!!
|
||||
## DO NOT EDIT THIS FILE!!
|
||||
## =======================
|
||||
##
|
||||
## This file was generated by an installation script.
|
||||
## If you edit this file, it might be overwritten without warning
|
||||
## and you will lose all your changes.
|
||||
##
|
||||
## Visit for instructions and more information:
|
||||
## https://github.com/andresgongora/synth-shell/
|
||||
##
|
||||
|
||||
|
||||
|
||||
loadConfigFile() {
|
||||
local config_file=$1
|
||||
if [ ! -f $config_file ]; then
|
||||
exit
|
||||
fi
|
||||
while IFS="" read -r p || [ -n "$p" ]
|
||||
do
|
||||
local line=$(echo "$p" |\
|
||||
sed -e '/^$/d;
|
||||
/^[ \t]*\#/d;
|
||||
s/[ \t][ \t]*\#.*//g;
|
||||
s/^[ \t]*//g;
|
||||
s/[ \t]*$//g')
|
||||
local line_end_trimmed=$(echo "$line" | sed -n 's/[ \t]*\\$//p')
|
||||
if [ -z "$line_end_trimmed" ]; then
|
||||
local is_multiline_next=false
|
||||
else
|
||||
local is_multiline_next=true
|
||||
local line=$line_end_trimmed
|
||||
fi
|
||||
set -- $( echo "$line" | sed -e 's/\\//g;s/".*"/X/g' )
|
||||
if [ ! -z "$line" ] && [ "$#" -gt 1 ]; then
|
||||
local config_key_name=$1
|
||||
local config_param=$(echo "$line" |\
|
||||
sed -e "s/$config_key_name\s*//g" |\
|
||||
sed -e "s/^\"//g;s/\"$//g")
|
||||
eval config_key_current_value=\$$config_key_name
|
||||
if [ ! -z "$config_key_current_value" ]; then
|
||||
export "${config_key_name}"="$config_param"
|
||||
fi
|
||||
elif [ "$#" -eq 1 ] && $is_multiline ; then
|
||||
local line_end_trimmed=$(echo $line |\
|
||||
sed -n 's/[ \t]*\\$//p')
|
||||
if [ -z "$line_end_trimmed" ]; then
|
||||
local multi_line=false
|
||||
else
|
||||
echo ":) $line_end_trimmed"
|
||||
local multi_line=true
|
||||
local line=$line_end_trimmed
|
||||
fi
|
||||
local config_param_old=$config_param
|
||||
local config_param=$(echo "$line" |\
|
||||
sed "s/^\"//g;s/\"$//g")
|
||||
eval config_key_current_value=\$$config_key_name
|
||||
if [ ! -z "$config_key_current_value" ]; then
|
||||
export "${config_key_name}"="$config_key_current_value$config_param"
|
||||
fi
|
||||
fi
|
||||
local is_multiline=$is_multiline_next
|
||||
done < $config_file
|
||||
}
|
||||
get8bitCode()
|
||||
{
|
||||
CODE=$1
|
||||
case $CODE in
|
||||
default)
|
||||
echo 9
|
||||
;;
|
||||
none)
|
||||
echo 9
|
||||
;;
|
||||
black)
|
||||
echo 0
|
||||
;;
|
||||
red)
|
||||
echo 1
|
||||
;;
|
||||
green)
|
||||
echo 2
|
||||
;;
|
||||
yellow)
|
||||
echo 3
|
||||
;;
|
||||
blue)
|
||||
echo 4
|
||||
;;
|
||||
magenta|purple|pink)
|
||||
echo 5
|
||||
;;
|
||||
cyan)
|
||||
echo 6
|
||||
;;
|
||||
light-gray)
|
||||
echo 7
|
||||
;;
|
||||
dark-gray)
|
||||
echo 60
|
||||
;;
|
||||
light-red)
|
||||
echo 61
|
||||
;;
|
||||
light-green)
|
||||
echo 62
|
||||
;;
|
||||
light-yellow)
|
||||
echo 63
|
||||
;;
|
||||
light-blue)
|
||||
echo 64
|
||||
;;
|
||||
light-magenta|light-purple)
|
||||
echo 65
|
||||
;;
|
||||
light-cyan)
|
||||
echo 66
|
||||
;;
|
||||
white)
|
||||
echo 67
|
||||
;;
|
||||
*)
|
||||
echo 0
|
||||
esac
|
||||
}
|
||||
getColorCode()
|
||||
{
|
||||
COLOR=$1
|
||||
if [ $COLOR -eq $COLOR ] 2> /dev/null; then
|
||||
if [ $COLOR -gt 0 -a $COLOR -lt 256 ]; then
|
||||
echo "38;5;$COLOR"
|
||||
else
|
||||
echo 0
|
||||
fi
|
||||
else
|
||||
BITCODE=$(get8bitCode $COLOR)
|
||||
COLORCODE=$(($BITCODE + 30))
|
||||
echo $COLORCODE
|
||||
fi
|
||||
}
|
||||
getBackgroundCode()
|
||||
{
|
||||
COLOR=$1
|
||||
if [ $COLOR -eq $COLOR ] 2> /dev/null; then
|
||||
if [ $COLOR -gt 0 -a $COLOR -lt 256 ]; then
|
||||
echo "48;5;$COLOR"
|
||||
else
|
||||
echo 0
|
||||
fi
|
||||
else
|
||||
BITCODE=$(get8bitCode $COLOR)
|
||||
COLORCODE=$(($BITCODE + 40))
|
||||
echo $COLORCODE
|
||||
fi
|
||||
}
|
||||
getEffectCode()
|
||||
{
|
||||
EFFECT=$1
|
||||
NONE=0
|
||||
case $EFFECT in
|
||||
none)
|
||||
echo $NONE
|
||||
;;
|
||||
default)
|
||||
echo $NONE
|
||||
;;
|
||||
bold)
|
||||
echo 1
|
||||
;;
|
||||
bright)
|
||||
echo 1
|
||||
;;
|
||||
dim)
|
||||
echo 2
|
||||
;;
|
||||
underline)
|
||||
echo 4
|
||||
;;
|
||||
blink)
|
||||
echo 5
|
||||
;;
|
||||
reverse)
|
||||
echo 7
|
||||
;;
|
||||
hidden)
|
||||
echo 8
|
||||
;;
|
||||
strikeout)
|
||||
echo 9
|
||||
;;
|
||||
*)
|
||||
echo $NONE
|
||||
esac
|
||||
}
|
||||
getFormattingSequence()
|
||||
{
|
||||
START='\e[0;'
|
||||
MIDLE=$1
|
||||
END='m'
|
||||
echo -n "$START$MIDLE$END"
|
||||
}
|
||||
applyCodeToText()
|
||||
{
|
||||
local RESET=$(getFormattingSequence $(getEffectCode none))
|
||||
TEXT=$1
|
||||
CODE=$2
|
||||
echo -n "$CODE$TEXT$RESET"
|
||||
}
|
||||
getFormatCode()
|
||||
{
|
||||
local RESET=$(getFormattingSequence $(getEffectCode none))
|
||||
if [ "$#" -eq 0 ]; then
|
||||
echo -n "$RESET"
|
||||
elif [ "$#" -eq 1 ]; then
|
||||
TEXT_COLOR=$(getFormattingSequence $(getColorCode $1))
|
||||
echo -n "$TEXT_COLOR"
|
||||
else
|
||||
FORMAT=""
|
||||
while [ "$1" != "" ]; do
|
||||
TYPE=$1
|
||||
ARGUMENT=$2
|
||||
case $TYPE in
|
||||
-c)
|
||||
CODE=$(getColorCode $ARGUMENT)
|
||||
;;
|
||||
-b)
|
||||
CODE=$(getBackgroundCode $ARGUMENT)
|
||||
;;
|
||||
-e)
|
||||
CODE=$(getEffectCode $ARGUMENT)
|
||||
;;
|
||||
*)
|
||||
CODE=""
|
||||
esac
|
||||
if [ "$FORMAT" != "" ]; then
|
||||
FORMAT="$FORMAT;"
|
||||
fi
|
||||
FORMAT="$FORMAT$CODE"
|
||||
shift
|
||||
shift
|
||||
done
|
||||
FORMAT_CODE=$(getFormattingSequence $FORMAT)
|
||||
echo -n "${FORMAT_CODE}"
|
||||
fi
|
||||
}
|
||||
formatText()
|
||||
{
|
||||
local RESET=$(getFormattingSequence $(getEffectCode none))
|
||||
if [ "$#" -eq 0 ]; then
|
||||
echo -n "${RESET}"
|
||||
elif [ "$#" -eq 1 ]; then
|
||||
TEXT=$1
|
||||
echo -n "${TEXT}${RESET}"
|
||||
else
|
||||
TEXT=$1
|
||||
FORMAT_CODE=$(getFormatCode "${@:2}")
|
||||
applyCodeToText "$TEXT" "$FORMAT_CODE"
|
||||
fi
|
||||
}
|
||||
removeColorCodes()
|
||||
{
|
||||
printf "$1" | sed 's/\x1b\[[0-9;]*m//g'
|
||||
}
|
||||
shortenPath()
|
||||
{
|
||||
local path=$1
|
||||
local max_length=$2
|
||||
local default_max_length=25
|
||||
local trunc_symbol=".."
|
||||
if [ -z "$path" ]; then
|
||||
echo ""
|
||||
exit
|
||||
elif [ -z "$max_length" ]; then
|
||||
local max_length=$default_max_length
|
||||
fi
|
||||
local path=${path/#$HOME/\~}
|
||||
local dir=${path##*/}
|
||||
local dir_length=${#dir}
|
||||
local path_length=${#path}
|
||||
local print_length=$(( ( max_length < dir_length ) ? dir_length : max_length ))
|
||||
if [ $path_length -gt $print_length ]; then
|
||||
local offset=$(( $path_length - $print_length ))
|
||||
local truncated_path=${path:$offset}
|
||||
local clean_path=${truncated_path#*/}
|
||||
local short_path=${trunc_symbol}/${clean_path}
|
||||
else
|
||||
local short_path=$path
|
||||
fi
|
||||
echo $short_path
|
||||
}
|
||||
enableTerminalLineWrap()
|
||||
{
|
||||
printf '\e[?7h'
|
||||
}
|
||||
disableTerminalLineWrap()
|
||||
{
|
||||
printf '\e[?7l'
|
||||
}
|
||||
saveCursorPosition()
|
||||
{
|
||||
printf "\e[s"
|
||||
}
|
||||
moveCursorToSavedPosition()
|
||||
{
|
||||
printf "\e[u"
|
||||
}
|
||||
moveCursorToRowCol()
|
||||
{
|
||||
local row=$1
|
||||
local col=$2
|
||||
printf "\e[${row};${col}H"
|
||||
}
|
||||
moveCursorHome()
|
||||
{
|
||||
printf "\e[;H"
|
||||
}
|
||||
moveCursorUp()
|
||||
{
|
||||
local inc=$1
|
||||
if [ -z "$inc" ]; then
|
||||
printf "\e[1A"
|
||||
elif [ $inc -gt 0 ]; then
|
||||
printf "\e[${inc}A"
|
||||
fi
|
||||
}
|
||||
moveCursorDown()
|
||||
{
|
||||
local inc=$1
|
||||
if [ -z "$inc" ]; then
|
||||
printf "\e[1B"
|
||||
elif [ $inc -gt 0 ]; then
|
||||
printf "\e[${inc}B"
|
||||
fi
|
||||
}
|
||||
moveCursorRight()
|
||||
{
|
||||
local inc=$1
|
||||
if [ -z "$inc" ]; then
|
||||
printf "\e[1C"
|
||||
elif [ $inc -gt 0 ]; then
|
||||
printf "\e[${inc}D"
|
||||
fi
|
||||
}
|
||||
moveCursorLeft()
|
||||
{
|
||||
local inc=$1
|
||||
if [ -z "$inc" ]; then
|
||||
printf "\e[1D"
|
||||
elif [ $inc -gt 0 ]; then
|
||||
printf "\e[${inc}C"
|
||||
fi
|
||||
}
|
||||
getTerminalNumRows()
|
||||
{
|
||||
tput lines
|
||||
}
|
||||
getTerminalNumCols()
|
||||
{
|
||||
tput cols
|
||||
}
|
||||
getTextNumRows()
|
||||
{
|
||||
local rows=$(echo -e "$1" | wc -l )
|
||||
echo "$rows"
|
||||
}
|
||||
getTextNumCols()
|
||||
{
|
||||
local columns=$(echo -e "$1" | sed 's/\x1b\[[0-9;]*m//g' | wc -L )
|
||||
echo "$columns"
|
||||
}
|
||||
getTextShape()
|
||||
{
|
||||
echo "$(getTextNumRows) $(getTextNumCols)"
|
||||
}
|
||||
printWithOffset()
|
||||
{
|
||||
local row=$1
|
||||
local col=$2
|
||||
local text=${@:3}
|
||||
moveCursorDown "$row"
|
||||
if [ $col -gt 0 ]; then
|
||||
col_spacer="\\\\e[${col}C"
|
||||
local text=$(echo "$text" |\
|
||||
sed "s/^/$col_spacer/g;s/\\\\n/\\\\n$col_spacer/g")
|
||||
fi
|
||||
disableTerminalLineWrap
|
||||
echo -e "${text}"
|
||||
enableTerminalLineWrap
|
||||
}
|
||||
printTwoElementsSideBySide()
|
||||
{
|
||||
local element_1=$1
|
||||
local element_2=$2
|
||||
local print_cols_max=$3
|
||||
local term_cols=$(getTerminalNumCols)
|
||||
if [ ! -z "$print_cols_max" ]; then
|
||||
local term_cols=$(( ( $term_cols > $print_cols_max ) ?\
|
||||
$print_cols_max : $term_cols ))
|
||||
fi
|
||||
local e_1_cols=$(getTextNumCols "$element_1")
|
||||
local e_1_rows=$(getTextNumRows "$element_1")
|
||||
local e_2_cols=$(getTextNumCols "$element_2")
|
||||
local e_2_rows=$(getTextNumRows "$element_2")
|
||||
local free_cols=$(( $term_cols - $e_1_cols - $e_2_cols ))
|
||||
if [ $free_cols -lt 1 ]; then
|
||||
local free_cols=0
|
||||
fi
|
||||
if [ $e_1_cols -gt 0 ] && [ $e_2_cols -gt 0 ]; then
|
||||
local h_pad=$(( $free_cols/3 ))
|
||||
local e_1_h_pad=$h_pad
|
||||
local e_2_h_pad=$(( $e_1_cols + 2*$h_pad ))
|
||||
elif [ $e_1_cols -gt 0 ]; then
|
||||
local h_pad=$(( $free_cols/2 ))
|
||||
local e_1_h_pad=$h_pad
|
||||
local e_2_h_pad=0
|
||||
elif [ $e_2_cols -gt 0 ]; then
|
||||
local h_pad=$(( $free_cols/2 ))
|
||||
local e_1_h_pad=0
|
||||
local e_2_h_pad=$h_pad
|
||||
else
|
||||
local e_1_h_pad=0
|
||||
local e_2_h_pad=0
|
||||
fi
|
||||
local e_1_v_pad=$(( ( $e_1_rows > $e_2_rows ) ?\
|
||||
0 : (( ($e_2_rows - $e_1_rows)/2 )) ))
|
||||
local e_2_v_pad=$(( ( $e_2_rows > $e_1_rows ) ?\
|
||||
0 : (( ($e_1_rows - $e_2_rows)/2 )) ))
|
||||
local max_rows=$(( ( $e_1_rows > $e_2_rows ) ? $e_1_rows : $e_2_rows ))
|
||||
for i in `seq $max_rows`; do printf "\n"; done
|
||||
moveCursorUp $max_rows
|
||||
saveCursorPosition
|
||||
printWithOffset $e_1_v_pad $e_1_h_pad "$element_1"
|
||||
moveCursorToSavedPosition
|
||||
printWithOffset $e_2_v_pad $e_2_h_pad "$element_2"
|
||||
moveCursorToSavedPosition
|
||||
moveCursorDown $(( $max_rows ))
|
||||
}
|
||||
function better_ls()
|
||||
{
|
||||
shopt -s extglob
|
||||
local LS="$(type -P ls)"
|
||||
if [ $# -eq 0 ]; then
|
||||
files=$($LS -U . 2> /dev/null | wc -l)
|
||||
if [ "$files" != "0" ]
|
||||
then
|
||||
$LS -d {.,..,*} -lA --color=auto --human-readable \
|
||||
--time-style=long-iso --group-directories-first;
|
||||
hidden_files=$($LS -U -d .[^.]* 2> /dev/null | wc -l)
|
||||
if [ "$hidden_files" != "0" ]
|
||||
then
|
||||
echo ""
|
||||
$LS -d .[^.]* -l --color=auto --hide='..' \
|
||||
--human-readable --time-style=long-iso \
|
||||
--group-directories-first;
|
||||
fi
|
||||
else
|
||||
$LS -d {.,..,} -lA --color=auto --human-readable \
|
||||
--time-style=long-iso --group-directories-first;
|
||||
fi
|
||||
elif [ $# -eq 1 -a -d "$1" ]; then
|
||||
local current_pwd="$PWD"
|
||||
'cd' "$1/"
|
||||
better_ls
|
||||
'cd' "$current_pwd"
|
||||
elif [ $# -eq 1 -a -f "$1" ]; then
|
||||
$LS -l --color=auto --human-readable --time-style=long-iso "$1"
|
||||
else
|
||||
$LS --color=auto --human-readable --time-style=long-iso \
|
||||
--group-directories-first "$@";
|
||||
fi
|
||||
}
|
||||
alias l='better_ls'
|
|
@ -0,0 +1,151 @@
|
|||
##==============================================================================
|
||||
## LOGO
|
||||
##==============================================================================
|
||||
|
||||
logo=" \e[1;34m_\/_
|
||||
\e[1;34m/\\
|
||||
\e[0m___ _ _____ ___ ___ \e[1;34m#
|
||||
\e[0m/ __| /_\_ _| __/ __| \e[1;34m#
|
||||
\e[1;34m#\e[0m | (__ / _ \| | | _| (_\e[1;34m##
|
||||
\e[1;34m##\e[0m\___/_/ \_\_| |___\\e[1;34m##\e[0m__|
|
||||
\e[1;34m####\e[0m \e[1;34m#######
|
||||
\e[1;34m########\e[0m\n"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## STATUS INFO
|
||||
##
|
||||
## Choose what to print and in what order
|
||||
## Valid options are:
|
||||
##
|
||||
## ## SIMPLE ONE-LINERS
|
||||
## OS Linux distribution name
|
||||
## KERNEL Kernel version
|
||||
## CPU CPU Name
|
||||
## SHELL Shell name
|
||||
## DATE Current date
|
||||
## UPTIME System uptime (time since boot)
|
||||
## USER Current user and host names
|
||||
## NUMLOGGED Show number of logged in users
|
||||
## NAMELOGGED Show names of logged in users
|
||||
## LOCALIPV4 IPv4
|
||||
## EXTERNALIPV4 External IPv4 (might be slow)
|
||||
## SERVICES Summary of failed services
|
||||
## CPULOAD Sys load average(eg. 0.23, 0.26, 0.27 )
|
||||
## CPUTEMP CPU temperature (requires lm-sensors)
|
||||
##
|
||||
## ## SYS LOAD MONITORS
|
||||
## SYSLOAD_MON Current CPU load
|
||||
## MEMORY_MON Occupied memory
|
||||
## SWAP_MON Occupied SWAP
|
||||
## HDDROOT_MON / partition occupied
|
||||
## HDDHOME_MON /home/user occupied
|
||||
## CPUTEMP_MON CPU temperature (requires lm-sensors)
|
||||
## SYSLOAD_MON% Current CPU load in %
|
||||
## MEMORY_MON% Occupied memory in %
|
||||
## SWAP_MON% Occupied SWAP in %
|
||||
## HDDROOT_MON% / partition occupied in %
|
||||
## HDDHOME_MON% /home/user occupied in %
|
||||
##
|
||||
## ## MISC
|
||||
## SPACER Print decorative spacer (empty line)
|
||||
## PALETTE Show 16-bit palette (add SPACER before for best results)
|
||||
## PALETTE_SMALL Show smaller version of 16-bit color palette
|
||||
##
|
||||
##==============================================================================
|
||||
|
||||
print_info="
|
||||
OS
|
||||
KERNEL
|
||||
CPU
|
||||
GPU
|
||||
SHELL
|
||||
DATE
|
||||
UPTIME
|
||||
LOCALIPV4
|
||||
EXTERNALIPV4
|
||||
SERVICES
|
||||
CPUTEMP
|
||||
SYSLOAD_MON%
|
||||
MEMORY_MON
|
||||
SWAP_MON
|
||||
HDDROOT_MON
|
||||
HDDHOME_MON"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## COLORS
|
||||
##
|
||||
## Control the color and format scheme of the status report.
|
||||
## -c color: color name or 256bit color code
|
||||
## -b background color: color name or 256bit color code
|
||||
## -e effect: bold, blink, dim, underline...
|
||||
##
|
||||
## Valid color names (16 bit):
|
||||
## white, light-gray, dark-gray, black,
|
||||
## red, green, yellow, blue, magenta, cyan,
|
||||
## light-red, light-green, light-yellow, light-blue, light-magenta, light-cyan
|
||||
##
|
||||
##==============================================================================
|
||||
|
||||
format_info=" -c white"
|
||||
format_highlight=" -c blue -e bold"
|
||||
format_crit=" -c 208 -e bold"
|
||||
format_deco=" -c white -e bold"
|
||||
format_ok=" -c blue -e bold"
|
||||
format_error=" -c 208 -e bold -e blink"
|
||||
format_logo=" -c blue -e bold"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## STATUS BARS
|
||||
##
|
||||
## These option controls the behaviour of the visual status bars that are
|
||||
## plotted for CPU, Memory, Swap and HDD usage. You can set the percentage that
|
||||
## determines when the current usage is deemed critical. If said percentage
|
||||
## is surpassed, the color of the bars will change and extra information
|
||||
## might be plotted in addition (e.g. if the CPU usage is too high, the most
|
||||
## demanding processes are printed to terminal).
|
||||
##==============================================================================
|
||||
|
||||
bar_cpu_crit_percent=40
|
||||
bar_ram_crit_percent=75
|
||||
bar_swap_crit_percent=25
|
||||
bar_hdd_crit_percent=85
|
||||
bar_home_crit_percent=85
|
||||
|
||||
bar_ram_units="MB"
|
||||
bar_swap_units="MB"
|
||||
bar_hdd_units="GB"
|
||||
bar_home_units="GB"
|
||||
|
||||
cpu_crit_print=true
|
||||
cpu_crit_print_num=3
|
||||
ram_crit_print=true
|
||||
ram_crit_print_num=3
|
||||
|
||||
bar_length=9 # Number of characters that comprise a bar
|
||||
bar_num_digits=5 # Control num digits next to bar
|
||||
bar_padding_after=0 # Extra spaces after bar
|
||||
info_label_width=16 # Desired length of the info labels
|
||||
bar_bracket_char_left='['
|
||||
bar_bracket_char_right=']'
|
||||
bar_fill_char='|'
|
||||
bar_background_char=' '
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## OTHERS
|
||||
##
|
||||
## For date format setup, see `man date`
|
||||
##==============================================================================
|
||||
|
||||
print_cols_max=100 # Keep logo and info text together
|
||||
print_logo_right=false # Change where the logo is plotted
|
||||
date_format="%Y.%m.%d - %T" # see 'man date'
|
||||
clear_before_print=false # Dangerous if true, some messages might be lost
|
||||
print_extra_new_line_top=true # Extra line before logo and info
|
||||
print_extra_new_line_bot=true # Extra line after logo and info
|
|
@ -0,0 +1,33 @@
|
|||
##==============================================================================
|
||||
## LOGO
|
||||
##==============================================================================
|
||||
|
||||
logo="
|
||||
\e[1;30m▄▄▄\e[107m█▀▀▀▀▀█\e[0;30m▄▄▄
|
||||
\e[1;30m▄\e[107m█▀▀ ▄▄▄▄▄▄▄▄▄ ▀▀█\e[0;30m▄
|
||||
\e[1;30m▄\e[107m█▀ ▄█▀▀ ▀▀█▄ ▀█\e[0;30m▄
|
||||
\e[1;30m\e[107m█▀ ▄█▀ ·\ ▀█▄ ▀█\e[0;30m
|
||||
\e[1;30m\e[107m█▀ █▀ (( o )) @ .▀█ ▀█\e[0;30m
|
||||
\e[1;30m▄\e[107m█ █▀ \e[104m \e[107m | . \ ▀█ █\e[0;30m▄
|
||||
\e[1;30m\e[107m█ █ \e[104m \e[107m /X\ █ █\e[0;30m
|
||||
\e[1;30m\e[107m█ █__\e[104m___ />\e[107mX<\ ><>< █ █\e[0;30m
|
||||
\e[1;30m\e[107m█▄ █\e[104m||||| /><X><\ \/ \e[107m█ ▄█\e[0;30m
|
||||
\e[1;30m\e[107m█ ▀█\e[40m \e[107m█▀ █\e[0;30m
|
||||
\e[1;30m▀\e[107m█ ▀█\e[40m▄ \e[97mEA7·RCT\e[30m ▄\e[107m█▀ █\e[0;30m▀
|
||||
\e[1;30m▀\e[107m█▄ ▀█\e[40m▄ \e[0;97;40mIM76-SR\e[1;30m ▄\e[107m█▀ ▄█\e[0;30m▀
|
||||
\e[1;30m▀\e[107m█▄ ▀▀\e[40m█▄▄▄▄▄▄▄\e[107m█▀▀ ▄█\e[0;30m▀
|
||||
\e[1;30m▀▀\e[107m█▄▄▄ ▄▄▄█\e[0;30m▀▀
|
||||
\e[1;30m▀▀▀▀▀▀▀\e[0;30m"
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## COLORS
|
||||
##==============================================================================
|
||||
|
||||
format_info=" -c white"
|
||||
format_highlight=" -c light-blue -e bold"
|
||||
format_crit=" -c blue -e bold"
|
||||
format_deco=" -c white -e bold"
|
||||
format_ok=" -c light-blue -e bold"
|
||||
format_error=" -c blue -e bold -e blink"
|
||||
format_logo=" -c light-blue -e bold"
|
|
@ -0,0 +1,29 @@
|
|||
##==============================================================================
|
||||
## LOGO
|
||||
##==============================================================================
|
||||
|
||||
## MAPIR (UMA) Robotics Research Group
|
||||
logo="
|
||||
__ __ _ ___ ___ ___
|
||||
| \\/ | /_\\ | _ \\_ _| _ \\
|
||||
| |\\/| |/ _ \\| _/| || /
|
||||
|_| |_/_/ \\_\\_| |___|_|_\\
|
||||
|
||||
MACHINE PERCEPTION AND
|
||||
INTELLIGENT ROBOTICS
|
||||
mapir.uma.es
|
||||
"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## COLORS
|
||||
##==============================================================================
|
||||
|
||||
format_info=" -c white"
|
||||
format_highlight=" -c cyan -e bold"
|
||||
format_crit=" -c 208 -e bold"
|
||||
format_deco=" -c white -e bold"
|
||||
format_ok=" -c cyan -e bold"
|
||||
format_error=" -c 208 -e bold -e blink"
|
||||
format_logo=" -c cyan -e bold"
|
|
@ -0,0 +1,29 @@
|
|||
##==============================================================================
|
||||
## LOGO
|
||||
##==============================================================================
|
||||
|
||||
## MAPIR (UMA) Robotics Research Group
|
||||
logo="
|
||||
__ __ _ ___ ___ ___
|
||||
| \\/ | /_\\ | _ \\_ _| _ \\
|
||||
| |\\/| |/ _ \\| _/| || /
|
||||
|_| |_/_/ \\_\\_| |___|_|_\\
|
||||
|
||||
MACHINE PERCEPTION AND
|
||||
INTELLIGENT ROBOTICS
|
||||
mapir.uma.es
|
||||
"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## COLORS
|
||||
##==============================================================================
|
||||
|
||||
format_info=" -c white"
|
||||
format_highlight=" -c light-gray -e bold"
|
||||
format_crit=" -c 208 -e bold"
|
||||
format_deco=" -c white -e bold"
|
||||
format_ok=" -c light-gray -e bold"
|
||||
format_error=" -c 208 -e bold -e blink"
|
||||
format_logo=" -c light-gray -e bold"
|
|
@ -0,0 +1,29 @@
|
|||
##==============================================================================
|
||||
## LOGO
|
||||
##==============================================================================
|
||||
|
||||
## MAPIR (UMA) Robotics Research Group
|
||||
logo="
|
||||
__ __ _ ___ ___ ___
|
||||
| \\/ | /_\\ | _ \\_ _| _ \\
|
||||
| |\\/| |/ _ \\| _/| || /
|
||||
|_| |_/_/ \\_\\_| |___|_|_\\
|
||||
|
||||
MACHINE PERCEPTION AND
|
||||
INTELLIGENT ROBOTICS
|
||||
mapir.uma.es
|
||||
"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## COLORS
|
||||
##==============================================================================
|
||||
|
||||
format_info=" -c white"
|
||||
format_highlight=" -c green -e bold"
|
||||
format_crit=" -c 208 -e bold"
|
||||
format_deco=" -c white -e bold"
|
||||
format_ok=" -c green -e bold"
|
||||
format_error=" -c 208 -e bold -e blink"
|
||||
format_logo=" -c green -e bold"
|
|
@ -0,0 +1,29 @@
|
|||
##==============================================================================
|
||||
## LOGO
|
||||
##==============================================================================
|
||||
|
||||
## MAPIR (UMA) Robotics Research Group
|
||||
logo="
|
||||
__ __ _ ___ ___ ___
|
||||
| \\/ | /_\\ | _ \\_ _| _ \\
|
||||
| |\\/| |/ _ \\| _/| || /
|
||||
|_| |_/_/ \\_\\_| |___|_|_\\
|
||||
|
||||
MACHINE PERCEPTION AND
|
||||
INTELLIGENT ROBOTICS
|
||||
mapir.uma.es
|
||||
"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## COLORS
|
||||
##==============================================================================
|
||||
|
||||
format_info=" -c white"
|
||||
format_highlight=" -c 208 -e bold"
|
||||
format_crit=" -c red -e bold"
|
||||
format_deco=" -c white -e bold"
|
||||
format_ok=" -c 208 -e bold"
|
||||
format_error=" -c red -e bold -e blink"
|
||||
format_logo=" -c 208 -e bold"
|
|
@ -0,0 +1,61 @@
|
|||
##==============================================================================
|
||||
## LOGO
|
||||
##==============================================================================
|
||||
|
||||
logo="\e[49;34m
|
||||
▗▖ \e[94m▗▖\e[34m ▗▖
|
||||
▗▟█\e[104;34m▛\e[44;94m▟█▛\e[104;34m▟\e[49;34m██▙▖
|
||||
▗▟█\e[104;34m▛▘ \e[44;94m▛\e[104;34m▟\e[49;34m██████▙▖
|
||||
▗▟█\e[104;34m▛▘ \e[44;94m▛\e[104;34m▟\e[49;34m██████████▙▖
|
||||
▝▜█\e[104;34m▙▖ \e[44;94m▙▖\e[49;34m████████▛▘
|
||||
▝▜█\e[104;34m▙▖ \e[44;94m▙▖\e[49;34m████▛▘
|
||||
▝▜▛▘\e[49;94m▜▛\e[49;34m▝▜▛▘
|
||||
|
||||
\e[49;94mscbi
|
||||
Universidad de Malaga\n"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## COLORS
|
||||
##==============================================================================
|
||||
|
||||
format_info=" -c white"
|
||||
format_highlight=" -c blue -e bold"
|
||||
format_crit=" -c 208 -e bold"
|
||||
format_deco=" -c white -e bold"
|
||||
format_ok=" -c blue -e bold"
|
||||
format_error=" -c 208 -e bold -e blink"
|
||||
format_logo=" -c blu -e bold"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## STATUS INFO
|
||||
##==============================================================================
|
||||
|
||||
print_info="
|
||||
OS
|
||||
KERNEL
|
||||
CPU
|
||||
SHELL
|
||||
DATE
|
||||
UPTIME
|
||||
SERVICES
|
||||
CPUTEMP
|
||||
SYSLOAD_MON%
|
||||
MEMORY_MON
|
||||
SWAP_MON
|
||||
HDDROOT_MON
|
||||
HDDHOME_MON"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## STATUS BARS
|
||||
##==============================================================================
|
||||
bar_memory_units="GB"
|
||||
bar_swap_units="GB"
|
||||
bar_hdd_units="GB"
|
||||
bar_home_units="TB"
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
##==============================================================================
|
||||
## COLORS
|
||||
##
|
||||
## Control the color and format scheme of the bash prompt.
|
||||
## The prompt is divided into segments, listed below starting from the left:
|
||||
## - USER: shows the user's name.
|
||||
## - HOST: shows the host's name.
|
||||
## - PWD: shows the current directory.
|
||||
## - GIT: if inside a git repository, shows the name of current branch.
|
||||
## - INPUT: actual bash input.
|
||||
##
|
||||
## Valid color options:
|
||||
## - white black light-gray dark-gray
|
||||
## red green yellow blue cyan purple
|
||||
## light-red light-green light-yellow light-blue light-cyan light-purple
|
||||
## - Values in the range [0-255] for 256 bit colors. To check all number-color
|
||||
## pairs for your terminal, you may run the following snippet by HaleTom:
|
||||
## curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash
|
||||
## or search something like "bash 256 color codes" on the internet.
|
||||
##
|
||||
##==============================================================================
|
||||
|
||||
font_color_user="white"
|
||||
background_user="blue"
|
||||
texteffect_user="bold"
|
||||
|
||||
font_color_host="white"
|
||||
background_host="light-blue"
|
||||
texteffect_host="bold"
|
||||
|
||||
font_color_pwd="dark-gray"
|
||||
background_pwd="white"
|
||||
texteffect_pwd="bold"
|
||||
|
||||
font_color_git="light-gray"
|
||||
background_git="dark-gray"
|
||||
texteffect_git="bold"
|
||||
|
||||
font_color_input="cyan"
|
||||
background_input="none"
|
||||
texteffect_input="bold"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## BEHAVIOR
|
||||
##==============================================================================
|
||||
local separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
|
||||
enable_vertical_padding=true # Add extra new line over prompt
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## GIT
|
||||
##==============================================================================
|
||||
show_git=true # Enable/Disable git info if inside a repo
|
||||
git_symbol_synced=''
|
||||
git_symbol_unpushed='△'
|
||||
git_symbol_unpulled='▽'
|
||||
git_symbol_unpushedunpulled='○'
|
||||
git_symbol_dirty='!'
|
||||
git_symbol_dirty_unpushed='▲'
|
||||
git_symbol_dirty_unpulled='▼'
|
||||
git_symbol_dirty_unpushedunpulled='●'
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
##==============================================================================
|
||||
## COLORS
|
||||
##
|
||||
## Control the color and format scheme of the bash prompt.
|
||||
## The prompt is divided into segments, listed below starting from the left:
|
||||
## - USER: shows the user's name.
|
||||
## - HOST: shows the host's name.
|
||||
## - PWD: shows the current directory.
|
||||
## - GIT: if inside a git repository, shows the name of current branch.
|
||||
## - INPUT: actual bash input.
|
||||
##
|
||||
## Valid color options:
|
||||
## - white black light-gray dark-gray
|
||||
## red green yellow blue cyan purple
|
||||
## light-red light-green light-yellow light-blue light-cyan light-purple
|
||||
## - Values in the range [0-255] for 256 bit colors. To check all number-color
|
||||
## pairs for your terminal, you may run the following snippet by HaleTom:
|
||||
## curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash
|
||||
## or search something like "bash 256 color codes" on the internet.
|
||||
##
|
||||
##==============================================================================
|
||||
|
||||
font_color_user="white"
|
||||
background_user="black"
|
||||
texteffect_user="bold"
|
||||
|
||||
font_color_host="white"
|
||||
background_host="dark-gray"
|
||||
texteffect_host="bold"
|
||||
|
||||
font_color_pwd="black"
|
||||
background_pwd="light-gray"
|
||||
texteffect_pwd="bold"
|
||||
|
||||
font_color_git="black"
|
||||
background_git="white"
|
||||
texteffect_git="bold"
|
||||
|
||||
font_color_input="none"
|
||||
background_input="none"
|
||||
texteffect_input="bold"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## BEHAVIOR
|
||||
##==============================================================================
|
||||
local separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
|
||||
enable_vertical_padding=true # Add extra new line over prompt
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## GIT
|
||||
##==============================================================================
|
||||
show_git=true # Enable/Disable git info if inside a repo
|
||||
git_symbol_synced=''
|
||||
git_symbol_unpushed='△'
|
||||
git_symbol_unpulled='▽'
|
||||
git_symbol_unpushedunpulled='○'
|
||||
git_symbol_dirty='!'
|
||||
git_symbol_dirty_unpushed='▲'
|
||||
git_symbol_dirty_unpulled='▼'
|
||||
git_symbol_dirty_unpushedunpulled='●'
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
##==============================================================================
|
||||
## COLORS
|
||||
##
|
||||
## Control the color and format scheme of the bash prompt.
|
||||
## The prompt is divided into segments, listed below starting from the left:
|
||||
## - USER: shows the user's name.
|
||||
## - HOST: shows the host's name.
|
||||
## - PWD: shows the current directory.
|
||||
## - GIT: if inside a git repository, shows the name of current branch.
|
||||
## - INPUT: actual bash input.
|
||||
##
|
||||
## Valid color options:
|
||||
## - white black light-gray dark-gray
|
||||
## red green yellow blue cyan purple
|
||||
## light-red light-green light-yellow light-blue light-cyan light-purple
|
||||
## - Values in the range [0-255] for 256 bit colors. To check all number-color
|
||||
## pairs for your terminal, you may run the following snippet by HaleTom:
|
||||
## curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash
|
||||
## or search something like "bash 256 color codes" on the internet.
|
||||
##
|
||||
##==============================================================================
|
||||
|
||||
font_color_user="light-gray"
|
||||
background_user="green"
|
||||
texteffect_user="bold"
|
||||
|
||||
font_color_host="black"
|
||||
background_host="light-green"
|
||||
texteffect_host="bold"
|
||||
|
||||
font_color_pwd="dark-gray"
|
||||
background_pwd="light-gray"
|
||||
texteffect_pwd="bold"
|
||||
|
||||
font_color_git="light-gray"
|
||||
background_git="dark-gray"
|
||||
texteffect_git="bold"
|
||||
|
||||
font_color_input="green"
|
||||
background_input="none"
|
||||
texteffect_input="bold"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## BEHAVIOR
|
||||
##==============================================================================
|
||||
local separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
|
||||
enable_vertical_padding=true # Add extra new line over prompt
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## GIT
|
||||
##==============================================================================
|
||||
show_git=true # Enable/Disable git info if inside a repo
|
||||
git_symbol_synced=''
|
||||
git_symbol_unpushed='△'
|
||||
git_symbol_unpulled='▽'
|
||||
git_symbol_unpushedunpulled='○'
|
||||
git_symbol_dirty='!'
|
||||
git_symbol_dirty_unpushed='▲'
|
||||
git_symbol_dirty_unpulled='▼'
|
||||
git_symbol_dirty_unpushedunpulled='●'
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
##==============================================================================
|
||||
## COLORS
|
||||
##==============================================================================
|
||||
|
||||
font_color_user="white"
|
||||
background_user="magenta"
|
||||
texteffect_user="bold"
|
||||
|
||||
font_color_host="white"
|
||||
background_host="light-magenta"
|
||||
texteffect_host="bold"
|
||||
|
||||
font_color_pwd="dark-gray"
|
||||
background_pwd="white"
|
||||
texteffect_pwd="bold"
|
||||
|
||||
font_color_git="light-gray"
|
||||
background_git="dark-gray"
|
||||
texteffect_git="bold"
|
||||
|
||||
font_color_input="light-magenta"
|
||||
background_input="none"
|
||||
texteffect_input="bold"
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
##==============================================================================
|
||||
## COLORS
|
||||
##
|
||||
## Control the color and format scheme of the bash prompt.
|
||||
## The prompt is divided into segments, listed below starting from the left:
|
||||
## - USER: shows the user's name.
|
||||
## - HOST: shows the host's name.
|
||||
## - PWD: shows the current directory.
|
||||
## - GIT: if inside a git repository, shows the name of current branch.
|
||||
## - INPUT: actual bash input.
|
||||
##
|
||||
## Valid color options:
|
||||
## - white black light-gray dark-gray
|
||||
## red green yellow blue cyan purple
|
||||
## light-red light-green light-yellow light-blue light-cyan light-purple
|
||||
## - Values in the range [0-255] for 256 bit colors. To check all number-color
|
||||
## pairs for your terminal, you may run the following snippet by HaleTom:
|
||||
## curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash
|
||||
## or search something like "bash 256 color codes" on the internet.
|
||||
##
|
||||
##==============================================================================
|
||||
|
||||
font_color_user="black"
|
||||
background_user="208"
|
||||
texteffect_user="bold"
|
||||
|
||||
font_color_host="black"
|
||||
background_host="180"
|
||||
texteffect_host="bold"
|
||||
|
||||
font_color_pwd="black"
|
||||
background_pwd="white"
|
||||
texteffect_pwd="bold"
|
||||
|
||||
font_color_git="208"
|
||||
background_git="dark-gray"
|
||||
texteffect_git="bold"
|
||||
|
||||
font_color_input="208"
|
||||
background_input="none"
|
||||
texteffect_input="bold"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## BEHAVIOR
|
||||
##==============================================================================
|
||||
local separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
|
||||
enable_vertical_padding=true # Add extra new line over prompt
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## GIT
|
||||
##==============================================================================
|
||||
show_git=true # Enable/Disable git info if inside a repo
|
||||
git_symbol_synced=''
|
||||
git_symbol_unpushed='△'
|
||||
git_symbol_unpulled='▽'
|
||||
git_symbol_unpushedunpulled='○'
|
||||
git_symbol_dirty='!'
|
||||
git_symbol_dirty_unpushed='▲'
|
||||
git_symbol_dirty_unpulled='▼'
|
||||
git_symbol_dirty_unpushedunpulled='●'
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
##==============================================================================
|
||||
## COLORS
|
||||
##
|
||||
## Control the color and format scheme of the bash prompt.
|
||||
## The prompt is divided into segments, listed below starting from the left:
|
||||
## - USER: shows the user's name.
|
||||
## - HOST: shows the host's name.
|
||||
## - PWD: shows the current directory.
|
||||
## - GIT: if inside a git repository, shows the name of current branch.
|
||||
## - INPUT: actual bash input.
|
||||
##
|
||||
## Valid color options:
|
||||
## - white black light-gray dark-gray
|
||||
## red green yellow blue cyan purple
|
||||
## light-red light-green light-yellow light-blue light-cyan light-purple
|
||||
## - Values in the range [0-255] for 256 bit colors. To check all number-color
|
||||
## pairs for your terminal, you may run the following snippet by HaleTom:
|
||||
## curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash
|
||||
## or search something like "bash 256 color codes" on the internet.
|
||||
##
|
||||
##==============================================================================
|
||||
|
||||
font_color_user="light-gray"
|
||||
background_user="red"
|
||||
texteffect_user="bold"
|
||||
|
||||
font_color_host="light-gray"
|
||||
background_host="dark-gray"
|
||||
texteffect_host="bold"
|
||||
|
||||
font_color_pwd="dark-gray"
|
||||
background_pwd="light-gray"
|
||||
texteffect_pwd="bold"
|
||||
|
||||
font_color_git="black"
|
||||
background_git="white"
|
||||
texteffect_git="bold"
|
||||
|
||||
font_color_input="red"
|
||||
background_input="none"
|
||||
texteffect_input="bold"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## BEHAVIOR
|
||||
##==============================================================================
|
||||
local separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
|
||||
enable_vertical_padding=true # Add extra new line over prompt
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## GIT
|
||||
##==============================================================================
|
||||
show_git=true # Enable/Disable git info if inside a repo
|
||||
git_symbol_synced=''
|
||||
git_symbol_unpushed='△'
|
||||
git_symbol_unpulled='▽'
|
||||
git_symbol_unpushedunpulled='○'
|
||||
git_symbol_dirty='!'
|
||||
git_symbol_dirty_unpushed='▲'
|
||||
git_symbol_dirty_unpulled='▼'
|
||||
git_symbol_dirty_unpushedunpulled='●'
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
##==============================================================================
|
||||
## COLORS
|
||||
##
|
||||
## Control the color and format scheme of the bash prompt.
|
||||
## The prompt is divided into segments, listed below starting from the left:
|
||||
## - USER: shows the user's name.
|
||||
## - HOST: shows the host's name.
|
||||
## - PWD: shows the current directory.
|
||||
## - GIT: if inside a git repository, shows the name of current branch.
|
||||
## - INPUT: actual bash input.
|
||||
##
|
||||
## Valid color options:
|
||||
## - white black light-gray dark-gray
|
||||
## red green yellow blue cyan purple
|
||||
## light-red light-green light-yellow light-blue light-cyan light-purple
|
||||
## - Values in the range [0-255] for 256 bit colors. To check all number-color
|
||||
## pairs for your terminal, you may run the following snippet by HaleTom:
|
||||
## curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash
|
||||
## or search something like "bash 256 color codes" on the internet.
|
||||
##
|
||||
##==============================================================================
|
||||
|
||||
font_color_user="yellow"
|
||||
background_user="dark-gray"
|
||||
texteffect_user="bold"
|
||||
|
||||
font_color_host="black"
|
||||
background_host="yellow"
|
||||
texteffect_host="bold"
|
||||
|
||||
font_color_pwd="black"
|
||||
background_pwd="light-yellow"
|
||||
texteffect_pwd="bold"
|
||||
|
||||
font_color_git="black"
|
||||
background_git="white"
|
||||
texteffect_git="bold"
|
||||
|
||||
font_color_input="light-yellow"
|
||||
background_input="none"
|
||||
texteffect_input="bold"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## BEHAVIOR
|
||||
##==============================================================================
|
||||
local separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
|
||||
enable_vertical_padding=true # Add extra new line over prompt
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## GIT
|
||||
##==============================================================================
|
||||
show_git=true # Enable/Disable git info if inside a repo
|
||||
git_symbol_synced=''
|
||||
git_symbol_unpushed='△'
|
||||
git_symbol_unpulled='▽'
|
||||
git_symbol_unpushedunpulled='○'
|
||||
git_symbol_dirty='!'
|
||||
git_symbol_dirty_unpushed='▲'
|
||||
git_symbol_dirty_unpulled='▼'
|
||||
git_symbol_dirty_unpushedunpulled='●'
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
##==============================================================================
|
||||
## LOGO
|
||||
##==============================================================================
|
||||
|
||||
## ArchLinux theme from archey3. Slightly modified. Sources:
|
||||
## - https://wiki.archlinux.org/index.php/ASCII_art
|
||||
## - https://bbs.archlinux.org/viewtopic.php?id=24208&p=6
|
||||
|
||||
logo="\e[0;94m .
|
||||
\e[0;94m #
|
||||
\e[0;94m ###
|
||||
\e[0;94m #####
|
||||
\e[0;94m '######
|
||||
\e[0;94m .. #####:
|
||||
\e[0;94m ###.#####
|
||||
\e[0;94m ###########
|
||||
\e[0;94m ######\e[0;34m#####\e[0;94m##;
|
||||
\e[0;94m ###\e[0;34m############\e[0;94m
|
||||
\e[0;94m #\e[0;34m###### #######
|
||||
\e[0;34m :#####: :###.\`\".
|
||||
\e[0;34m :######: :####:.
|
||||
\e[0;34m :########. .########
|
||||
\e[0;34m :#####' '#####:
|
||||
\e[0;34m :#### ####:
|
||||
\e[0;34m ##' '##
|
||||
\e[0;34m #' '#
|
||||
\e[0;34m ' ' "
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## COLORS
|
||||
##==============================================================================
|
||||
|
||||
format_info=" -c white"
|
||||
format_highlight=" -c blue -e bold"
|
||||
format_crit=" -c 208 -e bold"
|
||||
format_deco=" -c white -e bold"
|
||||
format_ok=" -c blue -e bold"
|
||||
format_error=" -c 208 -e bold -e blink"
|
||||
format_logo=" -c blue -e bold"
|
|
@ -0,0 +1,37 @@
|
|||
##==============================================================================
|
||||
## LOGO
|
||||
##==============================================================================
|
||||
|
||||
## Debian logo, adapted for synth-shell. Original by metallo on the debian dev list?
|
||||
|
||||
logo=" _,met\$\$\$\$\$gg.
|
||||
,g\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$P.
|
||||
,g\$\$P\"\" \"\"\"Y\$\$.\".
|
||||
,\$\$P' \`\$\$\$.
|
||||
',\$\$P ,ggs. \`\$\$b:
|
||||
\`d\$\$' ,\$P\"' . \$\$\$
|
||||
\$\$P d\$' , \$\$P
|
||||
\$\$: \$\$. - ,d\$\$'
|
||||
\$\$; Y\$b._ _,d\$P'
|
||||
Y\$\$. \`.\`\"Y\$\$\$\$P\"'
|
||||
\`\$\$b \"-.__
|
||||
\`Y\$\$b
|
||||
\`Y\$\$.
|
||||
\`\$\$b.
|
||||
\`Y\$\$b.
|
||||
\`\"Y\$b._
|
||||
\`\"\"\"\"\n"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## COLORS
|
||||
##==============================================================================
|
||||
|
||||
format_info=" -c white"
|
||||
format_highlight=" -c red -e bold"
|
||||
format_crit=" -c light-blue -e bold"
|
||||
format_deco=" -c white -e bold"
|
||||
format_ok=" -c red -e bold"
|
||||
format_error=" -c light-blue -e bold -e blink"
|
||||
format_logo=" -c red -e bold"
|
|
@ -0,0 +1,34 @@
|
|||
##==============================================================================
|
||||
## LOGO
|
||||
##==============================================================================
|
||||
|
||||
## Manjaro Logo, simple ASCII drawing by andresgongora
|
||||
|
||||
local logo="██████████████ ██████
|
||||
██████████████ ██████
|
||||
██████████████ ██████
|
||||
██████ ██████
|
||||
██████ ██████ ██████
|
||||
██████ ██████ ██████
|
||||
██████ ██████ ██████
|
||||
██████ ██████ ██████
|
||||
██████ ██████ ██████
|
||||
██████ ██████ ██████
|
||||
██████ ██████ ██████"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## COLORS
|
||||
##==============================================================================
|
||||
|
||||
format_info=" -c dark-gray -e bold"
|
||||
format_highlight=" -c white"
|
||||
format_crit=" -c light-green -e bold"
|
||||
format_deco=" -c white -e bold"
|
||||
format_ok=" -c white -e bold"
|
||||
format_error=" -c light-green -e bold -e blink"
|
||||
format_logo=" -c light-green -e bold"
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
##==============================================================================
|
||||
## LOGO
|
||||
##==============================================================================
|
||||
|
||||
logo="\e[1;36m /////////////
|
||||
/////////////////////
|
||||
///////\e[1;37m*767 \e[1;36m////////////////
|
||||
//////\e[1;37m7676767676*\e[1;36m//////////////
|
||||
/////\e[1;37m76767\e[1;36m//\e[1;37m7676767\e[1;36m//////////////
|
||||
/////\e[1;37m767676\e[1;36m///\e[1;37m*76767\e[1;36m///////////////
|
||||
///////\e[1;37m767676\e[1;36m///\e[1;37m76767\e[1;36m.///\e[1;37m7676*\e[1;36m///////
|
||||
/////////\e[1;37m767676\e[1;36m//\e[1;37m76767\e[1;36m///\e[1;37m767676\e[1;36m////////
|
||||
//////////\e[1;37m76767676767\e[1;36m////\e[1;37m76767\e[1;36m/////////
|
||||
///////////\e[1;37m76767676\e[1;36m//////\e[1;37m7676\e[1;36m//////////
|
||||
////////////,\e[1;37m7676\e[1;36m,///////\e[1;37m767\e[1;36m///////////
|
||||
/////////////*\e[1;37m7676\e[1;36m///////\e[1;37m76\e[1;36m////////////
|
||||
///////////////\e[1;37m7676\e[1;36m////////////////////
|
||||
///////////////\e[1;37m7676\e[1;36m///\e[1;37m767\e[1;36m////////////
|
||||
//////////////////////\e[1;37m'\e[1;36m////////////
|
||||
//////\e[1;37m.7676767676767676767,\e[1;36m//////
|
||||
/////\e[1;37m767676767676767676767\e[1;36m/////
|
||||
///////////////////////////
|
||||
/////////////////////
|
||||
/////////////"
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## COLORS
|
||||
##==============================================================================
|
||||
|
||||
|
||||
format_info=" -c light-gray "
|
||||
format_highlight=" -c blue -e bold"
|
||||
format_crit=" -c 45 -e bold"
|
||||
format_deco=" -c light-gray "
|
||||
format_ok=" -c blue -e bold"
|
||||
format_error=" -c 45 -e bold -e blink"
|
||||
format_logo=" -c blue -e bold"
|
|
@ -0,0 +1,31 @@
|
|||
##==============================================================================
|
||||
## LOGO
|
||||
##==============================================================================
|
||||
|
||||
## Raspberry logo, colors added for synth-shell, orignal by b3n @ aspberrypi.com
|
||||
logo="
|
||||
\e[0;32m .~~. .~~.
|
||||
\e[0;32m '. \ ' ' / .'
|
||||
\e[1;31m .~ .~~~..~.
|
||||
\e[1;31m : .~.'~'.~. :
|
||||
\e[1;31m ~ ( ) ( ) ~
|
||||
\e[1;31m( : '~'.~.'~' : )
|
||||
\e[1;31m ~ .~ ( ) ~. ~
|
||||
\e[1;31m ( : '~' : )
|
||||
\e[1;31m '~ .~~~. ~'
|
||||
\e[1;31m '~'
|
||||
"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## COLORS
|
||||
##==============================================================================
|
||||
|
||||
format_info=" -c white"
|
||||
format_highlight=" -c red -e bold"
|
||||
format_crit=" -c green -e bold"
|
||||
format_deco=" -c white -e bold"
|
||||
format_ok=" -c red -e bold"
|
||||
format_error=" -c green -e bold -e blink"
|
||||
format_logo=" -c red -e bold"
|
|
@ -0,0 +1,35 @@
|
|||
##==============================================================================
|
||||
## LOGO
|
||||
##==============================================================================
|
||||
|
||||
logo="\e[1;31m / \\
|
||||
// \\\\\\\\
|
||||
// \\\\\\\\
|
||||
// \\\\\\\\
|
||||
// \e[5;39m███\e[25;31m \\\\\\\\
|
||||
// \e[5;39m███\e[25;31m \\\\\\\\
|
||||
// \e[5;39m███\e[25;31m \\\\\\\\
|
||||
// \\\\\\\\
|
||||
// \e[5;39m███\e[25;31m \\\\\\\\
|
||||
// \\\\\\\\
|
||||
//===================\\\\\\\\
|
||||
|
||||
WARNING!
|
||||
ROOT ACCOUNT!"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## COLORS
|
||||
##==============================================================================
|
||||
|
||||
format_info=" -c white"
|
||||
format_highlight=" -c red -e bold"
|
||||
format_crit=" -c red -e bold"
|
||||
format_deco=" -c white -e bold"
|
||||
format_ok=" -c red -e bold"
|
||||
format_error=" -c red -e bold -e blink"
|
||||
format_logo=" -c 208 -e bold"
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
##==============================================================================
|
||||
## LOGO
|
||||
##==============================================================================
|
||||
|
||||
## Ubuntu Logo, simple ASCII drawing by andresgongora
|
||||
|
||||
local logo="\e[0;91m /////////////////
|
||||
\e[0;91m /////////////////////////
|
||||
\e[0;91m ////////////////////\e[1;97m@@@@\e[0;91m///////
|
||||
\e[0;91m /////////////////////\e[1;97m@@@@@@\e[0;91m////////
|
||||
\e[0;91m ////////////////\e[1;97m@@@@@@\e[0;91m//\e[1;97m@@@@\e[0;91m///////////
|
||||
\e[0;91m ////////////\e[1;97m@@@@\e[0;91m//\e[1;97m@@@@@@@@\e[0;91m//\e[1;97m@\e[0;91m////////////
|
||||
\e[0;91m ///////////\e[1;97m@@@@@@\e[0;91m/////////\e[1;97m@@@@@@\e[0;91m///////////
|
||||
\e[0;91m///////////\e[1;97m@@@@@\e[0;91m/////////////\e[1;97m@@@@@\e[0;91m///////////
|
||||
\e[0;91m//////\e[1;97m@@@@\e[0;91m//\e[1;97m@@@\e[0;91m///////////////\e[1;97m@@@@@\e[0;91m//////////
|
||||
\e[0;91m/////\e[1;97m@@@@@@\e[0;91m/\e[1;97m@@@\e[0;91m//////////////////////////////
|
||||
\e[0;91m//////\e[1;97m@@@@\e[0;91m//\e[1;97m@@@\e[0;91m///////////////\e[1;97m@@@@@\e[0;91m//////////
|
||||
\e[0;91m///////////\e[1;97m@@@@@\e[0;91m/////////////\e[1;97m@@@@@\e[0;91m///////////
|
||||
\e[0;91m ///////////\e[1;97m@@@@@@\e[0;91m/////////\e[1;97m@@@@@@\e[0;91m///////////
|
||||
\e[0;91m ////////////\e[1;97m@@@@\e[0;91m//\e[1;97m@@@@@@@@\e[0;91m//\e[1;97m@\e[0;91m////////////
|
||||
\e[0;91m ////////////////\e[1;97m@@@@@@\e[0;91m//\e[1;97m@@@@\e[0;91m///////////
|
||||
\e[0;91m /////////////////////\e[1;97m@@@@@@\e[0;91m////////
|
||||
\e[0;91m ////////////////////\e[1;97m@@@@\e[0;91m///////
|
||||
\e[0;91m /////////////////////////
|
||||
\e[0;91m ///////////////// "
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## COLORS
|
||||
##==============================================================================
|
||||
|
||||
format_info=" -c white"
|
||||
format_highlight=" -c light-red -e bold"
|
||||
format_crit=" -c red -e bold"
|
||||
format_deco=" -c white -e bold"
|
||||
format_ok=" -c light-red -e bold"
|
||||
format_error=" -c red -e bold -e blink"
|
||||
format_logo=" -c light-red -e bold"
|
|
@ -0,0 +1 @@
|
|||
Feel free to pull request your config files to share them here :)
|
|
@ -0,0 +1,161 @@
|
|||
##==============================================================================
|
||||
## LOGO
|
||||
##==============================================================================
|
||||
|
||||
logo="
|
||||
-oydNMMMMNdyo-
|
||||
-yNMMMMMMMMMMMMMMNy-
|
||||
.hMMMMMMmhsooshmMMMMMMh.
|
||||
:NMMMMmo. .omMMMMN:
|
||||
-NMMMMs -+ss+- sMMMMN-
|
||||
hMMMMs -mMMMMMMm- sMMMMh
|
||||
'MMMMM. 'NMMMMMMMMN' .MMMMM
|
||||
'MMMMM. 'NMMMMMMMMN' yMMMM'
|
||||
hMMMMs -mMMMMMMMMy. -yMh
|
||||
-NMMMMs -+ss+yMMMMy. -.
|
||||
:NMMMMmo. .yMMMMy.
|
||||
.hMMMMMMmhsoo- .yMMMy
|
||||
-yNMMMMMMMMMy- .o-
|
||||
-oydNMMMMNd/ \n"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## STATUS INFO
|
||||
##
|
||||
## Choose what to print and in what order
|
||||
## Valid options are:
|
||||
##
|
||||
## ## SIMPLE ONE-LINERS
|
||||
## OS Linux distribution name
|
||||
## KERNEL Kernel version
|
||||
## CPU CPU Name
|
||||
## SHELL Shell name
|
||||
## DATE Current date
|
||||
## UPTIME System uptime (time since boot)
|
||||
## USER Current user and host names
|
||||
## NUMLOGGED Show number of logged in users
|
||||
## NAMELOGGED Show names of logged in users
|
||||
## LOCALIPV4 IPv4
|
||||
## EXTERNALIPV4 External IPv4 (might be slow)
|
||||
## SERVICES Summary of failed services
|
||||
## CPULOAD Sys load average(eg. 0.23, 0.26, 0.27 )
|
||||
## CPUTEMP CPU temperature (requires lm-sensors)
|
||||
##
|
||||
## ## SYS LOAD MONITORS
|
||||
## SYSLOAD_MON Current CPU load
|
||||
## MEMORY_MON Occupied memory
|
||||
## SWAP_MON Occupied SWAP
|
||||
## HDDROOT_MON / partition occupied
|
||||
## HDDHOME_MON /home/user occupied
|
||||
## CPUTEMP_MON CPU temperature (requires lm-sensors)
|
||||
## SYSLOAD_MON% Current CPU load in %
|
||||
## MEMORY_MON% Occupied memory in %
|
||||
## SWAP_MON% Occupied SWAP in %
|
||||
## HDDROOT_MON% / partition occupied in %
|
||||
## HDDHOME_MON% /home/user occupied in %
|
||||
##
|
||||
## ## MISC
|
||||
## SPACER Print decorative spacer (empty line)
|
||||
## PALETTE Show 16-bit palette (add SPACER before for best results)
|
||||
## PALETTE_SMALL Show smaller version of 16-bit color palette
|
||||
##
|
||||
##==============================================================================
|
||||
|
||||
print_info="
|
||||
OS
|
||||
KERNEL
|
||||
CPU
|
||||
GPU
|
||||
SHELL
|
||||
DATE
|
||||
UPTIME
|
||||
LOCALIPV4
|
||||
EXTERNALIPV4
|
||||
SERVICES
|
||||
CPUTEMP
|
||||
SYSLOAD_MON%
|
||||
MEMORY_MON
|
||||
SWAP_MON
|
||||
HDDROOT_MON
|
||||
HDDHOME_MON"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## COLORS
|
||||
##
|
||||
## Control the color and format scheme of the status report.
|
||||
## -c color: color name or 256bit color code
|
||||
## -b background color: color name or 256bit color code
|
||||
## -e effect: bold, blink, dim, underline...
|
||||
##
|
||||
## Valid color names (16 bit):
|
||||
## white, light-gray, dark-gray, black,
|
||||
## red, green, yellow, blue, magenta, cyan,
|
||||
## light-red, light-green, light-yellow, light-blue, light-magenta, light-cyan
|
||||
##
|
||||
##==============================================================================
|
||||
|
||||
format_info=" -c white"
|
||||
format_highlight=" -c blue -e bold"
|
||||
format_crit=" -c 208 -e bold"
|
||||
format_deco=" -c white -e bold"
|
||||
format_ok=" -c blue -e bold"
|
||||
format_error=" -c 208 -e bold -e blink"
|
||||
format_logo=" -c blue -e bold"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## STATUS BARS
|
||||
##
|
||||
## These option controls the behaviour of the visual status bars that are
|
||||
## plotted for CPU, Memory, Swap and HDD usage. You can set the percentage that
|
||||
## determines when the current usage is deemed critical. If said percentage
|
||||
## is surpassed, the color of the bars will change and extra information
|
||||
## might be plotted in addition (e.g. if the CPU usage is too high, the most
|
||||
## demanding processes are printed to terminal).
|
||||
##==============================================================================
|
||||
|
||||
bar_cpu_crit_percent=40
|
||||
bar_ram_crit_percent=75
|
||||
bar_swap_crit_percent=25
|
||||
bar_hdd_crit_percent=85
|
||||
bar_home_crit_percent=85
|
||||
|
||||
bar_ram_units="MB"
|
||||
bar_swap_units="MB"
|
||||
bar_hdd_units="GB"
|
||||
bar_home_units="GB"
|
||||
|
||||
cpu_crit_print=true
|
||||
cpu_crit_print_num=3
|
||||
ram_crit_print=true
|
||||
ram_crit_print_num=3
|
||||
|
||||
bar_length=9 # Number of characters that comprise a bar
|
||||
bar_num_digits=5 # Control num digits next to bar
|
||||
bar_padding_after=0 # Extra spaces after bar
|
||||
info_label_width=16 # Desired length of the info labels
|
||||
bar_bracket_char_left='['
|
||||
bar_bracket_char_right=']'
|
||||
bar_fill_char='|'
|
||||
bar_background_char=' '
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## OTHERS
|
||||
##
|
||||
## For date format setup, see `man date`
|
||||
##==============================================================================
|
||||
|
||||
print_cols_max=100 # Keep logo and info text together
|
||||
print_logo_right=false # Change where the logo is plotted
|
||||
date_format="%Y.%m.%d - %T" # see 'man date'
|
||||
clear_before_print=false # Dangerous if true, some messages might be lost
|
||||
print_extra_new_line_top=true # Extra line before logo and info
|
||||
print_extra_new_line_bot=true # Extra line after logo and info
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
##==============================================================================
|
||||
## LOGO
|
||||
##==============================================================================
|
||||
|
||||
## Ubuntu Logo, simple ASCII drawing by andresgongora
|
||||
|
||||
local logo="\e[0;91m /////////////////
|
||||
\e[0;91m /////////////////////////
|
||||
\e[0;91m ////////////////////\e[1;97m@@@@\e[0;91m///////
|
||||
\e[0;91m /////////////////////\e[1;97m@@@@@@\e[0;91m////////
|
||||
\e[0;91m ////////////////\e[1;97m@@@@@@\e[0;91m//\e[1;97m@@@@\e[0;91m///////////
|
||||
\e[0;91m ////////////\e[1;97m@@@@\e[0;91m//\e[1;97m@@@@@@@@\e[0;91m//\e[1;97m@\e[0;91m////////////
|
||||
\e[0;91m ///////////\e[1;97m@@@@@@\e[0;91m/////////\e[1;97m@@@@@@\e[0;91m///////////
|
||||
\e[0;91m///////////\e[1;97m@@@@@\e[0;91m/////////////\e[1;97m@@@@@\e[0;91m///////////
|
||||
\e[0;91m//////\e[1;97m@@@@\e[0;91m//\e[1;97m@@@\e[0;91m///////////////\e[1;97m@@@@@\e[0;91m//////////
|
||||
\e[0;91m/////\e[1;97m@@@@@@\e[0;91m/\e[1;97m@@@\e[0;91m//////////////////////////////
|
||||
\e[0;91m//////\e[1;97m@@@@\e[0;91m//\e[1;97m@@@\e[0;91m///////////////\e[1;97m@@@@@\e[0;91m//////////
|
||||
\e[0;91m///////////\e[1;97m@@@@@\e[0;91m/////////////\e[1;97m@@@@@\e[0;91m///////////
|
||||
\e[0;91m ///////////\e[1;97m@@@@@@\e[0;91m/////////\e[1;97m@@@@@@\e[0;91m///////////
|
||||
\e[0;91m ////////////\e[1;97m@@@@\e[0;91m//\e[1;97m@@@@@@@@\e[0;91m//\e[1;97m@\e[0;91m////////////
|
||||
\e[0;91m ////////////////\e[1;97m@@@@@@\e[0;91m//\e[1;97m@@@@\e[0;91m///////////
|
||||
\e[0;91m /////////////////////\e[1;97m@@@@@@\e[0;91m////////
|
||||
\e[0;91m ////////////////////\e[1;97m@@@@\e[0;91m///////
|
||||
\e[0;91m /////////////////////////
|
||||
\e[0;91m ///////////////// "
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## COLORS
|
||||
##==============================================================================
|
||||
|
||||
format_info=" -c white"
|
||||
format_highlight=" -c light-red -e bold"
|
||||
format_crit=" -c red -e bold"
|
||||
format_deco=" -c white -e bold"
|
||||
format_ok=" -c light-red -e bold"
|
||||
format_error=" -c red -e bold -e blink"
|
||||
format_logo=" -c light-red -e bold"
|
|
@ -0,0 +1,166 @@
|
|||
##==============================================================================
|
||||
## LOGO
|
||||
##
|
||||
## Configure the logo to your liking. You can either use the default or
|
||||
## set your own ASCII art down below.
|
||||
##
|
||||
## - You can either add it as a single line, or multiline (terminated with \).
|
||||
## - You have to escape backslashes if you want them to show inside your logo.
|
||||
## Use \\\\ for 1 backslash, \\\\\\\\ for two. All other characters work fine.
|
||||
## - You can also add individual color codes to the logo using '\e[ ··· m'.
|
||||
## - For example: \e[1;31mHello World! prints in bright red.
|
||||
## - If you want extra spaces between the logo and the status info, just add
|
||||
## extra spaces at the last line and end it with '\n'.
|
||||
##==============================================================================
|
||||
|
||||
logo="\e[38;5;213m __ __
|
||||
_______ ______ / /_/ /_
|
||||
/ ___/ / / / __ \/ __/ __ \\
|
||||
/__ / /_/ / / / / /_/ / / /
|
||||
/____/\__ /_/ /_/\__/_/ /_/
|
||||
/____/
|
||||
\e[38;5;45m _____ __ __________ __
|
||||
/ ___// / / / ____/ / / /
|
||||
\__ \/ /_/ / __/ / / / /
|
||||
___/ / __ / /___/ /___/ /___
|
||||
/____/_/ /_/_____/_____/_____/\e[0;39m"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## STATUS INFO
|
||||
##
|
||||
## Choose what to print and in what order
|
||||
## Valid options are:
|
||||
##
|
||||
## ## SIMPLE ONE-LINERS
|
||||
## OS Linux distribution name
|
||||
## KERNEL Kernel version
|
||||
## CPU CPU Name
|
||||
## SHELL Shell name
|
||||
## DATE Current date
|
||||
## UPTIME System uptime (time since boot)
|
||||
## USER Current user and host names
|
||||
## NUMLOGGED Show number of logged in users
|
||||
## NAMELOGGED Show names of logged in users
|
||||
## LOCALIPV4 IPv4
|
||||
## EXTERNALIPV4 External IPv4 (might be slow)
|
||||
## SERVICES Summary of failed services
|
||||
## CPULOAD Sys load average(eg. 0.23, 0.26, 0.27 )
|
||||
## CPUTEMP CPU temperature (requires lm-sensors)
|
||||
##
|
||||
## ## SYS LOAD MONITORS
|
||||
## SYSLOAD_MON Current CPU load
|
||||
## MEMORY_MON Occupied memory
|
||||
## SWAP_MON Occupied SWAP
|
||||
## HDDROOT_MON / partition occupied
|
||||
## HDDHOME_MON /home/user occupied
|
||||
## CPUTEMP_MON CPU temperature (requires lm-sensors)
|
||||
## SYSLOAD_MON% Current CPU load in %
|
||||
## MEMORY_MON% Occupied memory in %
|
||||
## SWAP_MON% Occupied SWAP in %
|
||||
## HDDROOT_MON% / partition occupied in %
|
||||
## HDDHOME_MON% /home/user occupied in %
|
||||
##
|
||||
## ## MISC
|
||||
## SPACER Print decorative spacer (empty line)
|
||||
## PALETTE Show 16-bit palette (add SPACER before for best results)
|
||||
## PALETTE_SMALL Show smaller version of 16-bit color palette
|
||||
##
|
||||
##==============================================================================
|
||||
|
||||
print_info="
|
||||
OS
|
||||
KERNEL
|
||||
CPU
|
||||
GPU
|
||||
SHELL
|
||||
DATE
|
||||
UPTIME
|
||||
LOCALIPV4
|
||||
EXTERNALIPV4
|
||||
SERVICES
|
||||
CPUTEMP
|
||||
SYSLOAD_MON%
|
||||
MEMORY_MON
|
||||
SWAP_MON
|
||||
HDDROOT_MON
|
||||
HDDHOME_MON
|
||||
PALETTE"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## COLORS
|
||||
##
|
||||
## Control the color and format scheme of the status report.
|
||||
## -c color: color name or 256bit color code
|
||||
## -b background color: color name or 256bit color code
|
||||
## -e effect: bold, blink, dim, underline...
|
||||
##
|
||||
## Valid color names (16 bit):
|
||||
## white, light-gray, dark-gray, black,
|
||||
## red, green, yellow, blue, magenta, cyan,
|
||||
## light-red, light-green, light-yellow, light-blue, light-magenta, light-cyan
|
||||
##
|
||||
##==============================================================================
|
||||
|
||||
format_info=" -c light-gray "
|
||||
format_highlight=" -c blue -e bold"
|
||||
format_crit=" -c 45 -e bold"
|
||||
format_deco=" -c light-gray "
|
||||
format_ok=" -c blue -e bold"
|
||||
format_error=" -c 45 -e bold -e blink"
|
||||
format_logo=" -c blue -e bold"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## STATUS BARS
|
||||
##
|
||||
## These option controls the behaviour of the visual status bars that are
|
||||
## plotted for CPU, Memory, Swap and HDD usage. You can set the percentage that
|
||||
## determines when the current usage is deemed critical. If said percentage
|
||||
## is surpassed, the color of the bars will change and extra information
|
||||
## might be plotted in addition (e.g. if the CPU usage is too high, the most
|
||||
## demanding processes are printed to terminal).
|
||||
##==============================================================================
|
||||
|
||||
bar_cpu_crit_percent=40
|
||||
bar_ram_crit_percent=75
|
||||
bar_swap_crit_percent=25
|
||||
bar_hdd_crit_percent=85
|
||||
bar_home_crit_percent=85
|
||||
|
||||
bar_ram_units="MB"
|
||||
bar_swap_units="MB"
|
||||
bar_hdd_units="GB"
|
||||
bar_home_units="GB"
|
||||
|
||||
cpu_crit_print=true
|
||||
cpu_crit_print_num=3
|
||||
ram_crit_print=true
|
||||
ram_crit_print_num=3
|
||||
|
||||
bar_length=9 # Number of characters that comprise a bar
|
||||
bar_num_digits=5 # Control num digits next to bar
|
||||
bar_padding_after=0 # Extra spaces after bar
|
||||
info_label_width=16 # Desired length of the info labels
|
||||
bar_bracket_char_left='['
|
||||
bar_bracket_char_right=']'
|
||||
bar_fill_char='|'
|
||||
bar_background_char=' '
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## OTHERS
|
||||
##
|
||||
## For date format setup, see `man date`
|
||||
##==============================================================================
|
||||
|
||||
print_cols_max=100 # Keep logo and info text together
|
||||
print_logo_right=false # Change where the logo is plotted
|
||||
date_format="%Y.%m.%d - %T" # see 'man date'
|
||||
clear_before_print=false # Dangerous if true, some messages might be lost
|
||||
print_extra_new_line_top=true # Extra line before logo and info
|
||||
print_extra_new_line_bot=true # Extra line after logo and info
|
|
@ -0,0 +1,41 @@
|
|||
##==============================================================================
|
||||
## LOGO
|
||||
##==============================================================================
|
||||
|
||||
## ArchLinux theme from archey3. Slightly modified. Sources:
|
||||
## - https://wiki.archlinux.org/index.php/ASCII_art
|
||||
## - https://bbs.archlinux.org/viewtopic.php?id=24208&p=6
|
||||
|
||||
logo="\e[0;94m .
|
||||
\e[0;94m #
|
||||
\e[0;94m ###
|
||||
\e[0;94m #####
|
||||
\e[0;94m '######
|
||||
\e[0;94m .. #####:
|
||||
\e[0;94m ###.#####
|
||||
\e[0;94m ###########
|
||||
\e[0;94m ######\e[0;34m#####\e[0;94m##;
|
||||
\e[0;94m ###\e[0;34m############\e[0;94m
|
||||
\e[0;94m #\e[0;34m###### #######
|
||||
\e[0;34m :#####: :###.\`\".
|
||||
\e[0;34m :######: :####:.
|
||||
\e[0;34m :########. .########
|
||||
\e[0;34m :#####' '#####:
|
||||
\e[0;34m :#### ####:
|
||||
\e[0;34m ##' '##
|
||||
\e[0;34m #' '#
|
||||
\e[0;34m ' ' "
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## COLORS
|
||||
##==============================================================================
|
||||
|
||||
format_info=" -c white"
|
||||
format_highlight=" -c blue -e bold"
|
||||
format_crit=" -c 208 -e bold"
|
||||
format_deco=" -c white -e bold"
|
||||
format_ok=" -c blue -e bold"
|
||||
format_error=" -c 208 -e bold -e blink"
|
||||
format_logo=" -c blue -e bold"
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,92 @@
|
|||
##==============================================================================
|
||||
## COLORS
|
||||
##
|
||||
## Control the color and format scheme of the bash prompt.
|
||||
## The prompt is divided into segments, listed below starting from the left:
|
||||
## - USER: shows the user's name.
|
||||
## - HOST: shows the host's name.
|
||||
## - PWD: shows the current directory.
|
||||
## - GIT: if inside a git repository, shows the name of current branch.
|
||||
## - PYENV: if inside a Python Virtual environment.
|
||||
## - TF: if inside a Terraform Workspace.
|
||||
## - CLOCK: shows current time in H:M format.
|
||||
## - INPUT: actual bash input.
|
||||
##
|
||||
## Valid color options:
|
||||
## - white black light-gray dark-gray
|
||||
## red green yellow blue cyan purple
|
||||
## light-red light-green light-yellow light-blue light-cyan light-purple
|
||||
## - Values in the range [0-255] for 256 bit colors. To check all number-color
|
||||
## pairs for your terminal, you may run the following snippet by HaleTom:
|
||||
## curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash
|
||||
## or search something like "bash 256 color codes" on the internet.
|
||||
##
|
||||
##==============================================================================
|
||||
|
||||
format="CLOCK USER HOST PWD GIT PYENV TF KUBE"
|
||||
|
||||
font_color_user="black"
|
||||
background_user="231"
|
||||
texteffect_user="bold"
|
||||
|
||||
font_color_host="238"
|
||||
background_host="50"
|
||||
texteffect_host="bold"
|
||||
|
||||
font_color_pwd="white"
|
||||
background_pwd="124"
|
||||
texteffect_pwd="bold"
|
||||
|
||||
font_color_git="black"
|
||||
background_git="220"
|
||||
texteffect_git="bold"
|
||||
|
||||
font_color_pyenv="white"
|
||||
background_pyenv="blue"
|
||||
texteffect_pyenv="bold"
|
||||
|
||||
font_color_kube="white"
|
||||
background_kube="purple"
|
||||
texteffect_kube="bold"
|
||||
|
||||
font_color_tf="purple"
|
||||
background_tf="light-purple"
|
||||
texteffect_tf="bold"
|
||||
|
||||
font_color_clock="white"
|
||||
background_clock="16"
|
||||
texteffect_clock="bold"
|
||||
|
||||
font_color_input="45"
|
||||
background_input="none"
|
||||
texteffect_input="bold"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## BEHAVIOR
|
||||
##==============================================================================
|
||||
|
||||
separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
|
||||
separator_padding_left='' #
|
||||
separator_padding_right='' #
|
||||
prompt_horizontal_padding='' #
|
||||
prompt_final_padding='' #
|
||||
segment_padding=' ' #
|
||||
enable_vertical_padding=true # Add extra new line over prompt
|
||||
max_pwd_char="20"
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## GIT
|
||||
##==============================================================================
|
||||
|
||||
git_symbol_synced=''
|
||||
git_symbol_unpushed=' ▲'
|
||||
git_symbol_unpulled=' ▼'
|
||||
git_symbol_unpushedunpulled=' ◆'
|
||||
git_symbol_dirty=' ◔'
|
||||
git_symbol_dirty_unpushed=' ◔ △'
|
||||
git_symbol_dirty_unpulled=' ◔ ▽'
|
||||
git_symbol_dirty_unpushedunpulled=' ◔ ◇'
|
||||
git_update_period_minutes=15 # Use -1 to disable automatic updates
|
|
@ -0,0 +1,92 @@
|
|||
##==============================================================================
|
||||
## COLORS
|
||||
##
|
||||
## Control the color and format scheme of the bash prompt.
|
||||
## The prompt is divided into segments, listed below starting from the left:
|
||||
## - USER: shows the user's name.
|
||||
## - HOST: shows the host's name.
|
||||
## - PWD: shows the current directory.
|
||||
## - GIT: if inside a git repository, shows the name of current branch.
|
||||
## - PYENV: if inside a Python Virtual environment.
|
||||
## - TF: if inside a Terraform Workspace.
|
||||
## - CLOCK: shows current time in H:M format.
|
||||
## - INPUT: actual bash input.
|
||||
##
|
||||
## Valid color options:
|
||||
## - white black light-gray dark-gray
|
||||
## red green yellow blue cyan purple
|
||||
## light-red light-green light-yellow light-blue light-cyan light-purple
|
||||
## - Values in the range [0-255] for 256 bit colors. To check all number-color
|
||||
## pairs for your terminal, you may run the following snippet by HaleTom:
|
||||
## curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash
|
||||
## or search something like "bash 256 color codes" on the internet.
|
||||
##
|
||||
##==============================================================================
|
||||
|
||||
format="USER HOST PWD GIT PYENV TF KUBE"
|
||||
|
||||
font_color_user="white"
|
||||
background_user="blue"
|
||||
texteffect_user="bold"
|
||||
|
||||
font_color_host="white"
|
||||
background_host="light-blue"
|
||||
texteffect_host="bold"
|
||||
|
||||
font_color_pwd="dark-gray"
|
||||
background_pwd="white"
|
||||
texteffect_pwd="bold"
|
||||
|
||||
font_color_git="light-gray"
|
||||
background_git="dark-gray"
|
||||
texteffect_git="bold"
|
||||
|
||||
font_color_pyenv="white"
|
||||
background_pyenv="blue"
|
||||
texteffect_pyenv="bold"
|
||||
|
||||
font_color_kube="white"
|
||||
background_kube="purple"
|
||||
texteffect_kube="bold"
|
||||
|
||||
font_color_tf="purple"
|
||||
background_tf="light-purple"
|
||||
texteffect_tf="bold"
|
||||
|
||||
font_color_clock="white"
|
||||
background_clock="light-blue"
|
||||
texteffect_clock="bold"
|
||||
|
||||
font_color_input="45"
|
||||
background_input="none"
|
||||
texteffect_input="bold"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## BEHAVIOR
|
||||
##==============================================================================
|
||||
|
||||
separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
|
||||
separator_padding_left='' #
|
||||
separator_padding_right='' #
|
||||
prompt_horizontal_padding='' #
|
||||
prompt_final_padding='' #
|
||||
segment_padding=' ' #
|
||||
enable_vertical_padding=true # Add extra new line over prompt
|
||||
max_pwd_char="20"
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## GIT
|
||||
##==============================================================================
|
||||
|
||||
git_symbol_synced=''
|
||||
git_symbol_unpushed=' ▲'
|
||||
git_symbol_unpulled=' ▼'
|
||||
git_symbol_unpushedunpulled=' ◆'
|
||||
git_symbol_dirty=' ◔'
|
||||
git_symbol_dirty_unpushed=' ◔ △'
|
||||
git_symbol_dirty_unpulled=' ◔ ▽'
|
||||
git_symbol_dirty_unpushedunpulled=' ◔ ◇'
|
||||
git_update_period_minutes=15 # Use -1 to disable automatic updates
|
|
@ -0,0 +1,92 @@
|
|||
##==============================================================================
|
||||
## COLORS
|
||||
##
|
||||
## Control the color and format scheme of the bash prompt.
|
||||
## The prompt is divided into segments, listed below starting from the left:
|
||||
## - USER: shows the user's name.
|
||||
## - HOST: shows the host's name.
|
||||
## - PWD: shows the current directory.
|
||||
## - GIT: if inside a git repository, shows the name of current branch.
|
||||
## - PYENV: if inside a Python Virtual environment.
|
||||
## - TF: if inside a Terraform Workspace.
|
||||
## - CLOCK: shows current time in H:M format.
|
||||
## - INPUT: actual bash input.
|
||||
##
|
||||
## Valid color options:
|
||||
## - white black light-gray dark-gray
|
||||
## red green yellow blue cyan purple
|
||||
## light-red light-green light-yellow light-blue light-cyan light-purple
|
||||
## - Values in the range [0-255] for 256 bit colors. To check all number-color
|
||||
## pairs for your terminal, you may run the following snippet by HaleTom:
|
||||
## curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash
|
||||
## or search something like "bash 256 color codes" on the internet.
|
||||
##
|
||||
##==============================================================================
|
||||
|
||||
format="USER HOST PWD GIT PYENV TF KUBE"
|
||||
|
||||
font_color_user="white"
|
||||
background_user="blue"
|
||||
texteffect_user="bold"
|
||||
|
||||
font_color_host="white"
|
||||
background_host="light-blue"
|
||||
texteffect_host="bold"
|
||||
|
||||
font_color_pwd="dark-gray"
|
||||
background_pwd="white"
|
||||
texteffect_pwd="bold"
|
||||
|
||||
font_color_git="light-gray"
|
||||
background_git="dark-gray"
|
||||
texteffect_git="bold"
|
||||
|
||||
font_color_pyenv="white"
|
||||
background_pyenv="blue"
|
||||
texteffect_pyenv="bold"
|
||||
|
||||
font_color_kube="white"
|
||||
background_kube="purple"
|
||||
texteffect_kube="bold"
|
||||
|
||||
font_color_tf="purple"
|
||||
background_tf="light-purple"
|
||||
texteffect_tf="bold"
|
||||
|
||||
font_color_clock="white"
|
||||
background_clock="light-blue"
|
||||
texteffect_clock="bold"
|
||||
|
||||
font_color_input="45"
|
||||
background_input="none"
|
||||
texteffect_input="bold"
|
||||
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## BEHAVIOR
|
||||
##==============================================================================
|
||||
|
||||
separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
|
||||
separator_padding_left='' #
|
||||
separator_padding_right='' #
|
||||
prompt_horizontal_padding='' #
|
||||
prompt_final_padding='' #
|
||||
segment_padding=' ' #
|
||||
enable_vertical_padding=true # Add extra new line over prompt
|
||||
max_pwd_char="20"
|
||||
|
||||
|
||||
##==============================================================================
|
||||
## GIT
|
||||
##==============================================================================
|
||||
|
||||
git_symbol_synced=''
|
||||
git_symbol_unpushed=' ▲'
|
||||
git_symbol_unpulled=' ▼'
|
||||
git_symbol_unpushedunpulled=' ◆'
|
||||
git_symbol_dirty=' ◔'
|
||||
git_symbol_dirty_unpushed=' ◔ △'
|
||||
git_symbol_dirty_unpulled=' ◔ ▽'
|
||||
git_symbol_dirty_unpushedunpulled=' ◔ ◇'
|
||||
git_update_period_minutes=15 # Use -1 to disable automatic updates
|
|
@ -0,0 +1,24 @@
|
|||
##==============================================================================
|
||||
## COLORS
|
||||
##==============================================================================
|
||||
|
||||
font_color_user="black"
|
||||
background_user="red"
|
||||
texteffect_user="bold"
|
||||
|
||||
font_color_host="red"
|
||||
background_host="black"
|
||||
texteffect_host="bold"
|
||||
|
||||
font_color_pwd="black"
|
||||
background_pwd="red"
|
||||
texteffect_pwd="bold"
|
||||
|
||||
font_color_git="white"
|
||||
background_git="black"
|
||||
texteffect_git="bold"
|
||||
|
||||
font_color_input="red"
|
||||
background_input="none"
|
||||
texteffect_input="bold"
|
||||
|
|
@ -0,0 +1,895 @@
|
|||
#!/bin/bash
|
||||
|
||||
##
|
||||
##
|
||||
## =======================
|
||||
## WARNING!!
|
||||
## DO NOT EDIT THIS FILE!!
|
||||
## =======================
|
||||
##
|
||||
## This file was generated by an installation script.
|
||||
## It might be overwritten without warning at any time
|
||||
## and you will lose all your changes.
|
||||
##
|
||||
## Visit for instructions and more information:
|
||||
## https://github.com/andresgongora/synth-shell/
|
||||
##
|
||||
##
|
||||
|
||||
|
||||
|
||||
#!/bin/bash
|
||||
## +-----------------------------------+-----------------------------------+
|
||||
## | |
|
||||
## | Copyright (c) 2019-2020, Andres Gongora <mail@andresgongora.com>. |
|
||||
## | |
|
||||
## | This program is free software: you can redistribute it and/or modify |
|
||||
## | it under the terms of the GNU General Public License as published by |
|
||||
## | the Free Software Foundation, either version 3 of the License, or |
|
||||
## | (at your option) any later version. |
|
||||
## | |
|
||||
## | This program is distributed in the hope that it will be useful, |
|
||||
## | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
## | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
## | GNU General Public License for more details. |
|
||||
## | |
|
||||
## | You should have received a copy of the GNU General Public License |
|
||||
## | along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
||||
## | |
|
||||
## +-----------------------------------------------------------------------+
|
||||
##
|
||||
## DESCRIPTION
|
||||
## ===========
|
||||
##
|
||||
## Script to colorize terminal text.
|
||||
## It works in either of two ways, either by providing the formatting
|
||||
## sequences that should be added to the text, or by directly wrapping
|
||||
## the text with the desired control sequences
|
||||
##
|
||||
##
|
||||
##
|
||||
##
|
||||
##
|
||||
## USAGE
|
||||
## =====
|
||||
##
|
||||
## Formating a text directly:
|
||||
## FORMATTED_TEXT=$(formatText "Hi!" -c red -b 13 -e bold)
|
||||
## echo -e "$FORMATTED_TEXT"
|
||||
##
|
||||
## Getting the control sequences:
|
||||
## FORMAT=$(getFormatCode -c blue -b yellow -e bold -e blink)
|
||||
## NONE=$(getFormatCode -e none)
|
||||
## echo -e $FORMAT"Hello"$NONE
|
||||
##
|
||||
## Options (More than one code may be specified)
|
||||
## -c color name or 256bit code for font face
|
||||
## -b background color name or 256bit code
|
||||
## -e effect name (e.g. bold, blink, etc.)
|
||||
##
|
||||
##
|
||||
##
|
||||
##
|
||||
##
|
||||
## BASH TEXT FORMATING
|
||||
## ===================
|
||||
##
|
||||
## Colors and text formatting can be achieved by preceding the text
|
||||
## with an escape sequence. An escape sequence starts with an <ESC>
|
||||
## character (commonly \e[), followed by one or more formatting codes
|
||||
## (its possible) to apply more that one color/effect at a time),
|
||||
## and finished by a lower case m. For example, the formatting code 1
|
||||
## tells the terminal to print the text bold face. This is acchieved as:
|
||||
## \e[1m Hello World!
|
||||
##
|
||||
## But if nothing else is specified, then eveything that may be printed
|
||||
## after 'Hello world!' will be bold face as well. The code 0 is thus
|
||||
## meant to remove all formating from the text and return to normal:
|
||||
## \e[1m Hello World! \e[0m
|
||||
##
|
||||
## It's also possible to paint the text in color (codes 30 to 37 and
|
||||
## codes 90 to 97), or its background (codes 40 to 47 and 100 to 107).
|
||||
## Red has code 31:
|
||||
## \e[31m Hello World! \e[0m
|
||||
##
|
||||
## More than one code can be applied at a time. Codes are separated by
|
||||
## semicolons. For example, code 31 paints the text in red. Thus,
|
||||
## the following would print in red bold face:
|
||||
## \e[1;31m Hello World! \e[0m
|
||||
##
|
||||
## Some formatting sequences are, in fact, comprised of two codes
|
||||
## that must go together. For example, the code 38;5; tells the terminal
|
||||
## that the next code (after the semicolon) should be interpreted as
|
||||
## a 256 bit formatting color. So, for example, the code 82 is a light
|
||||
## green. We can paint the text using this code as follows, plus bold
|
||||
## face as follows - but notice that not all terminal support 256 colors:##
|
||||
## \e[1;38;5;82m Hello World! \e[0m
|
||||
##
|
||||
## For a detailed list of all codes, this site has an excellent guide:
|
||||
## https://misc.flogisoft.com/bash/tip_colors_and_formatting
|
||||
##
|
||||
##
|
||||
##
|
||||
##
|
||||
##
|
||||
## TODO: When requesting an 8 bit colorcode, detect if terminal supports
|
||||
## 256 bits, and return appropriate code instead
|
||||
##
|
||||
## TODO: Improve this description/manual text
|
||||
##
|
||||
## TODO: Currently, if only one parameter is passed, its treated as a
|
||||
## color. Addsupport to also detect whether its an effect code.
|
||||
## Now: getFormatCode blue == getFormatCode -c blue
|
||||
## Add: getFormatCode bold == getFormatCode -e bold
|
||||
##
|
||||
## TODO: Clean up this script. Prevent functions like "get8bitCode()"
|
||||
## to be accessible from outside. These are only a "helper" function
|
||||
## that should only be available to this script
|
||||
##
|
||||
##==============================================================================
|
||||
## CODE PARSERS
|
||||
##==============================================================================
|
||||
##------------------------------------------------------------------------------
|
||||
##
|
||||
get8bitCode()
|
||||
{
|
||||
CODE=$1
|
||||
case $CODE in
|
||||
default)
|
||||
echo 9
|
||||
;;
|
||||
none)
|
||||
echo 9
|
||||
;;
|
||||
black)
|
||||
echo 0
|
||||
;;
|
||||
red)
|
||||
echo 1
|
||||
;;
|
||||
green)
|
||||
echo 2
|
||||
;;
|
||||
yellow)
|
||||
echo 3
|
||||
;;
|
||||
blue)
|
||||
echo 4
|
||||
;;
|
||||
magenta|purple|pink)
|
||||
echo 5
|
||||
;;
|
||||
cyan)
|
||||
echo 6
|
||||
;;
|
||||
light-gray)
|
||||
echo 7
|
||||
;;
|
||||
dark-gray)
|
||||
echo 60
|
||||
;;
|
||||
light-red)
|
||||
echo 61
|
||||
;;
|
||||
light-green)
|
||||
echo 62
|
||||
;;
|
||||
light-yellow)
|
||||
echo 63
|
||||
;;
|
||||
light-blue)
|
||||
echo 64
|
||||
;;
|
||||
light-magenta|light-purple)
|
||||
echo 65
|
||||
;;
|
||||
light-cyan)
|
||||
echo 66
|
||||
;;
|
||||
white)
|
||||
echo 67
|
||||
;;
|
||||
*)
|
||||
echo 0
|
||||
esac
|
||||
}
|
||||
##------------------------------------------------------------------------------
|
||||
##
|
||||
getColorCode()
|
||||
{
|
||||
COLOR=$1
|
||||
## Check if color is a 256-color code
|
||||
if [ $COLOR -eq $COLOR ] 2> /dev/null; then
|
||||
if [ $COLOR -gt 0 -a $COLOR -lt 256 ]; then
|
||||
echo "38;5;$COLOR"
|
||||
else
|
||||
echo 0
|
||||
fi
|
||||
## Or if color key-workd
|
||||
else
|
||||
BITCODE=$(get8bitCode $COLOR)
|
||||
COLORCODE=$(($BITCODE + 30))
|
||||
echo $COLORCODE
|
||||
fi
|
||||
}
|
||||
##------------------------------------------------------------------------------
|
||||
##
|
||||
getBackgroundCode()
|
||||
{
|
||||
COLOR=$1
|
||||
## Check if color is a 256-color code
|
||||
if [ $COLOR -eq $COLOR ] 2> /dev/null; then
|
||||
if [ $COLOR -gt 0 -a $COLOR -lt 256 ]; then
|
||||
echo "48;5;$COLOR"
|
||||
else
|
||||
echo 0
|
||||
fi
|
||||
## Or if color key-workd
|
||||
else
|
||||
BITCODE=$(get8bitCode $COLOR)
|
||||
COLORCODE=$(($BITCODE + 40))
|
||||
echo $COLORCODE
|
||||
fi
|
||||
}
|
||||
##------------------------------------------------------------------------------
|
||||
##
|
||||
getEffectCode()
|
||||
{
|
||||
EFFECT=$1
|
||||
NONE=0
|
||||
case $EFFECT in
|
||||
none)
|
||||
echo $NONE
|
||||
;;
|
||||
default)
|
||||
echo $NONE
|
||||
;;
|
||||
bold)
|
||||
echo 1
|
||||
;;
|
||||
bright)
|
||||
echo 1
|
||||
;;
|
||||
dim)
|
||||
echo 2
|
||||
;;
|
||||
underline)
|
||||
echo 4
|
||||
;;
|
||||
blink)
|
||||
echo 5
|
||||
;;
|
||||
reverse)
|
||||
echo 7
|
||||
;;
|
||||
hidden)
|
||||
echo 8
|
||||
;;
|
||||
strikeout)
|
||||
echo 9
|
||||
;;
|
||||
*)
|
||||
echo $NONE
|
||||
esac
|
||||
}
|
||||
##------------------------------------------------------------------------------
|
||||
##
|
||||
getFormattingSequence()
|
||||
{
|
||||
START='\e[0;'
|
||||
MIDLE=$1
|
||||
END='m'
|
||||
echo -n "$START$MIDLE$END"
|
||||
}
|
||||
##==============================================================================
|
||||
## AUX
|
||||
##==============================================================================
|
||||
applyCodeToText()
|
||||
{
|
||||
local RESET=$(getFormattingSequence $(getEffectCode none))
|
||||
TEXT=$1
|
||||
CODE=$2
|
||||
echo -n "$CODE$TEXT$RESET"
|
||||
}
|
||||
##==============================================================================
|
||||
## MAIN FUNCTIONS
|
||||
##==============================================================================
|
||||
##------------------------------------------------------------------------------
|
||||
##
|
||||
getFormatCode()
|
||||
{
|
||||
local RESET=$(getFormattingSequence $(getEffectCode none))
|
||||
## NO ARGUMENT PROVIDED
|
||||
if [ "$#" -eq 0 ]; then
|
||||
echo -n "$RESET"
|
||||
## 1 ARGUMENT -> ASSUME TEXT COLOR
|
||||
elif [ "$#" -eq 1 ]; then
|
||||
TEXT_COLOR=$(getFormattingSequence $(getColorCode $1))
|
||||
echo -n "$TEXT_COLOR"
|
||||
## ARGUMENTS PROVIDED
|
||||
else
|
||||
FORMAT=""
|
||||
while [ "$1" != "" ]; do
|
||||
## PROCESS ARGUMENTS
|
||||
TYPE=$1
|
||||
ARGUMENT=$2
|
||||
case $TYPE in
|
||||
-c)
|
||||
CODE=$(getColorCode $ARGUMENT)
|
||||
;;
|
||||
-b)
|
||||
CODE=$(getBackgroundCode $ARGUMENT)
|
||||
;;
|
||||
-e)
|
||||
CODE=$(getEffectCode $ARGUMENT)
|
||||
;;
|
||||
*)
|
||||
CODE=""
|
||||
esac
|
||||
## ADD CODE SEPARATOR IF NEEDED
|
||||
if [ "$FORMAT" != "" ]; then
|
||||
FORMAT="$FORMAT;"
|
||||
fi
|
||||
## APPEND CODE
|
||||
FORMAT="$FORMAT$CODE"
|
||||
# Remove arguments from stack
|
||||
shift
|
||||
shift
|
||||
done
|
||||
## APPLY FORMAT TO TEXT
|
||||
FORMAT_CODE=$(getFormattingSequence $FORMAT)
|
||||
echo -n "${FORMAT_CODE}"
|
||||
fi
|
||||
}
|
||||
##------------------------------------------------------------------------------
|
||||
##
|
||||
formatText()
|
||||
{
|
||||
local RESET=$(getFormattingSequence $(getEffectCode none))
|
||||
## NO ARGUMENT PROVIDED
|
||||
if [ "$#" -eq 0 ]; then
|
||||
echo -n "${RESET}"
|
||||
## ONLY A STRING PROVIDED -> Append reset sequence
|
||||
elif [ "$#" -eq 1 ]; then
|
||||
TEXT=$1
|
||||
echo -n "${TEXT}${RESET}"
|
||||
## ARGUMENTS PROVIDED
|
||||
else
|
||||
TEXT=$1
|
||||
FORMAT_CODE=$(getFormatCode "${@:2}")
|
||||
applyCodeToText "$TEXT" "$FORMAT_CODE"
|
||||
fi
|
||||
}
|
||||
##------------------------------------------------------------------------------
|
||||
##
|
||||
removeColorCodes()
|
||||
{
|
||||
printf "$1" | sed 's/\x1b\[[0-9;]*m//g'
|
||||
}
|
||||
##==============================================================================
|
||||
## DEBUG
|
||||
##==============================================================================
|
||||
#formatText "$@"
|
||||
#FORMATTED_TEXT=$(formatText "HELLO WORLD!!" -c red -b 13 -e bold -e blink -e strikeout)
|
||||
#echo -e "$FORMATTED_TEXT"
|
||||
#FORMAT=$(getFormatCode -c blue -b yellow)
|
||||
#NONE=$(getFormatCode -e none)
|
||||
#echo -e $FORMAT"Hello"$NONE
|
||||
#!/bin/bash
|
||||
## +-----------------------------------+-----------------------------------+
|
||||
## | |
|
||||
## | Copyright (c) 2019-2020, Andres Gongora <mail@andresgongora.com>. |
|
||||
## | |
|
||||
## | This program is free software: you can redistribute it and/or modify |
|
||||
## | it under the terms of the GNU General Public License as published by |
|
||||
## | the Free Software Foundation, either version 3 of the License, or |
|
||||
## | (at your option) any later version. |
|
||||
## | |
|
||||
## | This program is distributed in the hope that it will be useful, |
|
||||
## | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
## | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
## | GNU General Public License for more details. |
|
||||
## | |
|
||||
## | You should have received a copy of the GNU General Public License |
|
||||
## | along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
||||
## | |
|
||||
## +-----------------------------------------------------------------------+
|
||||
##
|
||||
## DESCRIPTION
|
||||
##
|
||||
## This script takes a path name and shortens it.
|
||||
## - home is replaced by ~
|
||||
## - last folder in apth is never truncated
|
||||
##
|
||||
##
|
||||
## REFERENCES
|
||||
##
|
||||
## Original source: WOLFMAN'S color bash promt
|
||||
## https://wiki.chakralinux.org/index.php?title=Color_Bash_Prompt#Wolfman.27s
|
||||
##
|
||||
##==============================================================================
|
||||
## FUNCTIONS
|
||||
##==============================================================================
|
||||
##------------------------------------------------------------------------------
|
||||
##
|
||||
shortenPath()
|
||||
{
|
||||
## GET PARAMETERS
|
||||
local path=$1
|
||||
local max_length=$2
|
||||
local default_max_length=25
|
||||
local trunc_symbol=".."
|
||||
if [ -z "$path" ]; then
|
||||
echo ""
|
||||
exit
|
||||
elif [ -z "$max_length" ]; then
|
||||
local max_length=$default_max_length
|
||||
fi
|
||||
## CLEANUP PATH
|
||||
## Replace HOME with ~ for the current user, similar to sed.
|
||||
local path=${path/#$HOME/\~}
|
||||
## TRUNCATE DIR IF NEEDED
|
||||
## - Get curred directory (last folder in path)
|
||||
## - Get max length, as the greater of etiher the (desired) max lenght
|
||||
## and the length of the current dir. Dir never gets truncated.
|
||||
## - If path length > max_length
|
||||
## - Truncate the path to max_length
|
||||
## - Clean off path fragments before first '/' (included)
|
||||
## - Append "trunc_symbol", '/', and the clean path
|
||||
local dir=${path##*/}
|
||||
local dir_length=${#dir}
|
||||
local path_length=${#path}
|
||||
local print_length=$(( ( max_length < dir_length ) ? dir_length : max_length ))
|
||||
if [ $path_length -gt $print_length ]; then
|
||||
local offset=$(( $path_length - $print_length ))
|
||||
local truncated_path=${path:$offset}
|
||||
local clean_path=${truncated_path#*/}
|
||||
local short_path=${trunc_symbol}/${clean_path}
|
||||
else
|
||||
local short_path=$path
|
||||
fi
|
||||
## RETURN FINAL PATH
|
||||
echo $short_path
|
||||
}
|
||||
##==============================================================================
|
||||
## COLORS
|
||||
##
|
||||
## Control the color and format scheme of the bash prompt.
|
||||
## The prompt is divided into segments, listed below starting from the left:
|
||||
## - USER: shows the user's name.
|
||||
## - HOST: shows the host's name.
|
||||
## - PWD: shows the current directory.
|
||||
## - GIT: if inside a git repository, shows the name of current branch.
|
||||
## - PYENV: if inside a Python Virtual environment.
|
||||
## - TF: if inside a Terraform Workspace.
|
||||
## - CLOCK: shows current time in H:M format.
|
||||
## - INPUT: actual bash input.
|
||||
##
|
||||
## Valid color options:
|
||||
## - white black light-gray dark-gray
|
||||
## red green yellow blue cyan purple
|
||||
## light-red light-green light-yellow light-blue light-cyan light-purple
|
||||
## - Values in the range [0-255] for 256 bit colors. To check all number-color
|
||||
## pairs for your terminal, you may run the following snippet by HaleTom:
|
||||
## curl -s https://gist.githubusercontent.com/HaleTom/89ffe32783f89f403bba96bd7bcd1263/raw/ | bash
|
||||
## or search something like "bash 256 color codes" on the internet.
|
||||
##
|
||||
##==============================================================================
|
||||
format="USER HOST PWD GIT PYENV TF KUBE"
|
||||
font_color_user="white"
|
||||
background_user="blue"
|
||||
texteffect_user="bold"
|
||||
font_color_host="white"
|
||||
background_host="light-blue"
|
||||
texteffect_host="bold"
|
||||
font_color_pwd="dark-gray"
|
||||
background_pwd="white"
|
||||
texteffect_pwd="bold"
|
||||
font_color_git="light-gray"
|
||||
background_git="dark-gray"
|
||||
texteffect_git="bold"
|
||||
font_color_pyenv="white"
|
||||
background_pyenv="blue"
|
||||
texteffect_pyenv="bold"
|
||||
font_color_kube="white"
|
||||
background_kube="purple"
|
||||
texteffect_kube="bold"
|
||||
font_color_tf="purple"
|
||||
background_tf="light-purple"
|
||||
texteffect_tf="bold"
|
||||
font_color_clock="white"
|
||||
background_clock="light-blue"
|
||||
texteffect_clock="bold"
|
||||
font_color_input="45"
|
||||
background_input="none"
|
||||
texteffect_input="bold"
|
||||
##==============================================================================
|
||||
## BEHAVIOR
|
||||
##==============================================================================
|
||||
separator_char='\uE0B0' # Separation character, '\uE0B0'=triangle
|
||||
separator_padding_left='' #
|
||||
separator_padding_right='' #
|
||||
prompt_horizontal_padding='' #
|
||||
prompt_final_padding='' #
|
||||
segment_padding=' ' #
|
||||
enable_vertical_padding=true # Add extra new line over prompt
|
||||
max_pwd_char="20"
|
||||
##==============================================================================
|
||||
## GIT
|
||||
##==============================================================================
|
||||
git_symbol_synced=''
|
||||
git_symbol_unpushed=' ▲'
|
||||
git_symbol_unpulled=' ▼'
|
||||
git_symbol_unpushedunpulled=' ◆'
|
||||
git_symbol_dirty=' ◔'
|
||||
git_symbol_dirty_unpushed=' ◔ △'
|
||||
git_symbol_dirty_unpulled=' ◔ ▽'
|
||||
git_symbol_dirty_unpushedunpulled=' ◔ ◇'
|
||||
git_update_period_minutes=15 # Use -1 to disable automatic updates
|
||||
#!/bin/bash
|
||||
## +-----------------------------------+-----------------------------------+
|
||||
## | |
|
||||
## | Copyright (c) 2018-2021, Andres Gongora <mail@andresgongora.com>. |
|
||||
## | |
|
||||
## | This program is free software: you can redistribute it and/or modify |
|
||||
## | it under the terms of the GNU General Public License as published by |
|
||||
## | the Free Software Foundation, either version 3 of the License, or |
|
||||
## | (at your option) any later version. |
|
||||
## | |
|
||||
## | This program is distributed in the hope that it will be useful, |
|
||||
## | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
## | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
## | GNU General Public License for more details. |
|
||||
## | |
|
||||
## | You should have received a copy of the GNU General Public License |
|
||||
## | along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
||||
## | |
|
||||
## +-----------------------------------------------------------------------+
|
||||
##
|
||||
## DESCRIPTION
|
||||
##
|
||||
## This script updates your "PS1" environment variable to display colors.
|
||||
## Additionally, it also shortens the name of your current path to a
|
||||
## maximum 25 characters, which is quite useful when working in deeply
|
||||
## nested folders.
|
||||
##
|
||||
##
|
||||
##
|
||||
## REFFERENCES
|
||||
##
|
||||
## * http://tldp.org/HOWTO/Bash-Prompt-HOWTO/index.html
|
||||
##
|
||||
##
|
||||
##==============================================================================
|
||||
## EXTERNAL DEPENDENCIES
|
||||
##==============================================================================
|
||||
[ "$(type -t include)" != 'function' ]&&{ include(){ { [ -z "$_IR" ]&&_IR="$PWD"&&cd "$(dirname "${BASH_SOURCE[0]}")"&&include "$1"&&cd "$_IR"&&unset _IR;}||{ local d="$PWD"&&cd "$(dirname "$PWD/$1")"&&. "$(basename "$1")"&&cd "$d";}||{ echo "Include failed $PWD->$1"&&exit 1;};};}
|
||||
synth_shell_prompt()
|
||||
{
|
||||
##==============================================================================
|
||||
## FUNCTIONS
|
||||
##==============================================================================
|
||||
##------------------------------------------------------------------------------
|
||||
## getGitInfo
|
||||
## Returns current git branch for current directory, if (and only if)
|
||||
## the current directory is part of a git repository, and git is installed.
|
||||
##
|
||||
## In addition, it adds a symbol to indicate the state of the repository.
|
||||
## By default, these symbols and their meaning are (set globally):
|
||||
##
|
||||
## UPSTREAM NO CHANGE DIRTY
|
||||
## up to date SSP_GIT_SYNCED SSP_GIT_DIRTY
|
||||
## ahead SSP_GIT_AHEAD SSP_GIT_DIRTY_AHEAD
|
||||
## behind SSP_GIT_BEHIND SSP_GIT_DIRTY_BEHIND
|
||||
## diverged SSP_GIT_DIVERGED SSP_GIT_DIRTY_DIVERGED
|
||||
##
|
||||
## Returns an empty string otherwise.
|
||||
##
|
||||
## Inspired by twolfson's sexy-bash-prompt:
|
||||
## https://github.com/twolfson/sexy-bash-prompt
|
||||
##
|
||||
getGitBranch()
|
||||
{
|
||||
if ( which git > /dev/null 2>&1 ); then
|
||||
## CHECK IF IN A GIT REPOSITORY, OTHERWISE SKIP
|
||||
local branch=$(git branch 2> /dev/null |\
|
||||
sed -n '/^[^*]/d;s/*\s*\(.*\)/\1/p')
|
||||
if [[ -n "$branch" ]]; then
|
||||
## UPDATE LOCAL GIT BRANCH (i.e., fetch)
|
||||
## This will talk to the remote repository to get the latest
|
||||
## updates. Because doing so for every terminal prompt can
|
||||
## (and will) be slow, the script will do so only if its globaly
|
||||
## enabled and only periodically in the background.
|
||||
if [ "$SSP_GIT_UPDATE_PERIOD_MINUTES" -ge 0 ]; then
|
||||
## Find .git
|
||||
local d="$PWD"
|
||||
local max_lvls=25
|
||||
while [ ! -e "./.git" -a $max_lvls -gt 0 ]; do
|
||||
cd .. # Go up 1 level
|
||||
max_lvls=$((max_lvls - 1))
|
||||
done
|
||||
local dot_git="${PWD}/.git"
|
||||
cd "$d"
|
||||
## Check if submodule
|
||||
if [ -f "$dot_git" ]; then
|
||||
local dot_git=$(cat $dot_git | grep 'gitdir' | sed 's/gitdir:\ //g')
|
||||
fi
|
||||
## Get timestamp
|
||||
if [ -d "$dot_git" -a -e "${dot_git}/FETCH_HEAD" ]; then
|
||||
local git_last_update=$(stat -c "%Y" "${dot_git}/FETCH_HEAD")
|
||||
fi
|
||||
## Update if it's time to do so
|
||||
if [ ! -z $git_last_update ]; then
|
||||
local current_timestamp=$(date +%s)
|
||||
local elapsed_minutes=$(((current_timestamp-git_last_update)/60))
|
||||
if [ "$elapsed_minutes" -ge "$SSP_GIT_UPDATE_PERIOD_MINUTES" ]; then
|
||||
git fetch --recurse-submodules > /dev/null 2>&1 &
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
## GET GIT STATUS
|
||||
## This information contains whether the current branch is
|
||||
## ahead, behind or diverged (ahead & behind), as well as
|
||||
## whether any file has been modified locally (is dirty).
|
||||
## --porcelain: script friendly output.
|
||||
## -b: show branch tracking info.
|
||||
## -u no: do not list untracked/dirty files
|
||||
## From the first line we get whether we are synced, and if
|
||||
## there are more lines, then we know it is dirty.
|
||||
## NOTE: this requires that you fetch your repository,
|
||||
## otherwise your information is outdated.
|
||||
local is_dirty=false &&\
|
||||
[[ -n "$(git status --porcelain)" ]] &&\
|
||||
is_dirty=true
|
||||
local is_ahead=false &&\
|
||||
[[ "$(git status --porcelain -u no -b)" == *"ahead"* ]] &&\
|
||||
is_ahead=true
|
||||
local is_behind=false &&\
|
||||
[[ "$(git status --porcelain -u no -b)" == *"behind"* ]] &&\
|
||||
is_behind=true
|
||||
## SELECT SYMBOL
|
||||
if $is_dirty && $is_ahead && $is_behind; then
|
||||
local symbol=$SSP_GIT_DIRTY_DIVERGED
|
||||
elif $is_dirty && $is_ahead; then
|
||||
local symbol=$SSP_GIT_DIRTY_AHEAD
|
||||
elif $is_dirty && $is_behind; then
|
||||
local symbol=$SSP_GIT_DIRTY_BEHIND
|
||||
elif $is_dirty; then
|
||||
local symbol=$SSP_GIT_DIRTY
|
||||
elif $is_ahead && $is_behind; then
|
||||
local symbol=$SSP_GIT_DIVERGED
|
||||
elif $is_ahead; then
|
||||
local symbol=$SSP_GIT_AHEAD
|
||||
elif $is_behind; then
|
||||
local symbol=$SSP_GIT_BEHIND
|
||||
else
|
||||
local symbol=$SSP_GIT_SYNCED
|
||||
fi
|
||||
## RETURN STRING
|
||||
echo "$branch$symbol"
|
||||
fi
|
||||
fi
|
||||
## DEFAULT
|
||||
echo ""
|
||||
}
|
||||
getTerraform()
|
||||
{
|
||||
## Check if we are in a terraform directory
|
||||
if [ -d .terraform ]; then
|
||||
## Check if the terraform binary is in the path
|
||||
if ( which terraform > /dev/null 2>&1 ); then
|
||||
## Get the terraform workspace
|
||||
local tf="$(terraform workspace show 2> /dev/null | tr -d '\n')"
|
||||
echo "$tf"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
getPyenv()
|
||||
{
|
||||
## Conda environment
|
||||
if [ -n "$CONDA_DEFAULT_ENV" ]; then
|
||||
echo "$CONDA_DEFAULT_ENV"
|
||||
## Python virtual environment
|
||||
elif [ -n "${VIRTUAL_ENV:-}" ]; then
|
||||
local regex='PS1=\"\((.*?)\)\s\$\{PS1'
|
||||
local pyenv=$(cat $VIRTUAL_ENV/bin/activate | perl -n -e"/$regex/ && print \$1" 2> /dev/null)
|
||||
if [ -z "${pyenv}" ]; then
|
||||
local pyenv=$(basename ${VIRTUAL_ENV})
|
||||
fi
|
||||
echo "$pyenv"
|
||||
fi
|
||||
}
|
||||
getKube()
|
||||
{
|
||||
type kubectl &>/dev/null && \
|
||||
type yq &>/dev/null && \
|
||||
echo -n "$(kubectl config view | yq '.contexts[].context.cluster |select(.contexts[].name == .current-context)' | head -n 1)"
|
||||
}
|
||||
printSegment()
|
||||
{
|
||||
## GET PARAMETERS
|
||||
local text=$1
|
||||
local font_color=$2
|
||||
local background_color=$3
|
||||
local next_background_color=$4
|
||||
local font_effect=$5
|
||||
## COMPUTE COLOR FORMAT CODES
|
||||
local no_color="\[$(getFormatCode -e reset)\]"
|
||||
local text_format="\[$(getFormatCode -c $font_color -b $background_color -e $font_effect)\]"
|
||||
local separator_format="\[$(getFormatCode -c $background_color -b $next_background_color)\]"
|
||||
## GENERATE TEXT
|
||||
printf "${text_format}${segment_padding}${text}${segment_padding}${separator_padding_left}${separator_format}${separator_char}${separator_padding_right}${no_color}"
|
||||
}
|
||||
get_colors_for_element()
|
||||
{
|
||||
case $1 in
|
||||
"USER") echo "${SSP_COLORS_USER[@]}" ;;
|
||||
"HOST") echo "${SSP_COLORS_HOST[@]}" ;;
|
||||
"PWD") echo "${SSP_COLORS_PWD[@]}" ;;
|
||||
"GIT") echo "${SSP_COLORS_GIT[@]}" ;;
|
||||
"PYENV") echo "${SSP_COLORS_PYENV[@]}";;
|
||||
"KUBE") echo "${SSP_COLORS_KUBE[@]}";;
|
||||
"TF") echo "${SSP_COLORS_TF[@]}" ;;
|
||||
"CLOCK") echo "${SSP_COLORS_CLOCK[@]}";;
|
||||
"INPUT") echo "${SSP_COLORS_INPUT[@]}";;
|
||||
*)
|
||||
esac
|
||||
}
|
||||
combine_elements()
|
||||
{
|
||||
local first=$1
|
||||
local second=$2
|
||||
local colors_first=($(get_colors_for_element $first))
|
||||
local colors_second=($(get_colors_for_element $second))
|
||||
case $first in
|
||||
"USER") local text="$user" ;;
|
||||
"HOST") local text="$host" ;;
|
||||
"PWD") local text="$path" ;;
|
||||
"GIT") local text="$git_branch" ;;
|
||||
"PYENV") local text="$pyenv" ;;
|
||||
"KUBE") local text="$kube" ;;
|
||||
"TF") local text="$tf" ;;
|
||||
"CLOCK") local text="$clock" ;;
|
||||
"INPUT") local text="" ;;
|
||||
*) local text="" ;;
|
||||
esac
|
||||
local text_color=${colors_first[0]}
|
||||
local bg_color=${colors_first[1]}
|
||||
local next_bg_color=${colors_second[1]}
|
||||
local text_effect=${colors_first[2]}
|
||||
printSegment "$text" "$text_color" "$bg_color" "$next_bg_color" "$text_effect"
|
||||
}
|
||||
##==============================================================================
|
||||
## HOOK
|
||||
##==============================================================================
|
||||
prompt_command_hook()
|
||||
{
|
||||
## GET PARAMETERS
|
||||
## This might be a bit redundant, but it makes it easier to maintain
|
||||
local elements=(${SSP_ELEMENTS[@]})
|
||||
local user=$USER
|
||||
local host=$HOSTNAME
|
||||
local path="$(shortenPath "$PWD" $SSP_MAX_PWD_CHAR)"
|
||||
local git_branch="$(getGitBranch)"
|
||||
local pyenv="$(getPyenv)"
|
||||
local kube="$(getKube)"
|
||||
local tf="$(getTerraform)"
|
||||
local clock="$(date +"%H:%M")"
|
||||
## ADAPT DYNAMICALLY ELEMENTS TO BE SHOWN
|
||||
## Check if elements such as GIT and the Python environment should be
|
||||
## shown and adapt the variables as needed. This usually implies removing
|
||||
## the appropriate field from the "elements" array if the user set them
|
||||
if [ -z "$git_branch" ]; then
|
||||
elements=( ${elements[@]/"GIT"} ) # Remove GIT from elements to be shown
|
||||
fi
|
||||
if [ -z "$pyenv" ]; then
|
||||
elements=( ${elements[@]/"PYENV"} ) # Remove PYENV from elements to be shown
|
||||
fi
|
||||
if [ -z "$tf" ]; then
|
||||
elements=( ${elements[@]/"TF"} ) # Remove TF from elements to be shown
|
||||
fi
|
||||
if [ -z "$kube" ]; then
|
||||
elements=( ${elements[@]/"KUBE"} ) # Remove KUBE from elements to be shown
|
||||
fi
|
||||
## WINDOW TITLE
|
||||
## Prevent messed up terminal-window titles, must be set in the PS1 variable
|
||||
case $TERM in
|
||||
xterm*|rxvt*)
|
||||
SSP_PWD="$path"
|
||||
local titlebar="\[\033]0;\${USER}@\${HOSTNAME}: \${SSP_PWD}\007\]"
|
||||
;;
|
||||
*)
|
||||
local titlebar=""
|
||||
;;
|
||||
esac
|
||||
## CONSTRUCT PROMPT ITERATIVELY
|
||||
## Iterate through all elements to be shown and combine them. Stop once only
|
||||
## 1 element is left, which should be the "INPUT" element; then apply the
|
||||
## INPUT formatting.
|
||||
## Notice that this reuses the PS1 variables over and over again, and appends
|
||||
## all extra formatting elements to the end of it.
|
||||
PS1="${titlebar}${SSP_VERTICAL_PADDING}"
|
||||
while [ "${#elements[@]}" -gt 1 ]; do
|
||||
local current=${elements[0]}
|
||||
local next=${elements[1]}
|
||||
local elements=("${elements[@]:1}") #remove the 1st element
|
||||
PS1="$PS1$(combine_elements $current $next)"
|
||||
done
|
||||
local input_colors=($(get_colors_for_element ${elements[0]}))
|
||||
local input_color=${input_colors[0]}
|
||||
local input_bg=${input_colors[1]}
|
||||
local input_effect=${input_colors[2]}
|
||||
local input_format="\[$(getFormatCode -c $input_color -b $input_bg -e $input_effect)\]"
|
||||
PS1="$PS1 $input_format"
|
||||
## Once this point is reached, PS1 is formatted and set. The terminal session
|
||||
## will then use that variable to prompt the user :)
|
||||
}
|
||||
##==============================================================================
|
||||
## MAIN
|
||||
##==============================================================================
|
||||
## LOAD USER CONFIGURATION
|
||||
local user_config_file="$HOME/.config/synth-shell/synth-shell-prompt.config"
|
||||
local root_config_file="/etc/synth-shell/synth-shell-prompt.root.config"
|
||||
local sys_config_file="/etc/synth-shell/synth-shell-prompt.config"
|
||||
if [ -f $user_config_file ]; then
|
||||
source $user_config_file
|
||||
elif [ -f $root_config_file -a "$USER" == "root" ]; then
|
||||
source $root_config_file
|
||||
elif [ -f $sys_config_file ]; then
|
||||
source $sys_config_file
|
||||
fi
|
||||
## PADDING
|
||||
if $enable_vertical_padding; then
|
||||
local vertical_padding="\n"
|
||||
else
|
||||
local vertical_padding=""
|
||||
fi
|
||||
## CONFIG FOR "prompt_command_hook()"
|
||||
SSP_ELEMENTS=($format "INPUT") # Append INPUT to elements that have to be shown
|
||||
SSP_COLORS_USER=($font_color_user $background_user $texteffect_user)
|
||||
SSP_COLORS_HOST=($font_color_host $background_host $texteffect_host)
|
||||
SSP_COLORS_PWD=($font_color_pwd $background_pwd $texteffect_pwd)
|
||||
SSP_COLORS_GIT=($font_color_git $background_git $texteffect_git)
|
||||
SSP_COLORS_PYENV=($font_color_pyenv $background_pyenv $texteffect_pyenv)
|
||||
SSP_COLORS_KUBE=($font_color_kube $background_kube $texteffect_kube)
|
||||
SSP_COLORS_TF=($font_color_tf $background_tf $texteffect_tf)
|
||||
SSP_COLORS_CLOCK=($font_color_clock $background_clock $texteffect_clock)
|
||||
SSP_COLORS_INPUT=($font_color_input $background_input $texteffect_input)
|
||||
SSP_VERTICAL_PADDING=$vertical_padding
|
||||
SSP_MAX_PWD_CHAR=${max_pwd_char:-20}
|
||||
SSP_GIT_SYNCED=$git_symbol_synced
|
||||
SSP_GIT_AHEAD=$git_symbol_unpushed
|
||||
SSP_GIT_BEHIND=$git_symbol_unpulled
|
||||
SSP_GIT_DIVERGED=$git_symbol_unpushedunpulled
|
||||
SSP_GIT_DIRTY=$git_symbol_dirty
|
||||
SSP_GIT_DIRTY_AHEAD=$git_symbol_dirty_unpushed
|
||||
SSP_GIT_DIRTY_BEHIND=$git_symbol_dirty_unpulled
|
||||
SSP_GIT_DIRTY_DIVERGED=$git_symbol_dirty_unpushedunpulled
|
||||
SSP_GIT_UPDATE_PERIOD_MINUTES=$git_update_period_minutes
|
||||
## For terminal line coloring, leaving the rest standard
|
||||
none="$(tput sgr0)"
|
||||
trap 'echo -ne "${none}"' DEBUG
|
||||
## ADD HOOK TO UPDATE PS1 AFTER EACH COMMAND
|
||||
## Bash provides an environment variable called PROMPT_COMMAND.
|
||||
## The contents of this variable are executed as a regular Bash command
|
||||
## just before Bash displays a prompt.
|
||||
## We want it to call our own command to truncate PWD and store it in NEW_PWD
|
||||
PROMPT_COMMAND=prompt_command_hook
|
||||
}
|
||||
## CALL SCRIPT FUNCTION
|
||||
## - CHECK IF SCRIPT IS _NOT_ BEING SOURCED
|
||||
## - CHECK IF COLOR SUPPORTED
|
||||
## - Check if compliant with Ecma-48 (ISO/IEC-6429)
|
||||
## - Call script
|
||||
## - Unset script
|
||||
## If not running interactively, don't do anything
|
||||
if [ -n "$( echo $- | grep i )" ]; then
|
||||
if [ "${BASH_SOURCE[0]}" == "${0}" ]; then
|
||||
echo -e "Do not run this script, it will do nothing.\nPlease source it instead by running:\n"
|
||||
echo -e "\t. ${BASH_SOURCE[0]}\n"
|
||||
elif [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
|
||||
synth_shell_prompt
|
||||
fi
|
||||
unset synth_shell_prompt
|
||||
unset include
|
||||
fi
|
Loading…
Reference in New Issue