[cc lang="bash"]
export PS1=”\n[\[\e[1;37m\]\u\[\e[0m\]@\[\e[1;34m\]\H\[\e[0m\]] [\[\e[1;33m\]\d, \t\[\e[0m\]] [\[\e[1;31m\]\!\[\e[0m\]]\n\[\e[1;31m\]\[\e[0m\][\[\e[1;37m\]\w\[\e[0m\]]\n\[\e[1;37m\]\\$\[\e[0m\] ”
export HISTTIMEFORMAT=’%F %T ‘
export HISTCONTROL=ignoredups
export HISTCONTROL=ignoreboth
export HISTIGNORE=’pwd:ls:history:’
eval `dircolors`
alias ls=’ls –color=auto’
alias dir=’ls –color=auto –format=vertical’
alias ll=’ls -Al’
alias la=’ls -A’
alias lh=’ls -Alh’
alias grep=’grep –color=auto’
alias fgrep=’fgrep –color=auto’
alias egrep=’egrep –color=auto’
alias dateclip=’date|xsel –clipboard’
alias tsclip=’echo -n “$(date +%Y-%m-%d-%H.%M.%S)”|xsel –clipboard’
alias tstmp=’date +%Y-%m-%d-%H.%M.%S’
alias cryptclip=”xsel|gpg -ear ace@tommybutler.me|xsel –clipboard”
alias putclip=”xsel –clipboard”
alias getclip=”xsel”
alias procstat=”ps -e -o pcpu,pid,cpu,nice,state,cputime,args –sort -pcpu | sed ‘/^ 0.0 /d’”
alias wylie=’l=20; x=1300; y=100; d=-5;for i in `seq $x $d $y`; do beep -l $l -f $i; done’
beepwhenup () { echo ‘Enter host you want to ping:’; read PHOST; if [[ "$PHOST" == "" ]]; then exit; fi; while true; do ping -c1 -W2 $PHOST 2>&1 >/dev/null; if [[ "$?" == "0" ]]; then for j in $(seq 1 4); do beep; done; ping -c1 $PHOST; break; fi; done; }
shopt -s checkwinsize
export PATH=${PATH}:/home/tommy/android-sdk-linux_86/tools
alias vimclean=”find . -iname ‘*sw[po]‘ -print -delete”
[/cc]
The coveted .bashrc of Tommy Butler
January 15th, 2010remove the first N characters from each line of output (bash)
December 23rd, 2009If you want to remove the first, let’s say, 27 characters from each line of output, you would:
[CC lang="bash"]$ some command|sed ’s/^.\{27\}//’[/CC]
clone partition table from one hard drive to another (one step)
December 22nd, 2009[CC lang="bash"]sfdisk /dev/sdb <(sfdisk -d /dev/sda|perl -pi -e ’s/sda/sdb/g’)[/CC]
Burn an ISO image to writable CD
December 2nd, 2009[CC lang="bash"]wodim cdimage.iso[/CC]
Does life get much easier? Read up about wodim for an understanding of its origins in relation to the older `cdrecord` utility
convert vdi to vmdk (virtualbox hard disk conversion to vmware hard disk format)
December 2nd, 2009Convert vdi to vmdk (virtualbox hard disk conversion to vmware hard disk format)
[CC lang="bash"]VBoxManage internalcommands converttoraw winxp.vdi winxp.raw && qemu-img convert -O vmdk winxp.raw winxp.vmdk && rm winxp.raw[/CC]
Converts a .vdi file to a .vmdk file for use in a vmware virtual machine. The benefit: using this method actually works. There are others out there that claim to give you a working .vmdk by simply using the qemu-img command alone. Doing that only results in pain for you because the .vmdk file will be created with no errors, but it won’t boot either.
Be advised that these conversions are very disk-intensive by nature; you are probably dealing with disk images several gigabytes in size.
Once finished, the process of using the new .vmdk file is left as an exercise to the reader.
Easiest commandline search and replace that I know
December 2nd, 2009[cc lang="bash"]perl -pi -e ’s/$findstr/$replacestr/g’ file1 [file2, file3...][/cc]
It does not get much better than that. And oooooooo baby it’s fast too!
The sacred .vimrc of Tommy Butler
December 2nd, 2009[cc lang="vim"]
:set nocompatible
:filetype plugin indent on
:syntax enable
:set background=dark
:set tabstop=3
:set shiftwidth=3
:set softtabstop=3
:set ignorecase
:set expandtab
:set modeline
:set ruler
:set showmatch
:set nohlsearch
:nnoremap
:set pastetoggle=
:let perl_fold=1
:set foldmethod=syntax
:set cursorline
:set number
:set backspace=eol,indent,start
:autocmd BufWritePre * :%s/\s\+$//e
:autocmd BufReadPost * if line(“‘\”") > 0 && line(“‘\”") <= line(“$”) | exe “normal g’\”" | endif
” vim: set ft=vim :
[/cc]
- updated Fri Jan 15 05:26:47 CST 2010 (becuz it just keeps getting more and more awesome)
Backup everything from your local GPG setup
December 2nd, 2009[cc lang="bash"]gpg –export-options export-local-sigs,export-attributes,export-sensitive-revkeys –export-secret-keys –armor > seckey.asc
gpg –export-options export-local-sigs,export-attributes,export-sensitive-revkeys –export –armor > pubkey.asc
gpg –export-ownertrust –armor > ownertrust.asc[/cc]
Run Trac without Apache, and include basic auth support
December 2nd, 2009[cc lang="bash"]/usr/bin/sudo -u www-data /usr/bin/tracd -p 80 -b $HOST -s -d –basic-auth=’*',/usr/share/trac/.htpasswd,/usr/share/trac /usr/share/trac[/cc]
…then set up rinetd to forward port 80 to port 8080 (you’ll have to install rinetd first; the configuration file for rinetd is very straightforward and doesn’t really need any explanation here)
Select the actual column names from a table in MySQL
December 2nd, 2009[cc lang="sql"]
SELECT column_name
FROM information_schema.`COLUMNS` columns
WHERE table_name = ‘TABLE_NAME’;[/cc]