From f9cd580e146737d09b1878453419b7e6b1a77895 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Tue, 21 Feb 2023 16:11:56 +0100 Subject: [PATCH] Ensure to only use local vars --- zshrc | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/zshrc b/zshrc index 6c7fa6f..1980054 100644 --- a/zshrc +++ b/zshrc @@ -59,8 +59,8 @@ else alias llt='ll --tree' alias lld='ll --group-directories-first' alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\''' -fi ## }}} +fi # }}} # 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 function bonjour() { - MIN_TIME=$(date +%M) - MODULO_MIN=$(($MIN_TIME % 2)) + local MIN_TIME=$(date +%M) + local MODULO_MIN=$(($MIN_TIME % 2)) if [ $(command -v bash_quote) ] && [ $(command -v cowsay) ]; 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) @@ -1296,7 +1296,7 @@ function ippriv() { for interface in $(find /sys/class/net/ ! -name lo -type l -printf "%f\n" | sort); 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" done } @@ -1314,7 +1314,7 @@ function is_network() { for path_interface in $(find /sys/class/net/ ! -name lo -type l); do - IS_UP=$(grep 1 ${path_interface}/carrier) + local IS_UP=$(grep 1 ${path_interface}/carrier) if [ ${IS_UP} ]; then return 0 fi @@ -1327,13 +1327,13 @@ function is_network() function lowercase() { for file in *; do - filename=${file##*/} + local filename=${file##*/} case "$filename" in - */*) dirname==${file%/*} ;; - *) dirname=.;; + */*) local dirname==${file%/*} ;; + *) local dirname=.;; esac - nf=$(printf $filename | tr A-Z a-z) - newname="${dirname}/${nf}" + local nf=$(printf $filename | tr A-Z a-z) + local newname="${dirname}/${nf}" if [ "$nf" != "$filename" ]; then mv "$file" "$newname" printf 'lowercase: %s --> %s\n' ${file} ${newname} @@ -1356,11 +1356,11 @@ function printscreen() function pdflatex() { # 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 - pdf="${file_name}.pdf" + local pdf="${file_name}.pdf" # Dossier temporaire - temp_dir="temp" + local temp_dir="temp" # On supprime le fichier pdf si il est présent if [ -f "${pdf}" ]; then @@ -2011,7 +2011,7 @@ setopt extendedglob ############### 9. Modules ################ ########################################### -## fzf +## IF fzf AVAILABLE if [ -d ~/.fzf ]; then ## 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 {{{ # Search with fd (fdfind is better than find with a pattern) # Allow to give arguments to prefill fzf request @@ -2492,6 +2490,9 @@ passf() { } # }}} +fi +## ENDIF fzf AVAILABLE + # }}} # zsh-syntax-highlighting {{{ ## Activate if plugin is available