Wednesday, November 28, 2012

ctrl+left/right arrow by inputrc

Suddenly my Ctrl+left arrow and Ctrl+right arrow stopped working for navigating word-by-word and it had become eally annoying. I still dont know the root cause. But I found following :

1. On your console, press Ctrl + v - Ctrl + RightArraow.  It should either print ^[0D or ^[[D.
2. Replace initial "^[" by "\e" and put it in ~/.inputrc as follows

  "\e[D": forward-word

3. Restart session or press Ctrl x - Ctrl r . Confirm binding by

  bind -P

Make sure your "env" has TERM=linux. (Putty -> Connection -> Data -> terminal-type string= linux)

Final ~/.inputrc should look like :

set meta-flag on
set input-meta on
set convert-meta off
set output-meta on
"\e[1~": beginning-of-line # Home key
"\e[4~": end-of-line # End key
"\e[5~": beginning-of-history # PageUp key
"\e[6~": end-of-history # PageDown key
"\e[3~": delete-char # Delete key
"\e[2~": quoted-insert # Insert key
"\eOD": backward-word # Ctrl + Left Arrow key
"\eOC": forward-word # Ctrl + Right Arrow key

Monday, October 15, 2012

Tabbed vim

I always felt like we should have tabs in vim so that I wont have to split screen using "vim -O option / ":vs". I just found that we can use tabs.

 vim -p < file1 > < file2 >

You can see that you can open multiple files and go to next file without saving (something you cannot do in multiple buffer). Youcan switch between files using tabn/tabp, but I do it as follows and use F5/6.

 :map <f5> :tabp <cr>
 :map <f6> :tabn <cr>

Thursday, May 10, 2012

Shell commands in VIM

If we need to execute a shell command on currently opened file in VIM, we can do following

  :%! sed G          Double space the entire file.
  :1,5! sed G        Double space the lines from 1-5.

Sunday, April 1, 2012

Downloading flash videos in ubuntu

Here is a modified version of a online script I found to download videos. Online script download everything which is a clutter because it has many flash ads too.

$ cat ~/Dropbox/new_installation/scripts/flash_vid.sh
#!/bin/bash
num=1;
for FILE in $(lsof -n | grep "Flash.*deleted" | awk '{printf "/proc/" $2 "/fd/"; sub(/[a-z]+/,"",$4); print $4}'); do
cp $FILE $HOME/Desktop/$num.flv
size=$( stat -c %s $HOME/Desktop/$num.flv);
if [ $size -gt 5000000 ]; then
num=$[$num + 1];
else
rm $HOME/Desktop/$num.flv;
fi
done

Thursday, March 15, 2012

CVS important commands

cvs add < filename >
cvs commit -m "my comment < filename >
cvs update < filename >

cvs -j < what version you want cvs to think it has > -j<what version you want cvs to go to > < filename >

Tuesday, March 13, 2012

linux commandline mail from shell as attachement

There are few ways to do this. Here are some :

(cat mailtext; uuencode surfing.jpeg surfing.jpeg) | mail sylvia@home.com
uuencode $ATTFILE $ATTFILE | mail -s "$SUBJECT" $MAILTO
echo "hi" | mutt -a $ATTFILE -s "$SUBJECT" $MAILTO