The pop-up notification will only display the beginning:īut we can see the full text in the notification center: Osascript -e 'display notification "hello world! This is a longer message and we would like to see how is it going to be displayed." with title "Greeting" subtitle "More text"' If the name of the sound is incorrect Mac will make an alert sound. Osascript -e 'display notification "hello world!" with title "Greeting" subtitle "More text" sound name "Submarine"' The sound can be one of the files in /System/Library/Sounds or in ~/Library/Sounds.ĭisplay notification "hello world!" with title "Greeting" subtitle "More text" sound name "Submarine" In addition to the visual notification, the display command can also include a sound effect. Osascript -e 'display notification "hello world!" with title "Greeting" subtitle "More text"' If we have a title we can also have a subtitle:ĭisplay notification "hello world!" with title "Greeting" subtitle "More text"
Osascript -e 'display notification "hello world!" with title "This is the title"' We can also set it in the AppleScript command:ĭisplay notification "hello world!" with title "This is the title" The default title of the notification was "Script Editor".
You can clear the list of notifications by clicking on the x.
You can open the Notification center (the hamburger icon in the top right corner of the screen) that will look something like this: (assuming the only notification The result is a pop-up like this that shows up in the top right corner of the screen and disappears after about 3 seconds: Osascript -e 'display notification "hello world!"' In order to run it on the command line we need to wrap that code in single-quotes and use the -e flag of osascript. The AppleScript code to send a notification with the text "hello world!" looks like this: That seems to be more useful at this point. We could write an AppleScript in a file and use osascript to run the file, but osascript can also execute one-liners where all the commands are on the command-line. The display command can send a notification to the standard notification system of Mac that will show a pop-up for a few seconds and that can be listed by clicking on the hamburger icon in the top-right corner of the screen (at the right end of the menu bar). There are a couple of interesting ones, for example: display and say. If the previous link stops working typing man osascript in the Mac Terminal should give you the explanation.ĪppleScript is a scripting language created by Apple. Then, use hdiutil to eject it, for example: hdiutil detach /dev/disk2s2.Osascript is a tool that comes with Mac that can execute code written in AppleScript, JavaScriptĪnd maybe a few other languages. To eject, first find out what disk device it is associated to by typing “df”.
How to eject a “.dmg” file using command line? To attach a encrypted dmg file without having it pop up a GUI dialog, do hdid -stdinpass mydisk.dmg. If it is encrypted, a password GUI dialog will pop up. The disk image will show up at /Volumes/. How to open a “.dmg” file with commnand line tool? This will create a disk image with 5 mega bytes, using HFS+ format (OS X standard), and the name of the disk is “myDisk”, and the disk image file created is “myDisk.dmg”. To create one, use hdiutil, like this: hdiutil create -megabytes 5 -fs HFS+ -volname myDisk ~/Desktop/myDisk For applications or executable files, it's better to use disk image format, because that way, all resource fork issues are done correctly, among other reasons.
Mac OS X's disk image file format is called “ ” files. With disk image files, you can also create a image file of a CD, and that can be used to create a CD that is identical to the original CD.
For example, you can create a zip version of all files on a CD, but that zip file can't be used by the OS to boot the machine. The OS will treat disk images just like a storage device, but a virtual one. Disk image is roughly a copy of the actual structure of disk. “.dmg” file are files in Apple's disk image file format,įiles are different than compressed files.
Line tools for Mac specific things, such as launching apps, put system to sleep, etc. This document explains Mac OS X's “.dmg” file, and some tips about using command