Work Productivity

Create an alias in Windows

Recently, I wanted to create shortcuts for git commands. I can have written aliases inside the git config file, but then also, I had to type git explicitly. So, I just searched the internet and came across this link: http://superuser.com/questions/49170/create-an-alias-in-windows-xp.

How can I make bash my login shell?

Every time, I do SSH to my Linux box, the default shell comes as: csh, but I want to, use the bash shell automatically from PuTTY. For making bash as the default login shell, first we need to find out, the path of the bash shell, by using:

which bash

If your login shell is csh or tcsh, and you have installed bash in /bin/bash then create a ~/.login file and add the following line:

Passwordless SSH Using Key Based Authentication with Putty

SSH (Secure Shell) is a protocol for connecting two computers securely. It provides secure authentication as well as encryption. If you use Linux, most distros have ssh installed by default.

You can log to a Linux machine using SSH protocol from a putty client by entering the username and password. But if, both the machines are yours only, and no one else uses those machines, it makes a hindrance to enter the username and password, every time you do SSH to that server.

Move cursor by display lines when wrapping in vi

You can move your cursor by display lines when wrapping in vi, instead of jumping to the next line. This can be really helpful, when you have long wrapped lines, and you want to move in between them.

Just edit the .vimrc file.

vi ~/.vimrc

and insert the following text into that:

nnoremap <up> gk
nnoremap <down> gj
inoremap <up> <C-o>gk
inoremap <down> <C-o>gj

Show line numbers in vi or vim

Displaying line numbers while editing a file can be handy. Using line numbers you can directly jump to a particular line. You can set the line numbers in vi using the following commands:

:set number

If you want to turn off the line numbers in vi, use the following command:

:set nonumber

You can also insert the following text into the .vimrc file, and can switch on or off the line numbers, by pressing the F6 and F7 keys respectively.

Using FTP Batch Scripts on Windows

The Microsoft KB article 96269 shows you how to use the ftp program that comes with all versions of windows to automate file transfer. You can use the -s option for passing FTP script to the program.

Shell script to download file using ftp

#!/bin/sh

# ftpget - given an ftp: style URL, unwrap it, and try to obtain the file using ftp.

if [ $# -ne 2 ] && [ $# -ne 3 ]; then
  echo "Usage: $0 ftp://... username [password]" >&2
  exit 1
fi

# Typical URL: ftp://ftp.ncftp.com/2.7.1/ncftpd-2.7.1.tar.gz

if [ "$(echo $1 | cut -c1-6)" != "ftp://" ] ; then
  echo "$0: Malformed url.

VLC: How to play videos at a faster rate?

In this video, we will see how to play video files at a faster rate using VLC, yet maintaining the audio clarity. This could help you to play video lectures downloaded from YouTube or other video sharing websites, at a faster rate, while maintaining the audio clarity for understanding and synchronize audio with the video. This would enable you to go through a one hour lecture in about half an hour.

How to add "Command Prompt Here" to Nautilus/Gnome?

Command Prompt Here: Windows developers are familiar with the tiny utility "Command Prompt Here" which allows them to open the command prompt from the windows explorer, with the working directory set to the current directory selected in the windows explorer.

Run Commands Effectively in Linux

There are various ways to launch applications and run commands in Linux. Which method is best is a matter of personal taste and individual productivity needs. Here I will discuss some of the best methods available in Linux to do the common quotidian tasks easier and faster.

Command Prompt

The basic method of running commands is through the gnome-terminal, i.e. the command prompt in the Windows language. To run gnome-terminal, just press ALT+F2, type "gnome-terminal" and press the enter key.