Monday, February 20, 2012

Improve productivity by tracking work environment with git - vim

In this post I try to describe my vim configuration procedure and how it is connected with git. The whole concept is based on keeping all the configuration files in a separate directory. These files are connected using symbolic links in places where system or application requires it (eg $HOME/.vimrc -> /home/jdoe/workspace/dotfiles/vimrc). So first let's create local directory for vim:
cd ~/workspace/dotfiles;mkdir vim

  1. Pathogen

  2. The first plugin that will be installed is pathogen created by tpope and accessible through github. Pathogen is a vim script to manage all vim plugins with ease. Below line add pathogen as submodule to our workspace repository created in previous post:
    git submodule add https://github.com/tpope/vim-pathogen.git dotfiles/vim/pathogen
    Initialise repository and update it:
    git submodule init && git submodule update
    Create additional directories need to complete pathogen installation, change directory to autoload:
    cd dotfiles/vim;mkdir {autoload,bundle};cd autoload
    In autoload directory pathogen should be installed, bundle directory is a place for all plugins installed in future. Finally we need to link vim script from pathogen submodule to current directory (dotfiles/vim/autoload):
    ln -s ../pathogen/autoload/pathogen.vim .
    Directory structure should look like below:
                    pietrushnic@eriador:~/workspace/dotfiles$ tree
                    .
                    └── vim
                        ├── autoload
                        │   └── pathogen.vim -> ../pathogen/autoload/pathogen.vim
                        ├── bundle
                        └── pathogen
                            ├── autoload
                            │   └── pathogen.vim
                            └── README.markdown
    
    At the end of pathogen installation few lines to $HOME/.vimrc should be added. Of course following rules about dotfiles management .vimrc should be created as separate file in ~/workspace/dotfiles and linked to $HOME/.vimrc.
    touch vimrc;ln -s $PWD/vimrc $HOME/.vimrc
    Add below lines to $HOME/.vimrc
     call pathogen#infect()
    call pathogen#runtime_append_all_bundles()
    call pathogen#helptags()
    syntax on
    filetype plugin indent on
    

  3. Fuzzyfinder
  4. This is second plugin without which I cannot work. It speeds up searching though files, directories and tags. Has multiple useful features. RTFM if you want knew them. I will be also added as a git submodule:
    git submodule add https://github.com/vim-scripts/FuzzyFinder.git dotfiles/vim/bundle/fuzzyfinder
    Additional plugin is needed to correctly install fuzzyfinder:
    git submodule add https://github.com/vim-scripts/L9.git dotfiles/vim/bundle/l9
    Initialize and update submodules:
    git submodule init && git submodule update
    Configuration I suggest to configure fuzzyfinder with accordance to example provided in help. 
    • Run vim and type :h fuf@en<Enter>. 
    • Choose tag fuf-vimrc-example and press Ctrl-]. 
    • Mark whole keybindings copy and paste to ~/.vimrc
Right now I think it is enough with vim configuration. Of course I use plenty of other plugins but I don't have to time to describe my them all (maybe in future posts). Don't forget to commit your changes, there could be a lot of them, however, to deal with the distribution of these changes and improve your skills try to use git add -p interface, suggesting after linux code style - each commit should contain separate logical part of the changes, personally I add prefix to my commits (eg . vim, git, etc.) to ease deal with git log.
Notes:
  • vim helpfiles generates tags files, which should be ignored by git, so I recommend to create .gitignore in every module with blow content:
  • .gitignore
    tags*
  • by default fuzzyfinder operate on unfriendly color palette espessicaly when using it through putty, highlighted pattern could be changed by added below lines to .vimrc (9 = black)
  • " fuzzy-finder - fix colors
    highlight PmenuSel ctermbg=9

Hostname generator

Many times happened that I spend time, during the installation of the new system, whether it be a virtual physical machine, wondering about it's hostname. One day I asked myself the trouble searching for host name generator. Best I could find (currently second in the results of google) is rospo.net. It gives you the choice of category for the host name. My favorite, as a fan of fantasy is "Characters from Tolkien". Although the category name does not reflect the truth, because in addition also includes a set of known sites in middlearth and more. So I recommend:

Sunday, February 19, 2012

Improve productivity by tracking work environment with git - preparation

Below is first post from series in which I want to describe my experience gained in attempt to enhance my productivity by using git to control the contents of some files in my home directory. The first step to improve the productivity is good organization of working environment. It happens very often that I work on multiple machines both physical and virtual. Therefore I need a good mechanism to share knowledge, experience, code, configuration and many other things. Configuration described below is only an example that actually fits my way of working.
First of all simple concept of directory structure is needed. Let's start with:
$HOME/workspace
        |- dotfiles
        |- blog
mkdir -p $HOME/workspace/blog;mkdir -p $HOME/workspace/dotfiles
cd workspace
Write some files (i.e. for your blog) with your favourite editor, initialize repository and prepare first commit
git init
git add .;git commit -m "Initial commit for environment tracking"
To avoid information about untracked vim swp files add $HOME/workspace/.gitignore with following content:
.gitignore
*.swp

Wednesday, February 15, 2012

Set irssi under debian to use freenode server

