Skip to content

Instantly share code, notes, and snippets.

View timofurrer's full-sized avatar
Commits are my own. Powered by coffee.

Timo Furrer timofurrer

Commits are my own. Powered by coffee.
View GitHub Profile
@timofurrer
timofurrer / gist:2931425
Created June 14, 2012 16:46
Apple Keyboard Xmodmap
! Swap Alt and Cmd keys.
keycode 37 = Control_L
keycode 49 = less greater less greater backslash brokenbar bar
keycode 133 = Alt_L Meta_L
keycode 64 = Super_L
keycode 108 = Super_R
keycode 134 = ISO_Level3_Shift Multi_key
keycode 105 = Control_R Multi_key
clear Shift
clear Lock
@timofurrer
timofurrer / gist:3924126
Created October 20, 2012 17:27
Remove old linux images, headers and modules
dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get -y purge
@timofurrer
timofurrer / gist:4087558
Created November 16, 2012 13:58
bash function to show last error code in bash prompt
function __return_value()
{
ret=$?
if [[ "$ret" -ne "0" ]]; then
echo -e "\033[1;31m[Error: \033[0;31m$ret\033[1;31m]\033[00m"
fi
}
@timofurrer
timofurrer / gist:4706153
Created February 4, 2013 11:04
mount /dev and /proc in chroot environment
mount -t proc none /mnt/chroot/proc
mount -o bind /dev /mnt/chroot/dev
@timofurrer
timofurrer / select.sh
Created February 6, 2013 09:10
bash select menu example (choose block device which matches pattern /dev/sd?)
#!/bin/bash
PS3="Choose device: "
select dev in /dev/sd?
do
echo you picked device $dev \($REPLY\)
break
done
@timofurrer
timofurrer / .Xmodmap
Created March 24, 2013 17:33
Xmodmap for mac keyboard
! Swap Alt and Cmd keys.
keycode 37 = Control_L
keycode 49 = less greater less greater backslash brokenbar bar
keycode 133 = Alt_L Meta_L
keycode 64 = Super_L
keycode 108 = Super_R
keycode 134 = ISO_Level3_Shift Multi_key
keycode 105 = Control_R Multi_key
clear Shift
clear Lock
@timofurrer
timofurrer / .tmux.conf
Created April 28, 2013 12:25
my tmux conf
# tuxtimo's tmux configuration
# Reload config
bind r source-file ~/.tmux.conf \; display "Configuration reloaded..."
# set terminal colors
set -g default-terminal "screen-256color"
# pane selection (vim style)
bind h select-pane -L
@timofurrer
timofurrer / login_notify.sh
Created June 15, 2013 13:29
show notification when someone logs into your computer (maybe per ssh - whatever) File location should be: `/etc/profile.d/login_notify.sh`
DISPLAY=:0 notify-send -t 10000 -u critical "User loggin in:" `whoami`
@timofurrer
timofurrer / .bash_aliases
Created June 15, 2013 13:32
cat & less with syntax highlighting!
# cat & less with syntax highlighting
alias ccat="pygmentize -f terminal256 -O style=native -g"
function cless() {
ccat "$1" | less -R
}
@timofurrer
timofurrer / .bash_aliases
Created June 15, 2013 13:33
cp and move commands with progress bar using rsync
# copy and move with progress bar
alias pcp='rsync -aP'
alias pmv='rsync -aP --remove-source-files'