Multiple gitconfig

I need to do dev of work on my personal laptop. Usually, I will clone the repository and set a work email for that repository by git config <>. That requests config for each working repositories, and if there are other settings, it requires more actions. And most important, I forget to set up it sometimes. Later, I did search on the internet and found I am actually able to set a separated gitconfig for the specific folder. Below are the steps. Create a separated gitconfig file ~/.gitconfig-work Add the settings you need into the file, like email/name git config -f ~/.gitconfig-work <> Now we have gitconfig file for working. Set work folder to use the new config file git config --global "includeIf.gitdir:~/work/.path" "~/.gitconfig-work" Then for all repositories inside of work folder, it will use the new config file. Bouns Add isWork to the new config file git config -f ~/.gitconfig-work core.isWork true And run below command inside of the work folder to see if the config is applied git config --get core.isWork || echo false credit/reference: []

Hugo Theme Twentytwenty

Blog theme is the one of my writing motivation. Once I saw some nice looking themes, I would like to use it on my blog, or reinvent the wheel.


Panic/recover and goroutine in Golang

The panic recover is only alive within the current thread, that means each goroutine need it’s own panic recover The panic in this goroutine, wont be caught by the recover, it will panic. defer func() { if rec := recover(); rec != nil { fmt.Println("Catched panic", rec) } }() fmt.Println("Hello, playground") wg := sync.WaitGroup{} wg.Add(1) go func() { defer wg.Done() panic("You can't catch me!") }() wg.Wait() To catch the panic inside of the goroutine, you need code the recover again defer func() { if rec := recover(); rec != nil { fmt.Println("Catched panic", rec) } }() fmt.Println("Hello, playground") wg := sync.WaitGroup{} wg.Add(1) go func() { defer func() { if rec := recover(); rec != nil { fmt.Printf("Now catched `%v`\n", rec) } }() defer wg.Done() panic("You can't catch me!") }() wg.Wait() More reading Website: Weekly tech bookmarks: funcmarks

nvALT Revisit

I am looking for an app to do random text input on the macOS, and sync through my own and company’s laptops. I tried Tot/Drafts, since I removed my iCloud account on the company’s laptop, the only modern way is using Dropbox. Then I get back the nvALT after I found it supports backlink, but inside of the app itself, by using [[text]], you can click it to search the nvALT with text. Gruvbox Dark Color Based on Gruvbox color scheme Font: SF Compact Text Search Highlight: #FE8019 Foreground Text: #EBDBB2 Background: #282828 Website: Weekly Tech bookmarks: funcmarks

Which browser for what link on macOS

It’s hard to split work and personal usage on the laptop at all. I would like to open work related web pages on Google Chrome, and all others go to Safari Before I have a Keyboard Maestro Marcos, I manually copy the address to clipboard and use hotkey to open it in the Google Chrome. However, this needs two more steps that are right-clicking or selection, and the hotkey. Then I find a few apps that can do the same with just clicking. You need to set the app as the default browser, and once you click the address, the app will help you forward to the specific app by the rule you set up. I also made a shortcuts on iOS that you can use share sheet or clipboard to open the address in Google Chrome iOS. Choosy The only one supports Google Chrome Profile so far. So if you have multiple profiles in Google Chrome, this is the only choice for you right now. Also, it has a similar popup browser selection like Bumpr. Bumpr The UI is the best, especially the popup browser selection, however, once you set up the rule, you could not edit it. Browser Opener Similar to Choosy, but not support Google Chrome Profile yet Finicky Very recently found this open source, you need to write a config file using JavaScript rather than GUI. However, there is a page finicky kickstart that helps you generate a basic config file. Also, There is one feature that you can edit the urls before opening.


Using Brewfile to automatic setup macOS from scratch

brew bundle The bundle is automatically installed once it is used. dump current apps to Brewfile brew bundle dump Import from Brewfile Run the cmd from the same folder of Brewfile brew bundle I would like to put it in my dotfiles. This one is mine

Move Hexo to Hugo

What is Hugo? Hugo is a static site generator written in Go. It is optimized for speed, easy use and configurability. Hugo takes a directory with content and templates and renders them into a full html website. Hugo makes use of markdown files with front matter for meta data. Hexo vs Hugo Hexo is also fast and simple, it is a static blog generator, and Hugo is more like for a site not only blog. Hexo is written in Node.js. Since I am a Golang developer now. I think it is good to move to Hugo. Prepare Hugo Check the Hugo official page Migrate to Hugo before you do it by yourself. Hugo has different content structure than Hexo. First of all, remove any unrelated files like themes, submodules, hexo config file… for removing submodules from # Remove the submodule entry from .git/config git submodule deinit -f path/to/submodule # Remove the submodule directory from the superproject's .git/modules directory rm -rf .git/modules/path/to/submodule # Remove the entry in .gitmodules and remove the submodule directory located at path/to/submodule git rm -f path/to/submodule Then, Install Hugo and run hugo new site --force in the current folder, it will generate the mandatory files for the site. Add theme you like and do configuration. Move all posts to the new content folder, I put mine into the content/posts. Update the front matter of the posts to avoid compile error in the Hugo. That’s almost done, it is easy because I moved my site from Jekyll to Hexo, then to Hugo, they all use markdown files and front matter for the post.


Alacritty font smooth on Mac

cg_context.set_allows_font_smoothing(false); cg_context.set_should_smooth_fonts(false); cg_context.set_allows_font_subpixel_quantization(false); cg_context.set_should_subpixel_quantize_fonts(false); cg_context.set_allows_font_subpixel_positioning(false); cg_context.set_should_subpixel_position_fonts(false); Change the value from true to false in font/src/darwin/, then build Alacritty The font is displaying much better on Mac OSX (at least for me) If you have not tried Alacritty + Tmux + vim(Neovim), you should do it. Here is a good article to talk about this set ‘Alacritty integration with Tmux’

Setup GPG for git on macOS

Install gnupg and pinentry-mac brew install gnupg brew install pinentry-mac Generating a GPG key Generating key gpg --full-generate-key Checking my key gpg --list-secret-keys --keyid-format LONG Copying key gpg --armor --export 3AA5C34371567BD2 | pbcopy Setting key for git git config --global user.signingkey 3AA5C34371567BD2 Full help Setting to load key nvim .gnupg/gpg-agent.conf pinentry-program /usr/local/bin/pinentry-mac Backup and restore gpg --export-secret-keys KEY_ID > my-private-key.asc gpg --import my-private-key.


iPhone X screen replacement

iPhone X screen replacement experience My iPhone screen was cracked by dropping on the floor. This is the first time since I started using iPhone from iPhone 4. And the experience is simple and good enough. Booked Apple genius with closet Apple store of my office on the second day. Be in the Apple store on the appointment time, and Waited around few mins. Show my iPhone X and run diagnostic to see if there are other issues on my iPhone. Good, all good except the screen. Ask me to disable Find my iPhone and turn off. Sign the repair form and leave Apple store. Received email to tell me my iPhone is ready in 1.5 hours. Back to Apple store, show my id and waited around 10 mins. Check the iPhone and pay. Leave the Apple store. The only point I hope they can do, It is better they can remind me to enable Find my iPhone when I picked up the iPhone.

Google Cloud Summit 2018 Sydney

Google Cloud Summit 2018 Sydney

Get basename of url by Golang

targetURL := "" u, err := url.Parse(targetURL) if err != nil { panic(err) } fmt.Println(path.Base(u.Path)) // three.json

Download a file from url in Golang

Example to download a file from url and save on local io.Copy() read 32kb (maximum) from input and write to output reapeatly, so dont need worry about memory. func DownloadFile(filepath string, url string) error { // Create the file out, err := os.Create(filepath) if err != nil { return err } defer out.Close() // Get the data resp, err := http.Get(url) if err != nil { return err } defer resp.Body.Close() // Write the body to file _, err = io.Copy(out, resp.Body) if err != nil { return err } return nil } reference: Code Example

Table driven tests in Golang

var fibTests = []struct { n int // input expected int // expected result }{ {1, 1}, {2, 1}, {3, 2}, {4, 3}, {5, 5}, {6, 8}, {7, 13}, } source: 5 simple tips and tricks for writing unit tests in #golang

Poker StraightFlush

First of all, PHP Code Example. (PHP ≥ 7) function isStriaghtFlush($d) { $b = $f = 0; $m = ['a'=>1,1=>10,'j'=>11,'q'=>12,'k'=>13]; foreach ($d as $a) { $p = substr($a,-1); $b |= 1<<(($m[$a[0]])??$a[0]); $f = ($f===0||$f===$p) ? $p : 1; } $b = ($b << 3) | ($b >> 10); foreach (range(0,13) as $i) { if ((($b >> $i) & 31) == 31){ return [true, $f!=1]; } } return [false, false]; } Explain: A can be straight of A, 2, 3, 4, 5 and 10, J, Q, K A There are total 14 ranks, when getting rank n from the $d, we set 1 of the n element in bitwise map. If we could find any 5 continuously 1 in the bitwise map, then it’s straight. also if all faces are same, then it’s straight flush. Example, cards: 10, J, Q, K, A read 10, bitwise map: 0,0,0,1,0,0,0,0,0,0,0,0,0,0 read J, bitwise map: 0,0,1,1,0,0,0,0,0,0,0,0,0,0 read Q, bitwise map: 0,1,1,1,0,0,0,0,0,0,0,0,0,0 read K, bitwise map: 1,1,1,1,0,0,0,0,0,0,0,0,0,0 read A, bitwise map: 1,1,1,1,0,0,0,0,0,0,0,0,1,0 shift left 3 of bitwise map to 1,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0 shift right 10 of bitwise map to 1,1,1,1 OR this two bitwise maps and get a new map 1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1 then we have 5 continuously 1, it’s straight.

MariaDB failed to start

Using Homebrew to install MariaDB, and got this eror when starting the server $ mysql.server start Starting MySQL .161227 19:05:10 mysqld_safe Logging to '/usr/local/var/mysql/xxx.err'. ERROR! Mostly it is caused by previous installation of MySQL. Manually remove /usr/local/var/mysql and reinstall MariaDB, it will start normally.

Homebrew Services Operation not permitted

You will get this kind of error message when you run brew services in tmux /usr/local/Cellar/something/homebrew.mxcl.something.plist: Operation not permitted How to fix it, just need install reattach-to-user-namespace brew install reattach-to-user-namespace

Date Range Overlap

Date Range Overlap Only 2 conditions that overlap does not exist |------ Date Range A ------| |------ Date Range B ------|  or |------ Date Range A ------| |------ Date Range B ------| That means start date A is later than end date B, or end data A is early than start date B. Overlap exists if neither of them is true. In rails we can create a scope to find all overlaps scope :overlaps, -\>(start_date_, end_date_) do where “((start_date \<= ?) and (end_date \>= ?))", end_date_, start_date_ end reference:

Ruby on Rails datepicker

Ruby on Rails datepicker Use bootstrap datepicker gem Gemfile: gem 'bootstrap-datepicker-rails' Add this line to app/assets/stylesheets/application.scss  *= require bootstrap-datepicker3 Add this line to app/assets/javascripts/application.js //= require bootstrap-datepicker Add this line to template <%= f.text_field :publish_at, "data-provide" => 'datepicker', "data-date-format" => "yyyy-mm-dd" %>

Archlinux in Virtualbox

Install Arch Linux in Virtualbox Pre-installation Partition the disks $ fdisk /dev/sda boot > n > return (default primary) > return (default partition 1) > return (default first sector) > +250M swap > n > return (default primary) > return (default partition 2) > return (default first sector) > +2G / > n > return (default primary) > return (default partition 3) > return (default first sector) > +2G > return /home > n > p (make primary) > return (default first sector) > return (default last sector) make /dev/sda1 bootable > a > 1 make /dev/sda1 to swap type partition > t > 2 > 82 write table to disk and exit fdisk > w Format the partitions format partitions $ mkfs.ext4 /dev/sda1 $ mkfs.ext4 /dev/sda3 $ mkfs.ext4 /dev/sda4 make swap $ mkswap /dev/sda2 mount swap $ swapon /dev/sda2 Mount the partitions $ mount /dev/sda3 /mnt $ cd /mnt $ mkdir boot home $ mount /dev/sda1 boot $ mount /dev/sda4 home $ cd / Installation Select the mirrors rankmirrors to make this faster (though it takes a while) mv /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.orig rankmirrors -n 6 /etc/pacman.d/mirrorlist.orig \>/etc/pacman.d/mirrorlist pacman -Syy Install the base packages # install base packages (take a coffee break if you have slow internet) pacstrap /mnt base base-devel Configure the system Generate an fstab file $ genfstab -p /mnt >> /mnt/etc/fstab Change root into the new system $ arch-chroot /mnt Set the hostname


Homestead provision

Laravel Homestead commands: Available commands: destroy Destroy the Homestead machine edit Edit the Homestead.yaml file halt Halt the Homestead machine help Displays help for a command init Create a stub Homestead.yaml file list Lists commands resume Resume the suspended Homestead machine run Run commands through the Homestead machine via SSH ssh Login to the Homestead machine via SSH status Get the status of the Homestead machine suspend Suspend the Homestead machine up Start the Homestead machine update Update the Homestead machine image There is missing provision command Solution is: list all vagrant instance $ vagrant global-status id name provider state directory ------------------------------------------------------------------------------------- 6e1aa44 default virtualbox poweroff /Users/[whoami]/.composer/vendor/laravel/homestead then run provision with id $ vagrant provision 6e1aa4

My Vagrant LAMP stack

I was using Vaprobash as basic starting Vagranfile which is working perfectly ‘post is here’. However, there are too many settings I will never use, I think it’s a better idea I make my own Vagranfile. I vagranted up a new empty box, and run each commands to setup my LAMP environment, and recorded each command to shell scripts, that make sure all commands are just what I need. Download my Vagrant LAMP: My Vagrant LAMP TODO: remote call shell scripts like Vaprobash use puppet might be better

Vagrant Move Project Directory

I started to move my development works on my local envirnoment setup to Vagrant. Since I like to reinstall my system once major update released like Mac OSX 10.9 to 10.10, this will save lots of time for me. And also, I watched this video Get Off MAMP on Laracast to push me move to Vagrant. Recently, I have moved one of my projects to a new directory, and it told me path is not correct once I vagrant up my project. Becuase I am using Vaprobash as basic start Vagrantfile, it is using NFS to sync folder between your local and box, which will modify /etc/exports. What I need to do after I move existing project to another directory, I just need modify /etc/exports and update the directory path to new one.

Install Mcrypt on Mac by Homebrew

Recently I setup Laravel enviroment on my Macbook, when I create project or run php artisan, it always prompts Mcrypt PHP extension required. error for me. Becuase I am using vagrant homestead for Laravel development, I can homestead ssh to run commands, but I think it’s better and convenience for me to install Mcrypt on my local enviroment. Then I did some reseach, and setup Mcrypt with mac native PHP. There are three ways I found: Manually complie Mcrypt source and install Using Homebrew to install Using MAMP Mcrypt For my requirement, I think homebrew is the best way for me. First Install autoconf which is needed when homebrew compling Mcrypt brew install autoconf Homebrew tap Homebrew dupes, versions, and homebrew-php tap brew tap homebrew/dupes brew tap homebrew/versions brew tap homebrew/homebrew-php Install php55 or php56 brew install php55 or brew install php56 PHP Mcrypt brew install php55-mcrypt or brew install php56-mcrypt Last add mcrypt extension into /etc/php.ini. You can find path using brew info php55-mcrypt, eg. extension= /usr/local/Cellar/php55-mcrypt/5.5.20/

Install Ghost with Nginx and MySQL

The steps I installed Ghost blog on Linode with Debian 7.5 Prepare apt-get update apt-get upgrade apt-get install -y build-essential Installing Nginx apt-get install nginx Install Node.js Based on here Setup with Debian (as root): curl -sL | sudo bash - Then install with Debian (as root): apt-get install -y nodejs nodejs-legacy Install MySQL apt-get install mysql-client mysql-server Secure MySQL mysql_secure_installation Restart MySQL /etc/init.d/mysql restart or service mysql restart Using MySQL mysql -u root -p to setup database: CREATE DATABASE YOUR_DATABASE; CREATE USER 'YOUR_USERNAME' IDENTIFIED BY 'YOUR_PASSWORD'; GRANT ALL PRIVILEGES ON YOUR_DATABASE.* TO 'YOUR_USERNAME'; exit Install Ghost Based on here created /var/www/ghost as ghost folder mkdir -p /var/www/ cd /var/www/ curl -L -o unzip -uo -d ghost cd /var/www/ghost Then setup ghost environment npm install --production npm install mysql npm install forever -g Setup Ghost Copy over the example config file and then edit it cp config.example.js config.js vim /var/www/ghost/config.js Change production default url to your domain and setup MySQL database url: 'http://YOUR_DOMAIN', database: { client: 'mysql', connection: { host: 'localhost', user: 'YOUR_USERNAME', password: 'YOUR_PASSWORD', database: 'YOUR_DATABASE', charset: 'utf8' } }, Run Ghost as background process Fix all permission chown -R www-data:www-data /var/www/ghost Then run ghost as background process by forever (you can find other deply methods in here) NODE_ENV=production forever start index.js Setup Nginx vim /etc/nginx/sites-available/ghost server { listen 80; server_name; location / { proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.


SSH Password for Windows Git bash

I think it’s more effective to use git cli than gui whatever which system you are using. For example, you need switch branch, it’s just one line in cli git checkout [branch] But (eg. windows) you need right click -> choose command -> click -> choose branch -> click It’s ok if you just do this few times. However, if you like me, going to 10+ repositories and switch to different branches everyday. Command line is your best friend to help you save your time. Terminal under Mac or *nix is native and easy to use. However, if you are using windows, after you install git, there is git bash to let you easy use git. Then there is a problem, each time you push, pull, or commit, it requests you to type your ssh password. What I did is every time when open a new terminal window, it will ask you your ssh password once, then whatever you do, it won’t ask you password again until you close this seesion window. Please find this file, if you could not find it, then create one. $HOME\\.bashrc In this file, add below’s code eval `ssh-agent` ssh-add Now every time, when you open a new git bash window, it will your password once, and you can run as many commands as you want without popup to ask your password again.

Keyboard Maestro as a replacement for TextExpander

Recently, I started to try Keyboard Maestro, and some people talked about it can be used as a replacement for TextExpander. Even I am not super fan of TextExpander, but I still use it sometimes. I decided to try it to see difference. Trigger Add a new trigger, select Typed String Trigger, then This string is typed. Type any short string as trigger, eg. I use gml (two spaces after gml). And other options which you can select as you like. Make sure you tick Simulaate x deletes before executing, otherwise the trigger phrase won’t be deleted before expansion is inserted. Actions There are only two actions. One is Insert Text, and another is Delete Past Clipboard Insert Text action, type the expansion into the textarea, and you also can use Insert Token to add variables of Keyboard Maestro given. Delete Past Clipboard action, change the value to 0(default is 1), because Insert Text action will paste the expansion to clipboard, and replace any previously copied.

Gmail Actions with Google Apps Script

Go to Google Apps Script and start a new blank project. {% gist 7799698 %} After you save script, run it and authorize the script to access your Gmail account, then add triggers to call script.

Git pull multiple repositories

for REPO in `ls`; do (cd "$REPO";git pull); done; update find . -mindepth 1 -maxdepth 1 -type d -print -exec git -C {} fetch \;


Let’s see what’s differences between JSON and JSONP first; //JSON {"name":"stackoverflow","id":5} //JSONP func({"name":"stackoverflow","id":5}); JSONP is the result that you can load the json as a script file. And it is usually used to allow for cross-site AJAX with JSON data. function func(json){ alert(; } var elm = document.createElement("script"); elm.setAttribute("type", "text/javascript"); elm.src = ""; document.body.appendChild(elm); Convert JSON to JSONP in PHP, JSONP will pass callback to script $json = json_encode($data); $jsonp_callback = isset($_GET['callback']) ? $_GET['callback'] : null; echo $jsonp_callback ? "$jsonp_callback($json)" : $json; Rerference: Stack Overflow

A Dark Room

Example of $this and self:: in PHP

Saw this good example from stackoverflow class Person { private $name; public function __construct($name) { $this->name = $name; } public function getName() { return $this->name; } public function getTitle() { return $this->getName()." the person"; } public function sayHello() { echo "Hello, I'm ".$this->getTitle()."<br/>"; } public function sayGoodbye() { echo "Goodbye from ".self::getTitle()."<br/>"; } } class Geek extends Person { public function __construct($name) { parent::__construct($name); } public function getTitle() { return $this->getName()." the geek"; } } $geekObj = new Geek("Ludwig"); $geekObj->sayHello(); $geekObj->sayGoodbye(); Output: Hello, I'm Ludwig the geek Goodbye from Ludwig the person $this will refer to current object(extended class), but self:: only refer to current class. If you want to refer to current object, you can use static:: (>= PHP5.3.0)

Hide Any File or Folder with Command

Mac only hide: chflags hidden /path/to/file-or-folder unhide: chflags nohidden /path/to/file-or-folder

Jekyll and Vagrant

Sometimes I want to run jekyll on office’s computer which is using windows. I dont want to spend too much time to setup ruby or compile setup on windows, or even install linux on office’s computer. Vagrant is a quick virtual machines to do the work! Follow the instruction on vagrant website, and vagrant init in your project folder. Then open Vagrantfile to configure Vagrant Vagrant.configure("2") do |config| = "precise32" :forwarded_port, guest: 4000, host: 4000 config.vm.provision :shell, :inline => "sudo apt-get update && sudo apt-get -y install build-essential ruby-compass && sudo /opt/vagrant_ruby/bin/gem install jekyll rdiscount --no-ri --no-rdoc" end Then you are ready to start VM $vagrant up $vagrant ssh $cd /vagrant $jekyll server After vagrant up successflly. You should be able to visit via http://localhost:4000 by your web browser.

500px Workflow for Alfred v2

Please register your own api key on 500px via here, and put Consumer Key after $api="" in workflow. For example, you want to save this photo with id: 27042559 on 500px to your local. Call Alfred, and type: 500px 27042559 It will download size 5 image into your desktop with name 27042559_5.jpg Download: 500px.workflow

Monday Calendar

Monday Calendar is a day based todo app which is similar with Teuxdeux, but it has better interface(at least for me), works on iPhone/iPad as well with browser, and more functions coming. Usually, I use Omnifocus as my project GTD app, and it is still the best GTD app for Mac, iPhone, and iPad. However, sometimes I just need a simple list app especially for my work. I tried Monday Calendar one day, and I feel this is what I am looking for. Simple, clearly, easy, and with elegant interface. It’s worth to try, and I think you will like it. Go website and request invite now.

Sublime Text 2 nil Theme

A nice Sublime Text 2 Theme And a good font: PragmataPro

Powder manages Pow

A good tools to manage Pow According to this post, if you dont need Pow and MAMP Pro together. You can use Powder to run powder down to disable pow first, then start MAMP Pro.

Running Pow And MAMP Pro Together

source: Running Pow with Apache I use both Pow for rails development and MAMP Pro for PHP development. I need them work simultaneously. Before start, if you have Pow installed, uninstall it with curl | sh Then let pow’s firewall run to redirect all traffic from port 88 instead of port 80 echo 'export POW_DST_PORT=88' >> ~/.powconfig Then you can install Pow as normal curl | sh Now, open MAMP Pro, create a new host. Doesn’t matter what it is named and which directory is selected (though I use ‘’ and the folder I keep my Rails apps in).Also, deselect the select box for “local name resolution”, just in case. Then go to the Advanced tab, and fill this in to the textarea labeled “Customized virtual host general settings”: ServerName pow ServerAlias *.dev ProxyPass / http://localhost:20559/ ProxyPassReverse / http://localhost:20559/ ProxyPreserveHost On

About Rails Depoly

This topic is about some general problems when I depoly rails app. After I set up server environment, I cloned source code by git. Usually, we need do some steps to make sure it works on production environment. gem we need install bundle install initial mongodb rake db:seed compile files we need for production rake assets:precompile --trace RAILS_ENV=production install javascript runtime sudo apt-get install nodejs or from package src apt-get install make python g++ mkdir ~/nodejs && cd $_ wget -N tar xzvf node-latest.tar.gz && cd \`ls -rd node-v*\` make install

Command to start Sublime Text on Ubuntu

There is a quick method to open Sublime Text from Terminal on Mac OS X. This is how to run Sublime Text on ubuntu terminal. Create command file: sudo vim /usr/local/bin/subl Copy & Paste below code, and change to your Sublime Text path #!/bin/sh $HOME/Apps/Sublime\ Text\ 2/sublime_text $1 & Give execute permission sudo chmod +x /usr/local/bin/subl Then you can do like this subl . or subl filename

Open Sublime Text 2 from Terminal Like TextMate

Updated@2012-06-26 23:00 +1000: It looks like sublime text 2 has official doc to support os x command line, I made it into /usr/local/bin/ ln -s "/Applications/Sublime Text" /usr/local/bin/ I used to run below command from terminal to open current projects in TextMate. mate . Now I am swiching to Sublime Text 2. Which is missing this. What I need to do just add below code into ~/.bash_profile alias sub='open -a "/Applications/Sublime Text"' Then I can open projects the same you would have in TextMate in Sublime Text but with the following command sub . That means you also can open any app from terminal, like when I want to edit markdown post in jekyll, or edit README file in my project from terminal by Byword: alias bw='open -a "/Applications/"'

Terminal Prompt for Mac OS X

I have re-installed my Macbook Pro with Mac OS X Lion. And I did another research to enhance terminal prompt to make it get better looking. What I need: seperate each command part show git branch colors You can get it from here

List no merged branches on git

We are using git-flow as git branching model to do development. However, there are more and more feautre branches were generated, and we need to make a list quickly for all branches to see which branch is still under development and not merged into master branch sometimes. Then this command will give a huge help. git branch --no-merged master And if add -a you can get all include remote branches.