Very short manual on how to set up irssi to work with freenode servers.
Fist, install irssi:
sudo apt-get install irssi
Run:
irssi
For freenode write:
/connect holmes.freenode.net
Send register command for youe {nickname} and add information about your {e-mail}:
/msg nickserv register {nickname} {e-mail}
Copy and paste line, which you get from freenode registration server to your mailbox, to irssi. After that add freenode network:
/network add freenode
Add what should be automaticali send to server after connecting, remeber to correctly write your {nickname} and {password}, password will be stored in plain text:
/network add -autosendcmd '^nick {nickname};/msg nickserv identify {password}' freenode
Auto-connect everytime when irssi will be run:
/server ADD -auto -network freenode holmes.freenode.net 6667
Channel autologin:
/channel ADD -auto #debian freenode
After all we should save settings:
/save
That's all, enjoy!

Monday, February 6, 2012

arbtt as productivity improver for Linux enviroment

As I mentioned in previous post I work a lot on improving my productivity. After FreeMind it is time for arbtt. This is small tool which tracks active windows during your work. It is delivered with distro that I'm currently using (Debian wheezy). So all I had to do was:
sudo apt-get install arbtt
Below I try describe how I configure arbtt to work with some apps that I use (Google Chrome, FreeMind, gnome-terminal and screen).
To effectively work with arbtt I had to run a daemon that collects information. In this way, I found the first problem, namely, it is hard to find a website, which correctly explains how to execute command during startup on Debian with GNOME environment. After few tries I realize that I should focus on GNOME autostart mechanism. This led me to create little file in $HOME/.config/autostart which looks like that:
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=The Automatic Rule-Base Time Tracker
Exec=arbtt-capture
Terminal=false
So I had configured arbtt and it starts to capture data about my work. To display this data in friendly manner arbtt-stat should be used. Application complains if $HOME/.arbtt/categorize.cfg wasn't configured for it appropriate. Detailed documentation about this file can be found on arbtt configuration page. The process of writing this file should be iterative, starting point for me was:
-- This defines some aliases, to make the reports look nicer:
aliases (
        "sun-awt-X11-XFramePeer"        -> "java"
        )

-- A rule that probably everybody wants. Being inactive for over a minute
-- causes this sample to be ignored by default.
$idle > 60 ==> tag inactive,


current window $program == "sun-awt-X11-XFramePeer" &&
current window ($title =~ /(.+)\s-\sFreeMind/)
  ==> tag program:FreeMind-$1,

current window $program == "gnome-terminal" &&
current window ($title =~ /(.+)/)
   ==> tag term:$1,

-- Simple rule that just tags the current program
tag program:$current.program,

-- I'd like to know what web pages in google-chrome I'm working in. So I do
-- not tag necessarily by the active window title, but the title that contains
-- the specific string.
current window $program == "google-chrome" &&
any window ($program == "google-chrome" && $title =~ /(.+)\s-\sGoogle\sChrome/)
  ==> tag www:$1,
However, after creating a configuration file such statistics were displayed correctly it was still a big problem to solve - how to combine arbtt with gnome-terminal and screen. The first one requires only a correctly set the window's name. Although the synchronization of the terminal window's name with a window inside the screen was not a trivial task (primarily on the mass of broken tutorials that can be found on the web). Finally my .screenrc looks like that:
termcapinfo xterm* 'hs:ts=\E]0;:fs=\007:ds=\E]0;\007'
defhstatus "[screen] ^Et"
hardstatus off
# Set the scrollback length:
defscrollback 10000
    
# Select whether you want to see the copyright notice during startup:
startup_message off
# Display a caption string below, appearing like tabs and
# displaying the window number and application name (by default).
caption always
caption string "%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]"
#"%{= kb}[ %=%{w}%?%-Lw%?%{b}(%{W}%n*%f %t%?(%u)%?%{b})%{w}%?%+Lw%?%?%= %{b}][%{B} %H %{W}%l %{b}][%{B} %d.%m.%Y %{W}%0c %{b}]"
#"%{bw}[%H] [%?%-Lw%?%{wb}%n*%f%t%{bw}%?%+Lw%?]%=%{bw} [%1`] [%c:%s] [%l]"
# "%{kw}%-w%{wr}%n %t%{-}%+w"
defhstatus set terminal title and caption keeps data about my open windows in screen. Every time I open new window or change current one terminal title is updated.
For now that's all. In the future I wanted to write how to synchronize the title of the window in the screen with vim editor to include information about the currently edited file.

Sunday, February 5, 2012

First steps to improve work productivity in Linux environment

The problem encountered on several occasions over several months. Now it is time to deal with it. How did this happen? As always, resources were not sufficient, and if we can not increase the amount of resources we must strive to optimize their use.In this case, it was about time.


While reading my last acquisition, once again I faced the problem of re-configure Linux account. Every time when I need new account for some reasons I need to configure some things manually. Most things are simple enough, we copy configuration files from the already existing user directory, and voila. Of course Murphy's law works, and something goes wrong. Sometimes we need to create a new account with just a few of the tools configured as in other existing accounts. So we have a problem, however, reflecting on the solution, my mind was deepened in the increasing number of new issues, which caused the solution became more distant.


How this process looks like? First we need new account, it should get automatically some configuration files that I create for other accounts. Second I realize that I don't have methods for storing configs that I use most. I heard about dotfiles tracking with git with cloud help (e.g. github). When I google this issue I found dotty. But after that I ask myself about productivity improvements in broad sense and the conclusion was that my work scheme should be changed. So I try to find some hints about improving productivity, there are thousand of web pages about that. Few things I found useful first of all the idea of "automated time tracking". Second that chaos that I produced during solving simple problem meant that I thought about controlling of its flow, and this led me to mind mapping technique. AFAIK FreeMind is the best free software for playing with this way of data presentation. Below I attach my first mind map in FreeMind, this is of course beta version.