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

:%s/pick/squash/g

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

2 Comments

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.

imageconverter.rb

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>"
end

> 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

2 Comments

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

Misc unix commands
> du -sh *

.bash_profile

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:

ci.sh easy git checkin

#!/bin/bash
echo "Checking in..." 

git add .

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

git push
echo "Done!"

reset.sh resets my git repository

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

chmod 711 ci.sh reset.sh

Something that handles ssh

#!/bin/sh

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

echo "copying..."
scp libspotify.so root@192.168.1.107:/system/chrome/plugins/libspotify.so
echo "ssh chmod"
ssh root@192.168.1.107 <<EOF
chmod 0744 /system/chrome/plugins/libspotify.so
reboot
exit
EOF

How to change heroku git remote

4 Comments

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

> git remote -v

heroku git@heroku.com:protected-reef-4420.git (fetch)
heroku git@heroku.com:protected-reef-4420.git (push)
origin git@github.com:rasmus4200/agilenutshell.git (fetch)
origin git@github.com:rasmus4200/agilenutshell.git (push)

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

hidden-ridge-8790.herokuapp.com

To do that is use this command:

> git remote add heroku git@heroku.com:hidden-ridge-8790.git

> git remote -v
heroku git@heroku.com:hidden-ridge-8790.git (fetch)
heroku git@heroku.com:hidden-ridge-8790.git (push)
origin git@github.com:rasmus4200/agilenutshell.git (fetch)
origin git@github.com:rasmus4200/agilenutshell.git (push)

Done

http://git-scm.com/book/ch2-5.html

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

> heroku create
> git remote set-url heroku git@heroku.com:hidden-ridge-8790.git

How to kill Xcode from the command line

7 Comments

#!/bin/bash
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.

reset.sh


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

Older Entries

%d bloggers like this: