Created
January 5, 2026 18:04
-
-
Save AlbertoEAF/e91206aa969703130227953fb86552d5 to your computer and use it in GitHub Desktop.
Collection of aliases
This file contains hidden or 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
| alias gitp="git pull" | |
| alias gitP="git push" | |
| alias gitf="git fetch -a" | |
| alias gitb="git branch" | |
| alias gits="git status" | |
| alias gitl="git log" | |
| alias gitd="git diff" | |
| alias gitD="git difftool --dir-diff" | |
| alias gitc="git checkout" | |
| mygpg() { | |
| # 1. Defaults | |
| local filename="tmp.pgp" | |
| local base_dir="$HOME/.pgp" | |
| local do_edit=false | |
| local do_encrypt=false | |
| local do_decrypt=false | |
| # Reset arg parser | |
| local OPTIND=1 | |
| # 2. Security Check: Does the directory exist? | |
| if [ ! -d "$base_dir" ]; then | |
| echo "⚠️ Error: The secure directory $base_dir does not exist." | |
| echo "You must create it with restricted permissions (drwx------) to continue." | |
| echo "" | |
| echo "Run these commands:" | |
| echo "--------------------------------" | |
| echo "mkdir -p $base_dir" | |
| echo "chmod 700 $base_dir" | |
| echo "--------------------------------" | |
| return 1 | |
| fi | |
| # 3. Parse Arguments | |
| # -f: Filename | |
| # -e: Edit | |
| # -c: En(c)rypt | |
| # -d: Decrypt | |
| while getopts "f:ecd" opt; do | |
| case $opt in | |
| f) filename="$OPTARG" ;; | |
| e) do_edit=true ;; | |
| c) do_encrypt=true ;; | |
| d) do_decrypt=true ;; | |
| *) echo "Usage: mygpg [-f filename] [-e (edit)] [-c (encrypt)] [-d (decrypt)]"; return 1 ;; | |
| esac | |
| done | |
| local full_path="$base_dir/$filename" | |
| # --- ACTION 1: EDIT (-e) --- | |
| if [ "$do_edit" = true ]; then | |
| vi "$full_path" | |
| fi | |
| # --- ACTION 2: ENCRYPT (-c) --- | |
| if [ "$do_encrypt" = true ]; then | |
| # --yes forces overwrite | |
| gpg --symmetric --yes --output "$full_path" "$full_path" | |
| fi | |
| # --- ACTION 3: DECRYPT (-d) --- | |
| if [ "$do_decrypt" = true ]; then | |
| # Buffer Flush (The Linux Fix) | |
| # Clears pending Enter keys/junk from previous steps | |
| read -t 0.1 -n 10000 discard < /dev/tty | |
| # Interactive Prompt | |
| echo -n "Password in clipboard? [Enter] to decrypt $filename..." | |
| read -r < /dev/tty | |
| # Decrypt | |
| gpg --decrypt "$full_path" | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment