selfjungle Just another WordPress weblog

25Oct/130

git auto-completion

wget https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -O ~/.git-completion.bash
source ~/.git-completion.bash
Tagged as: , No Comments
18Oct/130

pushing to a non-bare git repo

Init a directory as a bare repo in the first place:

git init . # non-bare
git init -bare . # bare

To be able to push into a non-bare repo, just check out a branch users don't push to:

git checkout -b DUMMY_BRANCH_DONT_USE

Or turn it into a bare repo:

rm *
mv .git/* .
rm .git
sed -i 's/bare = false/bare = true/' config

Source: gitolite

Tagged as: No Comments
15Oct/130

print range of lines of a file

Print from line N..M from FILE:

sed -n N,Mp FILE
Tagged as: No Comments
15Oct/130

what files does your executable open

strace -e trace=open EXECUTABLE
26Sep/130

git ignoring changes

Ignoring files in repository:

edit .gitignore
git update-index --[no-]assume-unchanged FILE # if rule was added after the tracked file

Ignoring files in all repositories on your computer:

edit ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global

Ignoring local per-repository files:

edit .git/info/exclude

Source: github help

Tagged as: No Comments
22Feb/130

bash basics

Executing programs in parallel:

p1 ; p2 ; p3 ; ...

Note: use wait if inside a script, so it waits for each child to finish.

Executing programs sequentially:

p1 ; p2 ; p3 ; ...

Executing programs sequentially, stop if one fails:

p1 && p2 && p3 && ...
Tagged as: No Comments
6Dec/110

bash case-insensitive filename tab-competion

Edit /etc/inputrc:

add this line:

set completion-ignore-case on
Tagged as: No Comments
5Dec/110

shortcuts to find and grep

Writing these 2 line way too much a day.

Edit ~.bashrc:

function gr {
grep -Hrni $1 *
}

function f {
find . -iname *$1* | grep -i $1
}
Tagged as: No Comments
18Nov/110

colorful man pages

Edit ~./Xdefaults:

*VT100*colorULMode: on
*VT100*colorUL: yellow
!*VT100*italicULMode: on
*VT100*underLine: off
! Uncomment this to use color for the bold attribute
*VT100*colorBDMode: on
*VT100*colorBD: cyan
Tagged as: No Comments
18Oct/110

merge two pdf documents

I had to sign a document, which was basically:

  1. Print the last, 5th page of the pdf.
  2. Sign the sheet.
  3. Scan it as a one-paged pdf.
  4. Change the 5th page from the pdf with the new one.

Again, the solution was pdfjam, which did the job of merging the first 4 page of the original document with the new pdf.

pdfjam original.pdf '1-4'  new.pdf '-' --outfile merged.pdf

I found nice pdfjam examples at the The Bit Brothers.

Tagged as: No Comments