EzDevInfo.com

prompt

a beautiful command-line prompt for node.js flatiron/prompt · GitHub a beautiful command-line prompt for node.js

Run Command Prompt Commands

Is there any way to run command prompt commands from within a C# application? If so how would I do the following:

copy /b Image1.jpg + Archive.rar Image2.jpg

This basically embeds an RAR file within JPG image. I was just wondering if there was a way to do this automatically in C#. Thank you.


Source: (StackOverflow)

Python: Read password from stdin

Scenario: An interactive CLI Python program, that is in need for a password. That means also, there's no GUI solution possible.

In bash I could get a password read in without re-prompting it on screen via

read -s

Is there something similar for Python? I.e.,

password = raw_input('Password: ', dont_print_statement_back_to_screen)

Alternative: Replace the typed characters with '*' before sending them back to screen (aka browser' style).


Source: (StackOverflow)

Advertisements

What is your favorite Bash prompt? [closed]

What are some elements in your favorite Bash prompt?

I like to have an indicator of the success of the most recent command, like so (in .bashrc):

function exitstatus {

    EXITSTATUS="$?"
    BOLD="\[\033[1m\]"
    RED="\[\033[1;31m\]"
    GREEN="\[\e[32;1m\]"
    BLUE="\[\e[34;1m\]"
    OFF="\[\033[m\]"

    PROMPT="[\u@\h ${BLUE}\W${OFF}"

    if [ "${EXITSTATUS}" -eq 0 ]
    then
       PS1="${PROMPT} ${BOLD}${GREEN}:)${OFF} ]\$ "
    else
       PS1="${PROMPT} ${BOLD}${RED}:(${OFF} ]\$ "
    fi

    PS2="${BOLD}>${OFF} "
}

PROMPT_COMMAND=exitstatus

Source: (StackOverflow)

Detecting Unsaved Changes

I have a requirement to implement an "Unsaved Changes" prompt in an ASP .Net application. If a user modifies controls on a web form, and attempts to navigate away before saving, a prompt should appear warning them that they have unsaved changes, and give them the option to cancel and stay on the current page. The prompt should not display if the user hasn't touched any of the controls.

Ideally I'd like to implement this in JavaScript, but before I go down the path of rolling my own code, are there any existing frameworks or recommended design patterns for achieving this? Ideally I'd like something that can easily be reused across multiple pages with minimal changes.


Source: (StackOverflow)

How can I change the color of my prompt in zsh (different from normal text)?

To recognize better the start and the end of output on a commandline, I want to change the color of my prompt, so that it is visibly different from the programs output. As I use zsh, can anyone give me a hint?


Source: (StackOverflow)

WPF: Create a dialog / prompt

I need to create a Dialog / Prompt including TextBox for user input. My problem is, how to get the text after having confirmed the dialog? Usually I would make a class for this which would save the text in a property. However I want do design the Dialog using XAML. So I would somehow have to extent the XAML Code to save the content of the TextBox in a property - but I guess that's not possible with pure XAML. What would be the best way to realize what I'd like to do? How to build a dialog which can be defined from XAML but can still somehow return the input? Thanks for any hint!


Source: (StackOverflow)

How can the last command's wall time be put in the Bash prompt?

Is there a way to embed the last command's elapsed wall time in a Bash prompt? I'm hoping for something that would look like this:

[last: 0s][/my/dir]$ sleep 10
[last: 10s][/my/dir]$

Background

I often run long data-crunching jobs and it's useful to know how long they've taken so I can estimate how long it will take for future jobs. For very regular tasks, I go ahead and record this information rigorously using appropriate logging techniques. For less-formal tasks, I'll just prepend the command with time.

It would be nice to automatically time every single interactive command and have the timing information printed in a few characters rather than 3 lines.


Source: (StackOverflow)

Code challenge: Bash prompt path shortener

I implemented a prompt path shortener for bash to be included in the PS1 environment variable, which shortens the working directory into something more compact but still descriptive. I'm curious what other ideas may exist.

Here's the challenge:

Create a bash function _dir_chomp which can be included into PS1 like this (line breaks inserted for readability):

PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] $(
  _dir_chomp "$(pwd)" 20
)\[\033[01;37m\]$(parse_git_branch)\[\033[01;34m\] \$\[\033[00m\] '

with "20" being the parameter for the maximum length as soft limit. These are the examples:

  1. /usr/portage/media-plugins/banshee-community-extensions/files becomes /u/p/m/b/files
  2. /home/user1/media/video/music/live-sets becomes ~/m/v/m/live-sets (note the ~ character as replacement for $HOME)
  3. /home/user2/media does NOT change (20 char limit not exceeded)
  4. /home/user1/this-is-a-very-long-path-name-with-more-than-20-chars becomes ~/this-is-a-very-long-path-name-with-more-than-20-chars (last component stays unshortened: soft limit)
  5. /home/user1/src becomes ~/src ($HOME always shortened)
  6. /home/user1/.kde4/share/config/kresources becomes ~/.k/s/c/kresources (note the prefixing dot is preserved)

Current user is user1.

It's allowed to call external interpreters like awk, perl, ruby, python but not compiled C programs or similar. In other words: external source files are not allowed, code must be inline. Shortest version wins. The length of the bash function body (and called sub functions) counts, means:

_sub_helper() {
  # this counts
}
_dir_chomp() {
  # these characters count (between { and })
  _sub_helper "foobar" # _sub_helper body counts, too
}

Source: (StackOverflow)

What is the difference between PS1 and PROMPT_COMMAND

While taking a look at this awesome thread I noticed that some examples use

PS1="Blah Blah Blah"

and some use

PROMPT_COMMAND="Blah Blah Blah"

(and some use both) when setting the prompt in a bash shell. What is the difference between the two? An SO search and even a bit of broader google searching aren't getting me results, so even a link to the right place to look for the answer would be appreciated. Thanks!


Source: (StackOverflow)

Different bash prompt for different vi editing mode?

When using vi mode (set -o vi) with Bash, it would be nice to have a prompt that depends on the mode you are currently in (insert or command). How does one find out this editing mode?

B.t.w, this seems to be possible in ZSH:


Source: (StackOverflow)

In Windows cmd, how do I prompt for user input and use the result in another command?

I have a Windows .bat file which I would like to accept user input and then use the results of that input as part of the call to additional commands.

For example, I'd like to accept a process ID from the user, and then run jstack against that ID, putting the results of the jstack call into a file. However, when I try this, it doesn't work.

Here's my sample bat file contents:

@echo off
set /p id=Enter ID: 
echo %id%
jstack > jstack.txt

and here's what shows up in jstack.txt:

Enter ID: Terminate batch job (Y/N)? 

Source: (StackOverflow)

List all environment variables from command line?

I'd like to know if it's possible from windows command line to list ALL environment variables.

Something equivalent to powershell gci env: (or ls env: or dir env:).


Source: (StackOverflow)

zsh: update prompt with current time when a command is started

I have a zsh prompt I rather like: it evaluates the current time in precmd and displays that on the right side of the prompt:

[Floatie:~] ^_^ 
cbowns%                      [9:28:31 on 2012-10-29]

However, this isn't exactly what I want: as you can see below, this time is actually the time the previous command exited, not the time the command was started:

[Floatie:~] ^_^ 
cbowns% date                           [9:28:26 on 2012-10-29]
Mon Oct 29 09:28:31 PDT 2012
[Floatie:~] ^_^ 
cbowns% date                           [9:28:31 on 2012-10-29]
Mon Oct 29 09:28:37 PDT 2012
[Floatie:~] ^_^ 
cbowns%                                [9:28:37 on 2012-10-29]

Is there a hook in zsh to run a command just before the shell starts a new command so I can update the prompt timestamp then? (I saw Constantly updated clock in zsh prompt?, but I don't need it constantly updated, just updated when I hit enter.)

(The ^_^ is based on the previous command's return code. It shows ;_; in red when there's a nonzero exit status.)


Source: (StackOverflow)

Prompt dialog in WSH using JScript?

How to open a prompt dialog box in WSH usig JScript??

The only pop-up dialog I've found in the doc is the WshShell.Popup() method. But I need a way to request the user to enter a string, like the window.prompt() method in DOM.

Thanks.


Source: (StackOverflow)

Compiling C-code from the Command Prompt in Windows?

I want to compile C code from the Command Prompt in Windows. I have added the environment variable to the PATH and I can compile .cs files with: csc app.cs

That's OK, but how do I compile app.c?


Source: (StackOverflow)