Skip to content

Instantly share code, notes, and snippets.


Eduardo Leggiero leggiero

View GitHub Profile
leggiero / hub-upgrade
Last active May 30, 2020
Install or upgrade hub; ideal to run via cron, e.g. /etc/cron.weekly/hub-upgrade
View hub-upgrade
set -e
if [ -f /usr/local/bin/hub ]; then
current_version=$(/usr/local/bin/hub --version | grep "hub version" | cut -d' ' -f3)
latest_version=$(curl -s | grep -oP '"tag_name": "v?\K(.*)(?=")')
leggiero / npm-upgrade
Last active Jun 14, 2020
Install or upgrade npm; ideal to run via cron
View npm-upgrade
set -e
if [ "$EUID" = "0" ] && [ ! -f /usr/etc/npmrc ]; then
mkdir -p /usr/etc
echo "prefix = /usr/local" > /usr/etc/npmrc
npm install --global --no-progress --quiet npm >/dev/null
leggiero / composer-upgrade
Last active May 30, 2020
Install or upgrade compose; ideal to run via cron, e.g. /etc/cron.weekly/composer-upgrade
View composer-upgrade
set -e
if [ ! -f /usr/local/bin/composer ]; then
setup_file=$(mktemp /tmp/$(basename "$0").XXXXXX)
trap "{ rm -f $setup_file; }" EXIT
php -r "copy('', '$setup_file');"
eval "php $setup_file --quiet --install-dir=/usr/local/bin --filename=composer"
composer --quiet self-update
leggiero / .zshenv
Created Apr 8, 2020
Start ssh-agent on login
View .zshenv
function start_agent {
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add 2> /dev/null;
if [ -z "$SSH_AUTH_SOCK" ]; then
View sudoers
# Default in Debian
Defaults env_reset
# Addded to share ssh agent between user and root when using sudo
Defaults env_keep+="SSH_AUTH_SOCK"
View ssh_config_proxy_example
Host host
HostName hostname.test
User username
Host subhost
User subhost_username
ProxyCommand ssh -q hostalias nc -q0 subhost 22
Host *
ForwardAgent yes