b0052c7958db673bcf9d7a14103599c11e2b0513

Author
Matthieu PETIOT <matt@ardeidae.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Add argument to set644 and set755 perms alias. (#6959)

This can avoid big mistakes as this I just made.
I thought I could give it an argument. So, now, it is possible.

Diff

 1diff --git a/plugins/perms/README.md b/plugins/perms/README.md
 2index 873c21d427069371870c2475348d33eec91ba1c6..324b3f3cc3465a3d0776f4870beb1a8e393a34ab 100644
 3--- a/plugins/perms/README.md
 4+++ b/plugins/perms/README.md
 5@@ -4,6 +4,6 @@ Plugin to handle some unix filesystem permissions quickly
 6 
 7 ### Usage
 8 
 9-* `set755` recursively sets all directories located within the current working directory and sub directories to octal 755.
10-* `set644` recursively sets all files located within the current working directory and sub directories to octal 644.
11-* `fixperms` is a wrapper around `set755` and `set644` applied to a specified directory or the current directory otherwise. It also prompts prior to execution unlike the other two  aliases.
12+* `set755` recursively sets all given directories (default to .) to octal 755.
13+* `set644` recursively sets all given files (default to .) to octal 644.
14+* `fixperms` is a wrapper around `set755` and `set644` applied to a specified directory or the current directory otherwise. It also prompts prior to execution unlike the other two  aliases.
15diff --git a/plugins/perms/perms.plugin.zsh b/plugins/perms/perms.plugin.zsh
16index 7cdebab7f792e598241c7863954d79259adca62f..1a7472c1cb9d8939fa16d957a02010cf0f12f04e 100644
17--- a/plugins/perms/perms.plugin.zsh
18+++ b/plugins/perms/perms.plugin.zsh
19@@ -6,10 +6,14 @@
20 ### Aliases
21 
22 # Set all files' permissions to 644 recursively in a directory
23-alias set644='find . -type f ! -perm 644 -print0 | xargs -0 chmod 644'
24+set644() {
25+	find "${@:-.}" -type f ! -perm 644 -print0 | xargs -0 chmod 644
26+}
27 
28 # Set all directories' permissions to 755 recursively in a directory
29-alias set755='find . -type d ! -perm 755 -print0 | xargs -0 chmod 755'
30+set755() {
31+	find "${@:-.}" -type d ! -perm 755 -print0 | xargs -0 chmod 755
32+}
33 
34 ### Functions
35