Skip to content

Instantly share code, notes, and snippets.

View tensorfields's full-sized avatar
🍵

David Palma tensorfields

🍵
View GitHub Profile
@tensorfields
tensorfields / gist:1568175
Created January 6, 2012 00:24
Check unread Gmail with nice formatting
curl -u username --silent "https://mail.google.com/mail/feed/atom" | awk 'BEGIN{FS="\n";RS="(</entry>\n)?<entry>"}NR!=1{print "\033[1;31m"$9"\033[0;32m ("$10")\033[0m:\t\033[1;33m"$2"\033[0m"}' | sed -e 's,<[^>]*>,,g' | column -t -s $'\t'
@tensorfields
tensorfields / rename-kvm-guest.txt
Last active August 9, 2017 07:03
Rename KVM guest VM
# Shutdown the VM and rename storage (optional)
$ virsh shutdown old_vm
$ mv /path/to/old_vm.img /path/to/new_vm.img
# Edit virsh template with the new name and storage
$ virsh dumpxml old_vm > new_vm.xml
$ vim new_vm.xml
~~~ new_vm.xml
<name>new_vm</name> # <-- change this line
...
@tensorfields
tensorfields / virt-addr.sh
Created January 3, 2013 22:02
Get a KVM guest's IP address
#!/bin/bash
# Returns the IP address of a running KVM guest VM
# Assumes a working KVM/libvirt environment
#
# Install:
# Add this bash function to your ~/.bashrc and `source ~/.bashrc`.
# Usage:
# $ virt-addr vm-name
# 192.0.2.16
#
@tensorfields
tensorfields / progress-bars.txt
Last active December 10, 2015 14:29
Progress bars for common fs ops
# Commands: mv and cp
# You can alias these to the standard `mv` and `cp` commands
# For safety, I call them something else.
# Requires: rsync
alias rscp='rsync -aP'
alias rsmv='rsync -aP --remove-source-files'
# Commands: dd
# You could make an alias out of this, but be careful when using it!
# $size is the size of the input file (e.g. 1024K, 4096M, etc)