How to interactive select and replace text in Vi

Leave a comment

Edit file

Screen Shot 2016-03-17 at 2.26.28 PM.png
Cntrl – V to enter Visual block mode

Select the text you want to replace

Screen Shot 2016-03-17 at 2.27.05 PM.png

Press c – to delete

Screen Shot 2016-03-17 at 2.27.36 PM.png
Type what you want to appear

Screen Shot 2016-03-17 at 2.28.02 PM.png
Press esc to see it all magically appear

Screen Shot 2016-03-17 at 2.28.25 PM.png

Altervativly can do a global replace in with with


How to skip forwards and backwards command line Mac OSX

Leave a comment

To move faster on the command line edit your terminal profile preferences and check the ‘Use Option as Meta key’ checkbox.

This will let you then move forwards and backwards on the command line with Option + B/F.

Screen Shot 2015-10-02 at 7.08.47 AM

How to read files from dir and generate html output


When creating videos, I take snapshots of keynote, upload to website, and then manually handcraft the html to include in the show notes. It’s slow, tedious, and not a lot of fun.

So today I created a ruby script to do this for me.


date = ARGV[0] # 2013/06
alt = ARGV[1] # iteration mechanics
basedir = "/Users/jrasmusson/Desktop"
files = Dir.glob(basedir + "/*.png")
files.each do |k|   puts "<img src=\"http://xxx/" + date + "/" + File.basename(k) + "?w=500\" alt=\"" + alt + "\" /><hr>"

> ruby imageconverter.rb 2013/06 “iteration mechanics” | pbcopy

<img src="http://xxx/2013/06/im-analysis.png?w=500" alt="iteration mechanics" /><hr>
<img src="http://xxx/2013/06/im-check-the-work.png?w=500" alt="iteration mechanics" /><hr>
<img src="http://xxx/2013/06/im-do-the-work.png?w=500" alt="iteration mechanics" /><hr>

To see the output on screen, run without the pbcopy mac command at the end which copies to clip board.

The only thing I haven’t been able to do is make this ruby script globally available from any directory (like a bash script).

If anyone has any ideas on how to do that I would be very grateful.

.bash_profile and handy scripts


Just a copy of my .bash_profile in case I ever forget it.

Misc unix commands
> du -sh *


export PATH=$PATH:~/scripts
export JAVA_HOME=/Library/Java/Home
alias nutshell='cd /Users/jrasmusson/Developer/agilenutshell'
alias reduce='sips --resampleWidth 200 a.png --out b.png'
alias ios='cd /Users/jrasmusson/Developer/iosbyexample'
alias gs='git status'
alias test='bundle exec rspec spec'

My scripts directory: easy git checkin

echo "Checking in..." 

git add .

if [ -z "$1" ]
 git commit -a -m "cleanup"
 git commit -a -m "$1"

git push
echo "Done!" resets my git repository

echo &amp;amp;quot;Reseting git repository&amp;amp;quot;
git reset --hard HEAD^
git clean -f
git merge origin/master

chmod 711

Something that handles ssh


echo "ssh mount..."
ssh -t -t root@ <<EOF
mount -o remount,rw /system

echo "copying..."
scp root@
echo "ssh chmod"
ssh root@ <<EOF
chmod 0744 /system/chrome/plugins/

How to change heroku git remote


If case you ever need to map your git remote back to an existing url do this:

> git remote -v

heroku (fetch)
heroku (push)
origin (fetch)
origin (push)

Right now heroku is pointed at protected-reef. But I want it to point to:

To do that is use this command:

> git remote add heroku

> git remote -v
heroku (fetch)
heroku (push)
origin (fetch)
origin (push)


Update: If you don’t have your heroku remote created, do this:

> heroku create
> git remote set-url heroku

How to kill Xcode from the command line


echo "Killing xcode..."
kill $(ps aux | grep 'Xcode' | awk '{print $2}')

Simple bash script to reset your git repository

1 Comment

Here’s a simple script I use whenever I screw up (often) and need to reset my git local git repository to a clean slate.

echo "Reseting git repository"
git reset --hard HEAD^
git clean -f
git merge origin/master 

Older Entries

%d bloggers like this: