Skip to content

Instantly share code, notes, and snippets.

View jimkil's full-sized avatar

Jimmy Kilgore jimkil

View GitHub Profile
@jimkil
jimkil / Git push deployment in 7 easy steps.md
Created March 4, 2022 13:04 — forked from thomasfr/Git push deployment in 7 easy steps.md
7 easy steps to automated git push deployments. With small and configurable bash only post-receive hook
  • Use curl to get the JSON response for the latest release
  • Use grep to find the line containing file URL
  • Use cut and tr to extract the URL
  • Use wget to download it
curl -s https://api.github.com/repos/jgm/pandoc/releases/latest \
| grep "browser_download_url.*deb" \
| cut -d : -f 2,3 \
| tr -d \" \
@jimkil
jimkil / clone.bash
Last active March 4, 2022 12:33 — forked from milanboers/clone.bash
[clone-repos-user] Clone all repositories of a Github user #snippet #bash #github #git
# Clone all repositories of a Github user
curl -s https://api.github.com/users/milanboers/repos | grep \"clone_url\" | awk '{print $2}' | sed -e 's/"//g' -e 's/,//g' | xargs -n1 git clone
@jimkil
jimkil / dumps.sh
Last active March 4, 2022 12:33
[dumps] Snippet set to dump copy of files or history export #snippet #bash #dump
# snippet_bash_dump-hist.sh
history > "history_$USER-$HOST-$(date +"%Y-%m-%d_%H-%M-%S").txt"
# snippet_bash_dump-zshrc.sh
cp "$HOME/.zshrc" "$USER-$HOST-dot_zshrc-$(date +"%Y-%m-%d-%H%M%S")"
@jimkil
jimkil / dump-zshrc
Created March 4, 2022 12:09
[dump-zshrc] Dump copy of dot zshrc with host user datestamp #snippet #bash
cp "$HOME/.zshrc" "$USER-$HOST-dot_zshrc-$(date +"%Y-%m-%d-%H%M%S")"
@jimkil
jimkil / dump-history.sh
Created March 4, 2022 12:00
[dump-history] Export history to file including host user and date stamp #snippet #bash
history > "history_$USER-$HOST-$(date +"%Y-%m-%d_%H-%M-%S").txt"
@jimkil
jimkil / Bash quickies.md
Last active March 4, 2022 12:51
[Handy one-liners] Handy commands I use often #snippet #bash #one-liner

gist bash quickies

  • Dump history with user, hostname and date stamp.

history > "history_$USER-$HOSTNAME_$(date +"%Y-%m-%d-%H:%M:%S").txt"

  • Here is a nice grep expression to remove blank lines and comment lines (change file as needed)
    • will display the used settings in sshd_config without any clutter
@jimkil
jimkil / function_got_root.sh
Last active March 4, 2022 12:26
[got-root] Function to check if script running as root. #function #bash #snippet
# bash function to check if user is root
function __got_root() {
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 87 # non-root user exit code
fi
}