prompt

The Linux pwd command (and Linux command line prompts)

Linux current directory FAQ: How do I show what directory I'm currently in on a Unix or Linux system?

Just use the Unix/Linux pwd command, like this:

pwd

If you're in a directory named /home/al, the output looks like this:

$ pwd
/home/al

If you're in a directory named /tmp, the output looks like this:

$ pwd
/tmp

That's all there is to the pwd command.

How to prompt and read user input in a Bash shell script

Unix/Linux bash shell script FAQ: How do I prompt a user for input from a shell script (Bash shell script), and then read the input the user provides?

Answer: I usually use the shell script "read" function to read input from a shell script. Here are two slightly different versions of the same shell script. This first version prompts the user for input only once, and then dies if the user doesn't give a correst Y/N answer:

A Perl function to prompt users during interactive command-line input

For many Unix users, Perl has replaced the Bourne shell, C shell, and Korn shell as a preferred programming language for many scripting duties and short programs.

Used as a scripting language, Perl programs often require you to prompt the user to enter some type of input. I've found that instead of writing separate "prompting" code in each of my Perl scripts, it's easier to create one prompting routine that can be used in almost all Perl programs.

AppleScript dialog - prompt for a response

A frequent AppleScript question I get is "How do I get information back from a user after I've prompted them with a dialog?" The following example demonstrates how I typically do this. I prompt the user to enter some text, then get their reply back. In this case the reply is stored in the variable named theName.

set theName to the text returned of 
  (display dialog "What is your name?" default answer "")

For your reference, the dialog created by this code looks like this:

AppleScript text dialog - How to display multiline text in a dialog

AppleScript dialog text FAQ: How can I display an AppleScript dialog showing multiple lines of text?

Once you know how to do it, this is surprisingly easy, and there are a couple of ways to do it. Here are a few examples:

display dialog "Line 1
Line 2
Line 3"

An AppleScript dialog textfield example

AppleScript dialog FAQ: How can I display an AppleScript dialog with a textfield (text field)?

A frequent AppleScript question is "How do I prompt a user to enter some text?" Here's how you display an AppleScript dialog to prompt a user to enter a simple piece of information, in this case their name:

display dialog "What is your name?" default answer ""

Running this AppleScript dialog code results in the following dialog:

My Linux/Cygwin command prompt

As each day passes I use Cygwin more and more. One of the things I like to do on Unix platforms is to control what my command prompt looks like. On Cygwin, I edited my .bash_profile to include a multi-line entry like this:

PS1='
$PWD
yo: '

This may look bizarre, but I like the results. It makes my command line prompt look like this: