Wednesday, July 31, 2013

Ubuntu 14.04: configure dev env right after install


I hate some Ubuntu Unity (and, sure, Windows 8) UI 'innovations'.
Wishing best for programmers who write such unusable UI, but always configuring Ubuntu UI to be more usable (without using Compiz as it as a double trouble for all Ubuntu users). Here are my favourite kinds of such improvements:

1. Move all window controls (minimize,maximize,close) to the right:

gsettings set org.gnome.desktop.wm.preferences button-layout ":minimize,maximize,close"

2. Disable Unity global menu.

I didn`t found any option to make Unity global menu to stay visible
without mouse hovering on it. So, my suggestion is to disable Unity global menu and use more default and habitual menus location.

sudo apt-get remove indicator-appmenu

This will disable global menu for all apps except Firefox (Usually I don`t disable global menu for Firefox, but you can do this using this StackOverflow answer).

3. Add some app shortcuts (launchers) to Ubuntu desktop:

In previous Ubuntu versions user was able to add shortcuts to Desktop using built-in 'gnome-panel' application. But 'gnome-panel' package was excluded from default Ubuntu packages list for some weird reason.

So, we should to install it manually and call from terminal every time we need to create a new Desktop shortcut:

sudo apt-get install gnome-panel
gnome-desktop-item-edit ~/Desktop/ --create-new

But: be careful with icon sizes for you shortcuts. If you will use 512x512 or greater icon to your shortcut, it will be displayed as real-size, without fit.

4. Add 'open in terminal' option to folder context menus by installing 'nautilus-open-terminal' package (it works perfectly with Ubuntu 8 and higher, not only in 12.04 / 12.10).

sudo apt-get install nautilus-open-terminal

5 [optional] install some common dev tools:

        sudo apt-get install skype htop iotop mtr geany python python-pip awscli meld ssh wget curl openvpn network-manager-openvpn git gitk jq expect vagrant virtualbox virtualbox-dkms ec2-api-tools unzip
        sudo pip install ansible==1.9.4 boto keyring keyrings.alt
      
6 [optional] setup git aliases:

git config --global alias.br branch
git config --global alias.sts "status -sb"
git config --global alias.sts "diff --name-status -r"
git config --global alias.st "status"
git config --global alias.who "shortlog -s --"
git config --global alias.l "log --graph --pretty=format:'%Cred%h%Creset %C(bold blue)<%an>%Creset%C(yellow)%d%Creset %s %Cgreen(%cr)' --abbrev-commit --date=relative"
git config --global alias.g "grep --break --heading --line-number"
git config --global alias.c "commit" 
git config --global alias.cia "commit --amend"


Thursday, July 4, 2013

Search through the GIT history like a ninja

To search for regexp through the whole GIT history you should to execute:

git grep <regexp> $(git rev-list --all)

 This will grep through all your commit text for regexp.

Here are some other useful ways of searching your source:

- Search working tree for text matching regular expression regexp:

git grep <regexp>

- Search working tree for lines of text matching regular expression regexp1 or regexp2:

git grep -e <regexp1> [--or] -e <regexp2>

- Search working tree for lines of text matching regular expression regexp1 and regexp2, reporting file paths only:

git grep -e <regexp1> --and -e <regexp2>

-Search working tree for files that have lines of text matching regular expression regexp1 and lines of text matching regular expression regexp2:

git grep -l --all-match -e <regexp1> -e <regexp2>

-Search all revisions for text matching regular expression regexp:

git grep <regexp> $(git rev-list --all)


-Search all revisions between rev1 and rev2 for text matching regular expression regexp:

git grep <regexp> $(git rev-list <rev1>..<rev2>)

If you have a git l alias to pretty log output, you can run this to search for commits whose changes include your regexp:

git l -G <regexp>