Ensure to only use local vars

This commit is contained in:
Jeremy Gardais 2023-02-21 16:11:56 +01:00
parent 3721b4865c
commit f9cd580e14
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 17 additions and 16 deletions

33
zshrc
View File

@ -59,8 +59,8 @@ else
alias llt='ll --tree' alias llt='ll --tree'
alias lld='ll --group-directories-first' alias lld='ll --group-directories-first'
alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\''' alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'''
fi
## }}} ## }}}
fi
# }}} # }}}
# cat with number on output lines # cat with number on output lines
@ -1237,8 +1237,8 @@ alias ccal='var=$(cal); echo "${var/$(date +%-d)/$(echo -e "\033[1;31m$(date +%-
##Commande utilisant cowsay (ou PONYSAY!!) pour afficher un message ##Commande utilisant cowsay (ou PONYSAY!!) pour afficher un message
function bonjour() { function bonjour() {
MIN_TIME=$(date +%M) local MIN_TIME=$(date +%M)
MODULO_MIN=$(($MIN_TIME % 2)) local MODULO_MIN=$(($MIN_TIME % 2))
if [ $(command -v bash_quote) ] && [ $(command -v cowsay) ]; then if [ $(command -v bash_quote) ] && [ $(command -v cowsay) ]; then
if [ $MODULO_MIN -eq 0 ]; then if [ $MODULO_MIN -eq 0 ]; then
#echo Bonjour $USER, nous sommes le `date +"%A %e %B %Y"`, et il est : `date +"%H"` h `date +"%M"` | cowsay -f $(/bin/ls /usr/share/cowsay/cows -1 | head -n $(expr $$$(date +%s) % $(ls /usr/share/cowsay/cows | wc -w) + 1) | tail -n 1) #echo Bonjour $USER, nous sommes le `date +"%A %e %B %Y"`, et il est : `date +"%H"` h `date +"%M"` | cowsay -f $(/bin/ls /usr/share/cowsay/cows -1 | head -n $(expr $$$(date +%s) % $(ls /usr/share/cowsay/cows | wc -w) + 1) | tail -n 1)
@ -1296,7 +1296,7 @@ function ippriv()
{ {
for interface in $(find /sys/class/net/ ! -name lo -type l -printf "%f\n" | sort); for interface in $(find /sys/class/net/ ! -name lo -type l -printf "%f\n" | sort);
do do
IP_INTER=$(ip a s ${interface}|grep "inet "|awk '{print $2}') local IP_INTER=$(ip a s ${interface}|grep "inet "|awk '{print $2}')
printf '%b' "${WHITEB}${interface}${RESET}: ${IP_INTER}\n" printf '%b' "${WHITEB}${interface}${RESET}: ${IP_INTER}\n"
done done
} }
@ -1314,7 +1314,7 @@ function is_network()
{ {
for path_interface in $(find /sys/class/net/ ! -name lo -type l); for path_interface in $(find /sys/class/net/ ! -name lo -type l);
do do
IS_UP=$(grep 1 ${path_interface}/carrier) local IS_UP=$(grep 1 ${path_interface}/carrier)
if [ ${IS_UP} ]; then if [ ${IS_UP} ]; then
return 0 return 0
fi fi
@ -1327,13 +1327,13 @@ function is_network()
function lowercase() function lowercase()
{ {
for file in *; do for file in *; do
filename=${file##*/} local filename=${file##*/}
case "$filename" in case "$filename" in
*/*) dirname==${file%/*} ;; */*) local dirname==${file%/*} ;;
*) dirname=.;; *) local dirname=.;;
esac esac
nf=$(printf $filename | tr A-Z a-z) local nf=$(printf $filename | tr A-Z a-z)
newname="${dirname}/${nf}" local newname="${dirname}/${nf}"
if [ "$nf" != "$filename" ]; then if [ "$nf" != "$filename" ]; then
mv "$file" "$newname" mv "$file" "$newname"
printf 'lowercase: %s --> %s\n' ${file} ${newname} printf 'lowercase: %s --> %s\n' ${file} ${newname}
@ -1356,11 +1356,11 @@ function printscreen()
function pdflatex() function pdflatex()
{ {
# On récupère le nom du fichier sans l'extension # On récupère le nom du fichier sans l'extension
file_name="${1:r}" local file_name="${1:r}"
# Le fichier avec l'extension pdf # Le fichier avec l'extension pdf
pdf="${file_name}.pdf" local pdf="${file_name}.pdf"
# Dossier temporaire # Dossier temporaire
temp_dir="temp" local temp_dir="temp"
# On supprime le fichier pdf si il est présent # On supprime le fichier pdf si il est présent
if [ -f "${pdf}" ]; then if [ -f "${pdf}" ]; then
@ -2011,7 +2011,7 @@ setopt extendedglob
############### 9. Modules ################ ############### 9. Modules ################
########################################### ###########################################
## fzf ## IF fzf AVAILABLE
if [ -d ~/.fzf ]; then if [ -d ~/.fzf ]; then
## If local fzf bin is available use it in priority ## If local fzf bin is available use it in priority
@ -2223,8 +2223,6 @@ v() {
} }
# }}} # }}}
fi
# pdf fuzzy open PDF file with "${PDF_VIEWER}" from current directory {{{ # pdf fuzzy open PDF file with "${PDF_VIEWER}" from current directory {{{
# Search with fd (fdfind is better than find with a pattern) # Search with fd (fdfind is better than find with a pattern)
# Allow to give arguments to prefill fzf request # Allow to give arguments to prefill fzf request
@ -2492,6 +2490,9 @@ passf() {
} }
# }}} # }}}
fi
## ENDIF fzf AVAILABLE
# }}} # }}}
# zsh-syntax-highlighting {{{ # zsh-syntax-highlighting {{{
## Activate if plugin is available ## Activate if plugin is available