Created
June 23, 2025 23:22
-
-
Save iTrauco/55980782b6c7fa08ef101493c51e8ccc to your computer and use it in GitHub Desktop.
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
#!/bin/zsh | |
################################################################# | |
# π GITHUB GIST ALIASES & FUNCTIONS | |
# Collection of aliases for managing GitHub Gists via gh CLI | |
# Author: @trauco | |
# Date Added: 2024-01-15 | |
# Dependencies: gh (GitHub CLI), vim | |
################################################################# | |
################################################################# | |
# π SINGLE FILE GIST CREATION | |
################################################################# | |
# π― gistedit - Create NEW file in vim, save locally, then push to public gist | |
# Usage: gistedit test.sh (creates test.sh locally and on gist) | |
# Date Added: 2024-01-15 | |
alias gistedit='function _gistedit(){ | |
local filename="$1" | |
if [ -z "$filename" ]; then | |
echo "β Usage: gistedit <filename>" | |
return 1 | |
fi | |
vim "$filename" # Create/edit NEW file in vim | |
# File is saved locally when you :wq in vim | |
gh gist create "$filename" --public # Upload to public gist after vim closes | |
}; _gistedit' | |
# π gisteditdesc - Edit file then create public gist with description | |
# Usage: gisteditdesc myfile.py | |
# Date Added: 2024-01-15 | |
alias gisteditdesc='function _gisteditdesc(){ | |
local filename="$1" | |
if [ -z "$filename" ]; then | |
echo "β Usage: gisteditdesc <filename>" | |
return 1 | |
fi | |
vim "$filename" # Edit file first | |
local description | |
echo "π Enter description for the Gist: " | |
read description | |
gh gist create "$filename" --public --description "$description" | |
}; _gisteditdesc' | |
# π gistsecret - Create NEW file in vim, save locally, then push to private gist | |
# Usage: gistsecret private_notes.txt (creates private_notes.txt locally and on gist) | |
# Date Added: 2024-01-15 | |
alias gistsecret='function _gistsecret() { | |
local filename="$1" | |
if [ -z "$filename" ]; then | |
echo "β Usage: gistsecret <filename>" | |
return 1 | |
fi | |
vim "$filename" # Create/edit NEW file in vim | |
# File is saved locally when you :wq in vim | |
gh gist create "$filename" # Upload to private gist after vim closes (default is private) | |
}; _gistsecret' | |
################################################################# | |
# π¦ MULTI-FILE GIST CREATION | |
################################################################# | |
# π gistall - Create multiple NEW files in vim, save locally, then push all to public gist | |
# Usage: gistall file1.py file2.js README.md (creates all files locally and on gist) | |
# Date Added: 2024-01-15 | |
function gistall() { | |
if [ "$#" -eq 0 ]; then | |
echo "β No files provided. Usage: gistall <file1> <file2> ... <fileN>" | |
return 1 | |
fi | |
echo "π¦ Creating new files for public gist:" | |
# Create/edit each file in vim | |
for file in "$@"; do | |
echo " π Creating: $file" | |
vim "$file" # Create each file locally | |
done | |
echo "π Enter a description for the gist:" | |
read -r description | |
# Upload all files to public gist | |
gh gist create "$@" --public -d "$description" | |
echo "β Public gist created with all files!" | |
} | |
# π gistpriv - Create multiple NEW files in vim, save locally, then push all to private gist | |
# Usage: gistpriv secrets.env config.json (creates all files locally and on gist) | |
# Date Added: 2024-01-15 | |
function gistpriv() { | |
if [ "$#" -eq 0 ]; then | |
echo "β No files provided. Usage: gistpriv <file1> <file2> ... <fileN>" | |
return 1 | |
fi | |
echo "π Creating new files for private gist:" | |
# Create/edit each file in vim | |
for file in "$@"; do | |
echo " π Creating: $file" | |
vim "$file" # Create each file locally | |
done | |
echo "π Enter a description for the gist:" | |
read -r description | |
# Upload all files to private gist (gh defaults to private) | |
gh gist create "$@" -d "$description" | |
echo "β Private gist created with all files!" | |
} | |
################################################################# | |
# βοΈ ENVIRONMENT CONFIGURATION | |
################################################################# | |
# π Set vim as the default editor for gh CLI operations | |
# Date Added: 2024-01-15 | |
export GH_EDITOR=vim | |
################################################################# | |
# π QUICK REFERENCE | |
# - gistedit: Quick public gist (single file with vim edit) | |
# - gisteditdesc: Public gist with description (single file) | |
# - gistsecret: Quick private gist (single file with vim edit) | |
# - gistall: Public gist (multiple files) | |
# - gistpriv: Private gist (multiple files) | |
################################################################# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment