Thursday, January 27, 2011

Git Remote Branch Tracking

當local產生了一個temporary branch
但是過一會又想要push會remote的時候
(也就是當初在create branch的時候沒有設tracking..)
從git 1.7之後就有個新的指令(感謝小白~)


$ git branch --set-upstream [branch_name] origin/[branch_name]


設定完之後就可以隨便push/pull了啦!!

Autojump with Profile Switch

當autojump用到走火入魔的地步的時候...你就會需要profile switch了!
也就是說我希望在不同的情況下, 某一個keyword會到不同的目錄!!
以下簡單的script請自行服用~~


#!/bin/bash
if [ "$#" -gt "0" ]; then
if [ -d ~/.local/share/autojump_$1 ]; then
rm -fr ~/.local/share/autojump
ln -s ~/.local/share/autojump_$1 ~/.local/share/autojump
echo "changed autojump profile to \"$1\""
else
read -N 1 -p "profile \"$1\" does not exist, create it? (y/n)"
if [ "$REPLY" == "y" ]; then
mkdir ~/.local/share/autojump_$1
rm -fr ~/.local/share/autojump
ln -s ~/.local/share/autojump_$1 ~/.local/share/autojump
echo -e "\nchanged autojump profile to \"$1\""
else
echo -e ""
fi
fi
else
echo "Usage: ajcp [profile_name]"
echo ""
echo "Change to given autojump profile."
fi