内容简介:As the maintainer ofEnter:and, we can use that value in a quick call to
As the maintainer of RSwitch
— and developer of my own (for personal use) macOS, iOS, watchOS, iPadOS and tvOS apps — I need the full Apple Xcode install around (more R-focused macOS folk can get away with just the command-line tools being installed). As an Apple Developer who insanely runs the macOS & Xcode betas as they are released, I also have the misery of dealing with Xcode usurping authority over .R
files every time it receives an update. Sure, I can right-click on an R script, choose “Open With => Other…”, pick RStudio and make it the new default, but clicks interrupt train of thought and take more time than execution a quick shell command at a terminal prompt (which I always have up).
Enter: dtui
— https://github.com/moretension/duti
— a small command-line tool that lets you change the default application just by knowing the id of the application you want to make the default. For instance, RStudio’s id is org.rstudio.RStudio
which can be obtained via:
$ osascript -e 'id of app "RStudio"' org.rstudio.RStudio
and, we can use that value in a quick call to duti
:
$ duti -s org.rstudio.RStudio .R all
If you’d rather Visual Studio Code or Sublime Text to be the default for .R
files, their bundle ids are com.sublimetext.3
and com.microsoft.VSCode
, respectively. If you’d rather use Atom, well you really need to think about your life choices.
We can see what the current default for R scripts via:
$ duti -x R RStudio.app /Applications/RStudio.app org.rstudio.RStudio
You can turn the “setter” into a shell alias (preferably zsh
or sh
alias since bash
is going away soon) or shell script for quick use.
Installing duti
Homebrew users can just brew install duti
and get on with their day. Folks can also grab the latest release
and get on with their day with just a little more effort.
The duti
utility can also be compiled on your own (which is preferred so you can look at the source to make sure you know being compromised by a random developer on the internet); but, if you have macOS 10.15 (Catalina), you’ll need to jump through a few hoops since it doesn’t compile out-of-the-box on that platform yet. Thankfully those hoops aren’t too bad
thanks to a helpful pull request
that adds support for the current version of macOS. (You’ll need at least the command-line developer tools installed for this to work and likely need to brew install autoconf automake libtool
to ensure all the toolchain bits that are needed are in place.):
At a terminal prompt, go to where you normally go to clone git repositories and grab the source:
$ git clone <a href="/cdn-cgi/l/email-protection" data-cfemail="482f213c082f213c203d2a662b2725">[email protected]</a>:moretension/duti.git $ cd duti $ git fetch origin pull/39/head:pull_39 # add and fetch the origin for the PR $ git checkout pull_39 # switch to the branch $ # review the source code $ # no, really, review the source code! $ autoconf # run autoconf to generate the configure script $ ./configure # generate the Makefile (there will be "checking" and "creating" messages) $ make # build it! (there will be macOS API deprecation warnings but no errors) $ make install # install it! (you may need to prefix with "sudo -H"; this will put the binary in `/usr/local/bin/` and man page in `/usr/local/share/man/man`
FIN
I’ll be adding this functionality to the next version of RSwitch , letting you specify the application(s) you want to own various R-ish files. It will check for the proper values being in place on a regular basis and set them to your defined preferences (I also need to see if there’s an event I can have RSwitch watch for to trigger the procedure).
If you have another, preferred way to keep ownership of R files drop a blog post link in the comments (or just drop a note the comments with said procedure).
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Filter Bubble
Eli Pariser / Penguin Press / 2011-5-12 / GBP 16.45
In December 2009, Google began customizing its search results for each user. Instead of giving you the most broadly popular result, Google now tries to predict what you are most likely to click on. Ac......一起来看看 《The Filter Bubble》 这本书的介绍吧!