Newsletter # 11 - Managing UTI and URL schemes via Launch Services' API from Swift Nov 29 2019
Hello,
Happy Thanksgiving, for the ones who celebrate it. It's always important to be grateful for everything we have, so no matter if you don't directly celebrate Thanksgiving. Maybe use it as an excuse and think of all the things that you have to be grateful for :).
Alright, in this week's newsletter I want to share with you a podcast I've been enjoying a lot.
The name of the podcast is The History of Computing, you can add it to your favourite podcast player. I use Overcast, so here is the link to the latest episode.
If you are a "long time" reader of my newsletter and blog, you know how much I enjoy history, especially related to technology. The Episode I would like to share with you is the one named The Internet Tidal Wave. The format of this episode it's different than the other episodes in the podcast. This episode is a reading of the Memo Bill Gates sent to its executive team in 1995, where he shows so much foresight on what was to become the Internet.
It's impressive the way he analyses what is to come. If you are a product manager, you'll see him display such a clear understanding of products, tendencies and users that very few people can. For all of us, there is something to learn from that memo, we can not predict the future, but we can help shape it if we open our eyes and try to understand what is currently happening and what the implications are. Who knows, maybe one of you sees something in what is happening today and build the next technology that will change the world.
Anyways, I encourage you to listen to it and let me know what you think.
This week's post was about using Launch Services API from Swift in macOS to set/get default applications associated with URL schemes and Uniform Type Identifiers (UTIs). We build a small tool to change and query the default applications to open when visiting a URL scheme or when opening a file with a specific file type (Defined by its UTI). If you want to read about it here is the link:
https://rderik.com/blog/managing-uti-and-url-schemes-via-launch-services-api-from-swift/
Ok, that's it for this week.
Thanks for reading my newsletter, and I hope you have a happy weekend.
Derik
Tip of the week
Have you ever struggled with a long command, where you prefer to switch to your favourite text editor and write the command there so that you can easily edit it? And then copy the command and paste it on the command-line?
Well, the fc
command can help!
You can use fc
to open your last command in an editor, and once you save the buffer and exit the program (successfully) run the edited command. For example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$ mkdir -p /User/derik/Veri_long_long_long_name/path/new_folder
# you notice that you have a mistake in Veri, it should be very!
# But because you are following all my tips now you:
# 1.) Ctrl+a to go to the beginning of the line
# 2.) add a # to make it a comment and hit enter
$ #mkdir -p /User/derik/Veri_long_long_long_name/path/new_folder
# 3.) you use fc
$ fc
# for me, it opens vim, and I tye the following keys:
# xfV~firy
# That removes the first character "#", moves forward to the "V"
# changes it to lower case then moves forward to "i" and replace it
# with "y". Very nice, eh?
# Now I can `Esc:wq` and Bash will run the correct command
$ mkdir -p /User/derik/very_long_long_long_name/path/new_folder
# :)
If the editor exits with an exit code different than 0, it won't execute the command. For example, imagine you are using vim
, and you want to cancel to get back to the command-line without executing the command. You can use :cq
, that will exit vim with an error, and bash won't run the command. To set your editor, use the environment variable $EDITOR
.