Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash Script on a Mac creates a info popup

Tags:

bash

macos

Is there a way in bash on a mac to draw a pretty info box that displays a simple message like "please save all files to /Users/......"

like image 962
Arcath Avatar asked Dec 11 '09 10:12

Arcath


People also ask

Do bash scripts work on Mac?

Bash scripts are files containing code that tell your computer to do something. They're a staple of the Linux world, and there are thousands of them freely available on the internet. With a bit of tweaking, you can use these scripts on your Mac, too.

Why does Mac use old bash?

To put that in perspective, the version of Bash used on your Mac was new when the first iPhone was introduced. Apple is likely using the older version because the licensing for the Bash shell changed from GNU GPL 2 (General Public License) to GNU GPLv3, which includes restrictions that could cause problems for Apple.

What is $@ bash script?

bash [filename] runs the commands saved in a file. $@ refers to all of a shell script's command-line arguments. $1 , $2 , etc., refer to the first command-line argument, the second command-line argument, etc. Place variables in quotes if the values might have spaces in them.

What is bash on Macbook?

Bash is a command-line interface shell program used extensively in Linux and macOS. The name Bash is an acronym for "Bourne Again Shell," developed in 1989 as a successor to the Bourne Shell.


1 Answers

You can run fragments of applescript from you bash scripts. A simple popup would look like this:

#!/bin/bash
/usr/bin/osascript <<-EOF

    tell application "System Events"
        activate
        display dialog "Hello world"
    end tell

EOF

This will feed the applescript between the EOF tags to osascript and execute it
(resulting in a Hello World popup).

like image 75
Shirkrin Avatar answered Oct 06 '22 09:10

Shirkrin