Showing posts with label Cygwin. Show all posts
Showing posts with label Cygwin. Show all posts

Get to Jira (or any web) quick from cygwin

1. Put the following in .bashrc:
export jira="https://jira.dovetail.net/browse/BUG-"
2. Make it effective:
source .bashrc
3. under /home/hliu/bin,  create file named as "jira":
cygstart "$jira$1"
4. Make it executable:
dos2unix jira
chmod 755 jira
5. Now from cygwin, you could type:

Find + Grep

find . -name "*Extent.java" -exec echo "{}," \; -exec grep " CLASSNAME" '{}' > output.xml \;

This is search all the files ends with "Extent.java", print the name, then grep the line which contains "ClASSNAME", then put everything into output.xml

snippet of output.xml

/advising/src/com/dovetailsys/advising/Q5CNPBankRestrictionExtent.java,
    public static final String CLASSNAME = "CNPBankRestriction";

Replace text in a lot of files

After I set up smbc-wl project on my eclipse, I have found that the CVS user name is actually Ian's user name. If you have the same problem, here is a quick solution to fix this:

First, we put the text that we want into a file called "bar".
Then we search all file named as "Root", and put the content of "bar" into it.

Change Cygwin ls colors

1. first, put the following lines in your .bashrc

alias ls='ls --color=auto -F --group-directories-first'
eval `dircolors -b /etc/DIR_COLORS`

2. edit /etc/DIR_COLORS`

Before I found that there are some directories always with green background, very annoying, take a good look, found the reason, I don't have enough permissions for these folders, so chmod 755 do it.

Use command's output as input

See, I want to use the output of pwd as input of cygpath, here is what I do

cygpath -w "`pwd`"

`` means executing pwd and get the result, "" will make sure we get the full path without worrying about blank. This command will show current path in windows format.

Where is color of ls command defined?

Where is color of ls command defined?

by NIXCRAFT · 5 COMMENTS

1) Configuration file for the ls color command is /etc/DIR_COLORS for Linux. You can modify those colours if you want.

2) Here is list of most common colors: (RHEL 3.x/FCx/RH and other linux distros)
Executable files: Green
* Normal file : Normal
* Directory: Blue
* Symbolic link : Cyan
* Pipe: Yellow
* Socket: Magenta
* Block device driver: Bold yellow foreground, with black background
* Character device driver: Bold yellow foreground, with black background
* Orphaned syminks : Blinking Bold white with red background
* Missing links ( - and the files they point to) : Blinking Bold white with red background
* Archives or compressed : Red (.tar, .gz, .zip, .rpm)
* Image files : Magenta (.jpg, gif, bmp, png, tif)

3) They are stored in special shell variable called LS_COLORS

4) You can customized them in /etc/DIR_COLORS or file pointed by shell variable COLORS.

5) To customized colors you must use special string combination:
FILE-TYPE Attribute codes: Text color codes:Background color codes

Where,

  • FILE-TYPE: is file type like DIR (for directories)
  • Attribute codes:
    • 00=none
    • 01=bold
    • 04=underscore
    • 05=blink
    • 07=reverse
    • 08=concealed
  • Text color codes:
    • 30=black
    • 31=red
    • 32=green
    • 33=yellow
    • 34=blue
    • 35=magenta
    • 36=cyan
    • 37=white
  • Background color codes:
    • 40=black
    • 41=red
    • 42=green
    • 43=yellow
    • 44=blue
    • 45=magenta
    • 46=cyan
    • 47=white

For example to define Bold Blue color for DIR file type, entry should look as follows:
DIR 01;34

6) Let us modify dir color on Red Hat (Fedora) Linux:

# vi /etc/DIR_COLORS

Modify DIR entry
From:

DIR 01;34 # default is Bold blue with black background

To:

DIR 01;34;41 # NEW default is Bold blue with RED background

Save file.

7) Logout and login again, Please note that if you have shell variable defined COLORS then use that file (use echo $COLORS to find it out).

todo.txt

This is todo tool for cygwin (not just for cygwin).

couple of things to set up:

export PATH=$PATH:"C:\cygwin\home\hliu\working_dir\todo.txt_cli-2.7"
chmod +x todo.sh
mv todo.cfg ~/.
(make some changes on todo.cfg, like define location of todo.txt and colors)
in .bashrc
alias t='todo.sh -d C:/cygwin/home/hliu/todo.cfg'

some commands
t add "go to drug store"
t do 1
t pri 1 A
t depri 1 A
t ls

Search in cygwin

Open in Windows (cygstart is doing the same thing)
Search File
credit to Rob


I made a little change to use TextPad as my editor.

now how to use this command:

cd $de_arc
u -f "*.xml" "DB" : this is to search the current directory for all *.xml file which contains "DB".

-d: directory
-e: editor, otherwise will search editors
-f: file name pattern
-s: case senstive
-h: help

u [-d] [-e] [-f] [regular expression or file path]

Open Windows Explorer in Cygwin

Robert on programming

put the script in a file called windows in /bin/
dos2unix windows
chmod 755 windows

that's it.


cygwin

export google=http://keyboardr.com/nightly/#home/
export blog=http://forevergarden17.blogspot.com

alias cs='cygstart'

then I could just type
cs $google
cs $blog

to go straight to my favorite page.

# Display the $PATH in a human acceptable way
function path()
{
old=$IFS
IFS=:
printf "%s\n" $PATH
IFS=$old
}

uname -srv: find the version of cygwin
man uname

dos2unix: if you edit a file in windows, then try to execute this file in cygwin, you will have problem, so should use dos2unix to fix it.

MS Dos warning in cygwin 7 fix:

Environment Variables (kinda awkward hidden button) -> Add a variable of CYGWIN with value of nodosfilewarning.

Unix Grep

grep "BusinessStatus" -B10 -A2 importList-Test.xml > output.xml

General meaning: get some stuff from importList-Test.xml, and put it into output.xml.

What stuff? lines which contain "BusinessStatus" + 10 lines before it + 2 lines after it.

This is very useful to extract certain patterned-contents from a large file.

find . -name "*Bean.java" -exec echo "==={}:" \; -exec grep "re\"DefaultDataSource\"" -B1 -A3 {} \;

find . -name "*Extent.java" -exec grep "CLASSNAME =" '{}' > output.xml \;