Posts Tagged ‘tips’


Find and replace in all the files

In howto on Nov 17, 2016 by theoryl Tagged: , ,

This simple one liner does it:

find ./ -type f -exec sed -i -e 's/apple/orange/g' {} \;

from StackOverflow


Parallelize using xargs

In howto on Sep 7, 2016 by theoryl Tagged: , , , ,

According to this answer on StackOverflow: , you can easily parallelize tasks using xargs. To quote the given example:

$ find . -type f -name '*.wav' -print0 | xargs -0 -P 3 -n 1 flac -V8

This example will encode *.wav => *.flac, using three processes at once (-P 3).


Remove sub directory from Git sparse checkout

In howto on Aug 28, 2014 by theoryl Tagged: , ,

If you have configured Git to use sparse checkout to checkout a sub directory, but later decided that you don’t really need that sub directory, here’s what to do:

1. first delete the sub directory
2. open .git/info/sparse-checkout , delete the sub directory name in the list
3. git read-tree -mu HEAD

If you don’t do this, Git will stage the deletion of the sub directory for the next commit.


Git aliases

In shared on Jan 17, 2014 by theoryl Tagged: , ,

Some useful Git aliases

name = ...
email = ...
github = ...

a = add
ap = add --patch
am = am -s
c = commit
cs = commit -s
ca = commit --amend
co = checkout
b = branch -vv
l = log --graph --all --abbrev-commit --date=relative --format=format:'%C(bold blue)%h%C(reset) %C(green)%ar %C(yellow)%an%C(bold yellow)%d%C(reset)%n %C(white)%s%n'
lt = log --graph --abbrev-commit --date=relative --format=format:'%C(bold blue)%h%C(reset) %C(green)%ar %C(yellow)%an%C(bold yellow)%d%C(reset)%n %C(white)%s%n'
ll = log --graph --abbrev-commit --date=relative --format=format:'%C(bold blue)%h%C(reset) %C(green)%ar %C(yellow)%an%C(bold yellow)%d%C(reset)%n %C(white)%s%n' -10 HEAD~6..HEAD
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%Creset' --abbrev-commit --date=relative
lf = log --pretty=fuller
ls = log --pretty=fuller --stat
s = status
d = diff
ds = diff --stat
dc = diff --cached
dcs = diff --cached --stat
dp = show
dhh = diff HEAD^!
dhhs = diff HEAD^! --stat
doh = diff origin/master HEAD
dohs = diff origin/master HEAD --stat
rb = rebase
rbi = rebase -i
rbio = rebase -i origin/master
t = tag -a
tl = tag -ln1

editor = vim

# default = simple

ui = auto


Find DOS format text files

In howto on Nov 6, 2013 by theoryl Tagged: ,

From :

grep -lUP '\r$' *


Disable mate-keyring-daemon

In howto on Sep 29, 2013 by theoryl Tagged: ,

Everytime I try to connect to GitHub via ssh, Linux Mint makes a pop up window asking for my password. It is really annoying. I prefer to use the tried and true ssh-agent instead.

To kill the keyring daemon:

# find out the PID
ps ax | grep mate-keyring-daemon  
kill -9 <PID>

To disable the keyring daemon from next startup: go to Preferences -> Startup Applications. Uncheck SSH Key Agent.


Geany search highlight

In howto on Aug 29, 2013 by theoryl Tagged: , ,

The translucency setting of Geany search highlight makes it difficult to see the matches when using a color scheme with white background (e.g. Github color scheme). Unfortunately the translucency setting cannot be changed (see This is an issue for me. So I decided to change the search highlight color to be close to the color used for text highlighting on Github:


and the search markers are more visible now.

I also decided to tweak the primary and secondary keywords in filetypes.cpp, so that secondary keywords consist of C/C++ types:

primary=alignas alignof auto and and_eq asm bitand bitor break case catch class compl const_cast constexpr continue decltype default delete do dynamic_cast else enum explicit export extern false final for friend goto if inline mutable namespace new noexcept noreturn not not_eq nullptr operator or or_eq override private protected public register reinterpret_cast restrict return sizeof static static_assert static_cast struct switch template thread_local this throw true try typedef typeid typename union using virtual volatile while xor xor_eq
secondary=bool char char16_t char32_t const double float int int8_t int16_t int32_t int64_t long ptrdiff_t short signed size_t ssize_t unsigned void wchar_t

p/s: The color scheme file is located at ~/.config/geany/colorschemes/github.conf; the typedef file is located at ~/.config/geany/filedefs/filetypes.cpp