How to Use Mail from Terminal in MacOS

Hi folks,

It’s been a while. Here’s a quick post on how to read local mails on your MacOS. This can come in handy if you have cron jobs running on your machine for example which send mails and you want to read the mails sent.

To open mail, open a terminal and run the command

mail

You will see the number of messages, number of unread messages and one line per message, including sender, time of receipt, and mail title. There will be a number shown for each mail starting from 1, then 2, etc.

To read a single mail, say the first 1, just type 1.

Then you can go up and down the mail by pressing Enter, or ctrl + B to go up a page and ctrl + F to scroll down a page.

Once you reach the end of the mail the prompt will change to ?

You can delete the mail by pressing

d <mail number>

To save your changes to mail, e.g. deletion, etc. press the command

q

To exit mail without making any changes to number of read mails, etc, press command

exit

To read about mail command in general, enter the command

man mail

That’s all for now, happy mailing.

How to exclude a folder in find command on a Mac

In order to exclude a folder with find command on a mac, you need to use to command:

-path ./path-to-exclude -prune -o

E.g. to find .txt files in the current folder without descending into a folder called foo, use the following command:

find . -path ./foo -prune -o -name '*.txt'

References

linux – Exclude directory from find . command – Stack Overflow. http://stackoverflow.com/questions/4210042/exclude-directory-from-find-command [17/01/2017].

How to add a SMB Shared Printer on Ubuntu server to Mac

Today I’ll discuss how to add a printer hosted on an Ubuntu server via Samba to a Mac.

First, make sure the printer is on.

Next, download and install the printer driver on your Mac.

Next, open Spotlight Search and type in printers. Printers & Scanners should be highlighter. Press Enter. This will open your printer settings.

Click the + icon to add a new printer. The Add window will appear.

Click IP tab to switch to IP settings.

In the Address field, enter the ip address of the server on which the printer is connected

Under protocol, choose Internet Printing Protocol – IPP. Enter the name of the queue. To find this information, you can open the CUPS admin of the Ubuntu print server, usually at http://{{print server ip}}:631. Go to Printers page, find the printer and copy the link on the printer name. Let’s assume the printer url is http://{{print server ip}}:631/printers/{{printer name}}. In this case, you will enter printers/{{printer name}} for Queue.

Enter a suitable Name and Location.

For Use, click Select Software. The Printer Software window will appear.

Find and click the name of your printer and click OK.

Click Add.

If all goes well, the printer gets added automatically. If doing this for the first time on your Mac, a window will appear showing features you can add to your printer. Click the button to complete the process and you’re done! You can now print from your Mac.

How to enable vi mode for several terminal applications on Unix (os X)

In order to enable vi mode for several readline-compatible (terminal) applications ilke ipython, MySQL, etc. on Unix (os X)

Set the following in your ~/.inputrc file:

set editing-mode vi
set keymap vi
set convert-meta on

Update:

In case someone’s wandering in here recently, IPython 5.0 switched from readline to prompt_toolkit, so an updated answer to this question is to pass an option:

$ ipython --TerminalInteractiveShell.editing_mode=vi

… or to set it globally in the profile configuration (~/.ipython/profile_default/ipython_config.py; create it with ipython profile create if you don’t have it) with:

c.TerminalInteractiveShell.editing_mode = ‘vi’

Source:

python – How do I use vi keys in ipython under *nix? – Stack Overflow. http://stackoverflow.com/questions/10394302/how-do-i-use-vi-keys-in-ipython-under-nix