Carl’s excellent post describes how to set up Screen with ssh-agent so that when a new screen session is started, windows with names were set up and logged onto different servers automatically. It was not clear how to create the configuration file .screenrc_escP to me initially, but after a bit of trying the following steps worked:
open ~/.screenrc_escP in vi
type string “escape”
press tab key
press ctrl-v: holding the control key press the v key
press ctrl-p: holding the control key press the p key
type character p
In my terminal window character ctrl-p is in bold:
The escape sequence for the outer screen is ctrl-p instead of ctrl-a– to see the windows created in the outer screen type ctrl-p + ” — holding the control key press p, release the control key, press double quotes:
I use ctrl-p at bash prompt to go to the previous command, so I chose ctrl-y as my escape character for the outer screen. After setting up config files and ssh-agent, starting a screen session created different windows and ssh connections opened to different servers.
I often backup a file by adding time stamp to the file using command like the one below:
mv catalina.out catalina.out.`date +%F-%I%M%p`
Date command “date +%F-%I%M%p” generates time stamp in the format YYYY-MM-DD-HHMM(AM/PM) (e.g. 2011-01-06-0729PM). Instead of typing the full date command, function keys F1, F2, etc. (not sure what other keys can be programmed) can be set to print it on command line when pressed. This post describes how to program F2 key so that when pressed:
deletes a character (backspace)
Tab completion adds a space after the filename. This is to delete the space character.
prints .`date +%F-%I%M%p` on the command line
Open file “.inputrc” in user home directory (vi ~/.inputrc)
Type the following characters (without + sign and spaces): ” + ctrl-v + F2″
while holding the control key press v (similar to holding shift key to type letters in caps)
Type the following characters (without + sign and spaces): ” + ctrl-v + ctrl-h + .`date +%F-%I%M%p` + ”
while holding the control key press v
while holding the control key press h — ctrl-h is for deleting a character (ctrl-h works at command prompt also)
The lines should now appear as in the picture below:
Open a new bash shell and pressing F2 should now output .`date +%F-%I%M%p`
Below are a few aliases that I use almost everyday at work:
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../../..'
alias .....='cd ../../../../..'
With these aliases in place, use “..” to navigate one-level up, “…” to navigate two-levels up, etc.
Navigating to project related directories
alias cdtomcat='cd "/cygdrive/c/appservers/tomcat"'
alias cdlogs='cd "/cygdrive/c/appservers/tomcat/logs"'
alias cdws='cd "/cygdrive/c/satish/eclipse/workspace"'
To navigate to Tomcat logs directory, type “cdlogs” at the command prompt; To navigate to project workspace, type “cdws”. You get the idea, right?
Converting cygwin directory in to windows format
alias cpwd='echo $PWD | sed -e "s/\/cygdrive\/c/c:/g" | sed -e "s/\//\\\/g"'
Look at the screenshot below to get an idea
Open windows explorer
alias winexp='explorer.exe `cpwd`'
typing “winexp” at the command prompt will open windows explorer in the current working directory — this alias uses cpwd alias set up above
The cd command in cygwin takes directory that is in cygwin path format. For example, to navigate to C:\Satish\Software, the command is “cd /cygdrive/c/Satish/Software”. Below is a tiny function that changes to a directory given path in windows format (e.g. c:\Satish\Software)
dir=`echo "$1" | sed -e 's/\\\\/\\//g'`
Command wincd “C:\Satish\Software” changes the working directory to /cygdrive/c/Satish/Software — note that double quotes around the path are required. See picture below: