From 1bb3de0190021facde17714cbaa06ddcafeb5214 Mon Sep 17 00:00:00 2001 From: FR69 Date: Tue, 18 Jun 2024 11:26:14 +0200 Subject: [PATCH] Ajout alias fix_owning, fix_rights_dir et fix_rights_file --- zsh/zshrc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/zsh/zshrc b/zsh/zshrc index f53a7ae..97c6774 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -85,6 +85,8 @@ export MOZILLA_FIVE_HOME=/usr/lib/mozilla alias -s pdf='okular' setopt autocd correctall +setopt RE_MATCH_PCRE + # Alias alias sudo='sudo ' # Permet d'utiliser les alias avec sudo alias ls='ls --color=auto --group-directories-first -Fh' @@ -113,3 +115,30 @@ find_php() { fi find $arg_path -type f -iname "*.php" -print0 | xargs --null grep $arg_options $1 } + +# fix_owning [:current user (/home)] [:www-data] [] +fix_owning() { + if [[ "$PWD" =~ '^(?:/mnt/part1/liens)?/home/([a-zA_Z0-9_]+)/' ]]; then + readonly user=${1:-$match[1]} + else + readonly user=${1:?"Please provide a user name"} + fi + readonly group=${2:-"www-data"} + readonly dir=${3:-"."} + + sudo chown -Rvf $user:$group $dir +} +# fix_rights_dir [] [] +fix_rights_dir() { + readonly rights=${1:-"775"} + readonly dir=${2:-"."} + + sudo find $dir -type d -exec chmod -vf $rights {} \; +} +# fix_rights_file [] [] +fix_rights_file() { + readonly rights=${1:-"664"} + readonly dir=${2:-"."} + + sudo find $dir -type f -exec chmod -vf $rights {} \; +}