Tuesday 18 November 2014

Edit bashrc, vimrc, tmux.conf and zshrc from vim

I have found that I am playing a lot with vim, tmux, zsh and bash, and I needed a fast way to edit this files as well as source them (reload them). So I added the following lines to vimrc:

let mapleader = " "
nmap ev :e $MYVIMRC             " edit vimrc
nmap sv :so $MYVIMRC           " source vimrc
nmap eb :e ~/.bashrc               " edit bashrc
nmap sb :! source ~/.bashrc   " source bashrc
nmap ez :e ~/.zshrc                  " edit zshrc
nmap et :e ~/.tmux.conf          " edit tmux
nmap st :!tmux source-file ~/.tmux.conf  " source tmux


Leader key is but it can be configured to any key. So, for example, to edit tmux config file I press et. To source it, I press st. Simple as that. I save a lot of time when fiddling and testing new ideas in these configuration files.

Auto install Pathogen (Vundle) plugin from .vimrc

The Pathogen (formerly knows as Vundle) plugin for vim is an extremely useful plugin manager. It can automatically download other plugins from github (and other locations). One downside is that Pathogen must be manually downloaded and copied in the correct folder. However, I added the following lines in .vimrc to check if Pathogen is already installed on the system, and if not, to download it.

let vundleInstalled=0
let vundle_readme=expand('~/.vim/bundle/vundle/README.md')
if !filereadable(vundle_readme)
     silent !mkdir -p ~/.vim/bundle/
     silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle
     let vundleInstalled=1
endif
filetype off
set rtp+=~/.vim/bundle/vundle
call vundle#rc()
...
if vundleInstalled == 1
     :PluginInstall
endif


I have my .vimrc on github and whenever I move to a new system I simply copy the file in my home folder. The first time I run vim, it will read .vimrc and will install Pathogen alongside with all the other plugins specified.

Tmux and Terminator key bindings

Tmux and Terminator key bindings

I have discovered Terminator before I learned about Tmux, and I must say that the feature of dividing a terminal was mind blowing. Afterwards I discovered that, unfortunately, Terminator only works in X server, so I found tmux, which also works in the absence of an X server. The problem then was that I would have 2 multiplexing applications, each with different key bindings. So, below is my setup to use similar key bindings.

TmuxTerminator
Vertical splitCtrl a vCtrl-Alt v
Horizontal splitCtrl a hCtrl-Alt h
Next paneCtrl a aCtrl-Alt a
New window/tabCtrl a wCtrl-Alt w
Switch window/pane*Ctrl a xCtrl-Alt x

Tmux uses windows and panes, while Terminator is using tabs and windows. It can be quite confusing in this regard, as the window from one application has a different meaning in the other.
The key bindings are easy to remember and intuitive.

Note: x represents a number from 0 to 9


Wednesday 16 May 2012

Windows 8 Development: Adding shortcuts in Metro (Day2)

Windows 8 Development: Installing Win8 (Day1)

There are 2 ways to install Windows8 on a machine: either as a virtual machine, or as the base OS. Either way, you need to get the Win8 iso image, which can be found here. At this moment (15.05.2012) only the Consumer Preview version is available, and the serial key can be found on the same page.

To install Win8 as a virtual machine I followed the steps (in VMWare Player):
File -> Create New Virtual Machine -> Select "Installer Disc Image file (iso)" and point to the location of the Win8 iso file -> Guest Operating System: Microsoft Windows and Version: Windows 8 -> Virtual Machine Name: Windows 8 -> Finish

To install Win8 as the base OS, you need to mount the iso as a DVD (use Alcohol 120%) and run the Setup.

Note: you can install Win8 on top of Win7 while preserving all the Programs Files and Documents you previously had. Win8 does NOT require formatting of the disk. However, it will complain if there is less than 16GB space on the destination partition. However, it will need only 9GB. The total duration of installing is around 2 hours.

Wednesday 25 March 2009

Installing ERD Commander 2005 on USB

(This method of installing is not my creation but it comes from a brilliant mind whose identity was lost after many generations)

WinInternals developed ERD Commander, before it was bought by Microsoft and made the tool part of Microsoft Diagnostics and Recovery Toolkit. ERD (Emergency Repair Disk) is very useful when the system won't boot into Windows, even in safe mode. It allows access to low level diagnostics and repair tools like crash analysis, file recovery, password remover, Windows restore points and hotfix uninstall.





Tools
USB pen drive - at least 1 GB
PE2USB - can be downloaded from here
ERD Commander 2005 - it is no longer supported but you can find it on torrents

Steps
1. Extract the files from the ISO or RAR containing ERD Commander into a directory
2. Start PE2USB
 - At "Destination Drive" select "Removable". Select the thumb drive from the drop down list.
 - Then check "Enable Disk Format". You should back-up your USB drive because formating it will delete everything.
 - At the "Source path" select the files containing the ERD Commander files extracted at step 1.
 - Also check "Enable Fily Copy" with the option "Overwrite Always".
 - Hit Start and now wait.
3. Now you should have a bootable USB with ERD Commander 2005.
4. Reboot the system, and check in BIOS to have the USB as the first option in the boot device  order.


Resources