How to capture a window using the command line - osx-lion

The screencapture command doesn't seem to be able to capture a specific window when it is invoked from the command line, but is able to do it when it is used interactively whit shift+command+4.
How can I capture a window from a script ?

screencapture -w yourfile.png
However the window selection itself is still interactive.

$ screencapture -l #windowId capture.png

Related

How to set shell-mode prompt in emacs?

I have set in my ~/.emacs.d/init_bash.sh:
export PS1='\h:\w$ '
without it, my prompt is
bash-3.2$
but now it is
bash-3.2$ computername:~/path/to/directory$
How do I make it just be
computername:~/path/to/directory$
?
It seems to just do this on the first line in the Emacs shell, and "bash-3.2$" goes away after I hit return once. To really get rid of "bash-3.2$", set PS1 in your ~/.bashrc instead.

How to use inkscape command line interface?

I'm trying to use the inkscape command line interface. I have windows 7.
First I open up command line, and I run these:
cd "C:\Program Files\Inkscape-0.48"
inkscape "C:\Users\me\Desktop\Pic\Class_UML.png" --export-png="C:\Users\me\Desktop\Pic\raster.png" --export-area=0:0:100:100
Then the inkscape popup opens, and I click embed, and then click ok, and then nothing happens, and the file doesn't show up.
Does anyone know what I am doing wrong?
Thanks
As of now, there doesn't seem to be a way to do perfect silent processing in Windows. However, any command using inkscape in Windows triggers an empty window while processing in background.
If you don't want it to open separate inkscape windows everytime, try entering the inkscape interactive shell (using inkscape --shell).
PS: I don't think we can do anything more in interactive shell, more than what we can do using cmd. Hopefully someone solves the aforementioned problem in Windows and adds more functionality inside shell.
Have you tried to open the file C:\Users\me\Desktop\Pic\raster.png and see how it looks like?
Supposedly by using --export-png in the command line, inkscape will not open the interface but simply process what you requested silently.
In this case you should have the cropped image should be saved in C:\Users\me\Desktop\Pic\raster.png.
I use Linux and tried your example to test and I get the same behaviour you described plus the response in the command line
Background RRGGBBAA: ffffff00
Area 0:0:100:100 exported to 100 x 100 pixels (90 dpi)
Bitmap saved as: raster.png
Hope it helps
On Windows, in the C:\Program Files\Inkscape\bin folder, you will see both inkscape.exe and inkscape.com. Use inkscape.com.
Here is an example from PowerShell:
> & "C:\Program Files\Inkscape\bin\inkscape.com" --help
#echo off
REM setup Inskcape File Location
cd /d "C:\Program Files\Inkscape"
inkscape path\filename.svg --export-dpi=120 -e exported_image_name.png --without-gui

prints in an another window in cmd and close quickley

I am trying to run a Perl script from command prompt.
The script contains one line:
print "Hello World!\n"
I type in the cmd: Perl hello.pl
The line is printed in a new window and quickly is closed.
It's all happening in the cmd! Does anyone had this kind of problem?
I know Perl is working because I tried to run a script that creates an excel file and it worked.
The only problem is, that it doesn't print in the same window as it is supposed to do, but opens a new window, prints there and closes it. (I tried to do a while loop in the end and it didn't help).
I was able to solve this.
In windows there is an option called "Open command prompt as Administrator". A new window does not open up in that case.
The cmd window closes as soon as the command that it runs has exited. You can either
… start a cmd.exe of your own, and launch your script via
> perl C:\path\to\script.pl
instead of double-clicking the perl file (or whatever you are doing to start it). This should not start a new window.
… or you could have the script wait until you have read the message. Just wait for user input of some sort before exiting, e.g. like
<>; # read and discard a line to exit
at the bottom of your script.
You can also use the pause program for this, which you can execute like system('pause').

I want to run a command in the system shell then respond to the program i am running with the commands input prompt?

I am trying to
Send a command to the terminal
Respond to the program's input prompt in Python.
How can I do that? I know how to use subprocess.check_output to just get a return.
if you have your inputs in a file normally < symbol would do.
./executable < inputsfile

edit commandline with $EDITOR in tcsh

Today's Daily Vim says this:
Assuming you're using the bash shell, the following can be helpful when composing long command lines.
Start typing on the command line and then type Ctrl-x Ctrl-e, it should drop you into your system's default editor (hopefully Vim) and allow you to edit the command line from there. Once finished, save the command line, and bash will run the command.
Is there any way to do this in tcsh?
A little explanation for the uninitiated.
bindkey -v
puts you in vi-mode (oh yeah!)
and hitting v from there would take you to $EDITOR -- and all is good with the world from there on.
Hmmm... IIRC, tcsh uses a command called bindkey. Try bindkey -v at the command line. Then hit escape followed by v. It's been a while since I used tcsh so the details are a bit fuzzy. When in doubt, Google it.