-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(dotfiles): 🐛 fix chmod.aliases.sh
- Loading branch information
1 parent
08cb525
commit 6f3318a
Showing
2 changed files
with
210 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,154 @@ | ||
<!-- markdownlint-disable MD033 MD041 MD043 --> | ||
|
||
<img | ||
src="https://kura.pro/dotfiles/v2/images/logos/dotfiles.svg" | ||
alt="dotfiles logo" | ||
alt="Dotfiles logo" | ||
width="66" | ||
align="right" | ||
/> | ||
|
||
<!-- markdownlint-enable MD033 MD041 --> | ||
|
||
# Dotfiles (v0.2.469) | ||
|
||
Simply designed to fit your shell life 🐚 | ||
**Simply designed to fit your shell life 🐚** | ||
|
||
![Dotfiles banner][banner] | ||
|
||
## 🅲🅷🅼🅾🅳 🅰🅻🅸🅰🆂🅴🆂 | ||
|
||
These aliases provide shortcuts for the chmod command to help you | ||
quickly change the permissions of files and directories. To use them, | ||
add the following lines to your .bashrc or .bash_profile file. | ||
|
||
### Change permissions | ||
|
||
- `000`: (chmod a-rwx) sets permissions so that, (U)ser / owner can't | ||
read, can't write and can't execute. (G)roup can't read, can't write | ||
and can't execute. (O)thers can't read, can't write and can't execute. | ||
- `400`: (chmod a-rw) sets permissions so that, (U)ser / owner can't | ||
read, can't write and can execute. (G)roup can't read, can't write and | ||
can execute. (O)thers can't read, can't write and can execute. | ||
- `444`: (chmod a-r) sets permissions so that, (U)ser / owner can't | ||
read, can't write and can execute. (G)roup can't read, can't write and | ||
can execute. (O)thers can't read, can't write and can execute. | ||
- `600`: (chmod a+rwx,u-x,g-rwx,o-rwx) sets permissions so that, (U)ser | ||
/ owner can read, can write and can't execute. (G)roup can't read, | ||
can't write and can't execute. (O)thers can't read, can't write and | ||
can't execute. | ||
- `644`: (chmod a+rwx,u-x,g-wx,o-wx) sets permissions so that, (U)ser / | ||
owner can read, can write and can't execute. (G)roup can read, can't | ||
write and can't execute. (O)thers can read, can't write and can't | ||
execute. | ||
- `666`: (chmod a+rwx,u-x,g-x,o-x) sets permissions so that, (U)ser / | ||
owner can read, can write and can't execute. (G)roup can read, can | ||
write and can't execute. (O)thers can read, can write and can't | ||
execute. | ||
- `755`: (chmod a+rwx,g-w,o-w) sets permissions so that, (U)ser / owner | ||
can read, can write and can execute. (G)roup can read, can't write | ||
and can execute. (O)thers can read, can't write and can execute. | ||
- `764`: (chmod a+rwx,g-x,o-wx) sets permissions so that, (U)ser / | ||
owner can read, can write and can execute. (G)roup can read, can write | ||
and can't execute. (O)thers can read, can't write and can't execute. | ||
- `777`: (chmod a+rwx) sets permissions so that, (U)ser / owner can | ||
read, can write and can execute. (G)roup can read, can write and can | ||
execute. (O)thers can read, can write and can execute. | ||
|
||
### Change ownership | ||
|
||
- `chgrp`: Change group ownership of files or directories. | ||
- `chgrpr`: Change group ownership of files or directories recursively. | ||
- `chgrpu`: Change group ownership of files or directories recursively | ||
to the current user. | ||
- `chmod`: Change file mode bits. | ||
- `chmodr`: Change file mode bits recursively. | ||
- `chmodu`: Change file mode bits recursively to the current user. | ||
- `chmox`: Make a file executable. | ||
- `chown`: Change file owner and group. | ||
- `chownr`: Change file owner and group recursively. | ||
- `chownu`: Change file owner and group recursively to the current user. | ||
|
||
### Set permissions for specific file types | ||
|
||
- `755d`: Set permissions of all directories to rwxr-xr-x. | ||
- `644f`: Set permissions of all files to rw-r--r--. | ||
|
||
### Set permissions for specific user types | ||
|
||
- `u+x`: Add execute permission for the owner of the file. | ||
- `u-x`: Remove execute permission for the owner of the file. | ||
- `u+w`: Add write permission for the owner of the file. | ||
- `u-w`: Remove write permission for the owner of the file. | ||
- `u+r`: Add read permission for the owner of the file. | ||
- `u-r`: Remove read permission for the owner of the file. | ||
- `g+x`: Add execute permission for the group owner of the file. | ||
- `g-x`: Remove execute permission for the group owner of the file. | ||
- `g+w`: Add write permission for the group owner of the file. | ||
- `g-w`: Remove write permission for the group owner of the file. | ||
- `g+r`: Add read permission for the group owner of the file. | ||
- `g-r`: Remove read permission for the group owner of the file. | ||
- `o+x`: Add execute permission for others. | ||
- `o-x`: Remove execute permission for others. | ||
- `o+w`: Add write permission for others. | ||
- `o-w`: Remove write permission for others. | ||
- `o+r`: Add read permission for others. | ||
- `o-r`: Remove read permission for others. | ||
|
||
### Set permissions based on octal notation | ||
|
||
- `000`: Set permissions to ---------- | ||
- `400`: Set permissions to r-------- | ||
- `444`: Set permissions to r--r--r-- | ||
- `600`: Set permissions to rw------- | ||
- `644`: Set permissions to rw-r--r--. | ||
- `664`: Set permissions to rw-rw-r--. | ||
- `755`: Set permissions to rwxr-xr-x. | ||
- `775`: Set permissions to rwxrwxr-x. | ||
- `777`: Set permissions to rwxrwxrwx. | ||
--- | ||
|
||
## 🚀 Introduction | ||
|
||
This script provides an enhanced set of shortcuts and functions for the `chmod` command, making it easier to manage file and directory permissions. With features like input validation, recursive confirmation, and user-friendly aliases, you can efficiently customize permissions for files and directories. | ||
|
||
--- | ||
|
||
## 🛠️ Features | ||
|
||
### 🌟 Permission Aliases | ||
|
||
Quickly apply common permission settings with pre-defined aliases: | ||
|
||
| Alias | Permissions | Description | | ||
|--------------|------------------|-----------------------------------------------------------------------------| | ||
| `chmod_000` | `----------` | No permissions for anyone | | ||
| `chmod_400` | `r--------` | Read-only for the owner | | ||
| `chmod_444` | `r--r--r--` | Read-only for everyone | | ||
| `chmod_600` | `rw-------` | Read/write for the owner | | ||
| `chmod_644` | `rw-r--r--` | Read/write for the owner, read-only for others | | ||
| `chmod_666` | `rw-rw-rw-` | Read/write for everyone | | ||
| `chmod_755` | `rwxr-xr-x` | Full permissions for the owner, read/execute for others | | ||
| `chmod_764` | `rwxrw-r--` | Full permissions for the owner, read/write for the group, read-only for others | | ||
| `chmod_777` | `rwxrwxrwx` | Full permissions for everyone | | ||
|
||
--- | ||
|
||
### 🔧 Recursive Confirmation for Permissions | ||
|
||
The `change_permission` function allows you to recursively apply permissions with a confirmation prompt, displaying the number of items affected: | ||
|
||
```bash | ||
change_permission 755 /path/to/directory -R | ||
``` | ||
|
||
--- | ||
|
||
### 📂 User, Group, and Others Shortcuts | ||
|
||
Fine-tune permissions for specific user groups (owner, group, or others): | ||
|
||
| Alias | Description | | ||
|---------------|--------------------------------------------| | ||
| `chmod_u+x` | Add execute permission for the owner | | ||
| `chmod_u-x` | Remove execute permission for the owner | | ||
| `chmod_u+w` | Add write permission for the owner | | ||
| `chmod_u-w` | Remove write permission for the owner | | ||
| `chmod_u+r` | Add read permission for the owner | | ||
| `chmod_u-r` | Remove read permission for the owner | | ||
| `chmod_g+x` | Add execute permission for the group | | ||
| `chmod_g-x` | Remove execute permission for the group | | ||
| `chmod_g+w` | Add write permission for the group | | ||
| `chmod_g-w` | Remove write permission for the group | | ||
| `chmod_g+r` | Add read permission for the group | | ||
| `chmod_g-r` | Remove read permission for the group | | ||
| `chmod_o+x` | Add execute permission for others | | ||
| `chmod_o-x` | Remove execute permission for others | | ||
| `chmod_o+w` | Add write permission for others | | ||
| `chmod_o-w` | Remove write permission for others | | ||
| `chmod_o+r` | Add read permission for others | | ||
| `chmod_o-r` | Remove read permission for others | | ||
|
||
--- | ||
|
||
### 📄 Custom Aliases for File Types | ||
|
||
Set permissions for specific file types with ease: | ||
|
||
| Alias | Description | | ||
|--------------|------------------------------------------------| | ||
| `chmod_755d` | Set permissions of all directories to `rwxr-xr-x` | | ||
| `chmod_644f` | Set permissions of all files to `rw-r--r--` | | ||
|
||
--- | ||
|
||
## 📦 Installation | ||
|
||
1. Clone this repository: | ||
|
||
```bash | ||
git clone https://github.com/sebastienrousseau/dotfiles.git | ||
``` | ||
|
||
2. Source the script in your shell configuration file: | ||
|
||
```bash | ||
echo 'source /path/to/dotfiles/chmod.sh' >> ~/.bashrc | ||
``` | ||
|
||
3. Reload your shell: | ||
|
||
```bash | ||
source ~/.bashrc | ||
``` | ||
|
||
--- | ||
|
||
## 🧑💻 Usage | ||
|
||
Here are some examples of how to use the `chmod` aliases and functions: | ||
|
||
- Apply common permissions: | ||
|
||
```bash | ||
chmod_644 /path/to/file | ||
chmod_755 /path/to/directory | ||
``` | ||
|
||
- Modify user, group, or others' permissions: | ||
|
||
```bash | ||
chmod_u+x /path/to/script | ||
chmod_g-w /path/to/file | ||
chmod_o+r /path/to/file | ||
``` | ||
|
||
- Recursively set permissions with confirmation: | ||
|
||
```bash | ||
change_permission 755 /path/to/directory -R | ||
``` | ||
|
||
--- | ||
|
||
## 🛡️ License | ||
|
||
This project is licensed under the [MIT License](https://opensource.org/licenses/MIT). See the `LICENSE` file for more information. | ||
|
||
--- | ||
|
||
## 👨💻 Author | ||
|
||
Created with ♥ by [Sebastien Rousseau](https://sebastienrousseau.com) | ||
|
||
- Website: [https://sebastienrousseau.com](https://sebastienrousseau.com) | ||
- GitHub: [https://github.com/sebastienrousseau](https://github.com/sebastienrousseau) | ||
|
||
[banner]: https://kura.pro/dotfiles/v2/images/titles/title-dotfiles.svg |
Oops, something went wrong.