Posts Tagged ‘bash

11
Dec
14

Opening a cmd window in the current working directory from cygwin

With the newer version of cygwin I am running, there are a few flaws. These mainly have to do with how it interacts with printing and user input from windows executables.

e.g.

  • The windows python prompt doesn’t display. See here for more details.
  • Using mercurial, it can’t prompt me for a password. It comes up as abort: http authorization required

There are a few little niggly things like this which makes it handy to have the windows console available at your fingertips. You can launch cmd.exe from within cygwin, but that doesn’t solve the problem as you are still using the same input/output from the terminal. So I wrote a very simple script which will launch cmd in the current working directory.

Here it is:

#!/bin/sh
# Written by: DGC

#==============================================================================
usage() {
  cat <<EOF
Usage: $(basename $0) <options>;

Opens a windows command window in the current working directory.

Options:
-h                 Display this message.
EOF
  exit
}

#==============================================================================
# Main
while getopts ":h?" option
do
  case $option in
    h)
      usage
      ;;
    \?)
      echo -e "Invalid option: -$OPTARG \n"
      usage
      ;;
  esac
done

cygstart 'C:\Windows\System32\cmd.exe'

This is slightly overkill for essentially just cygstart 'C:\Windows\System32\cmd.exe', but I like to include a help with all my scripts.

It was helpful to me, so I thought I’d share it.




Call Me
Endorse davidcorne on Coderwall

Categories

Copyright


© 2013 by David Corne.

Creative Commons License

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.