TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

OS X Command Line Utilities

567 点作者 brianwillis大约 11 年前

42 条评论

cstross将近 11 年前
One command I can&#x27;t live without: textutil.<p>Basically it&#x27;s a command-line front end to Apple&#x27;s TextKit file import&#x2F;export library. Works with a bunch of rich text&#x2F;word processor formats, including OpenDoc, RTF, HTML 5, and MS Word. Critically, the HTML it emits is <i>vastly</i> better than the bloated crap that comes out of Microsoft Word or LibreOffice when you save as HTML ...<p>Install pandoc and multimarkdown as well and you&#x27;ve got the three pillars of a powerful, easy-to-use multiformat text processing system.
评论 #7748638 未加载
eschaton将近 11 年前
What always surprises me is that so many don&#x27;t know or use the directory stack commands, pushd and popd. I&#x27;ll admit I was also ignorant of them until something like 2005, but once I learned of them I switched and never looked back. Now I can&#x27;t see someone write or type &quot;cd&quot; without a little bit of a cringe.
评论 #7749021 未加载
评论 #7748359 未加载
评论 #7748319 未加载
评论 #7749061 未加载
评论 #7748347 未加载
评论 #7748234 未加载
评论 #7748375 未加载
评论 #7748373 未加载
评论 #7748281 未加载
ggreer将近 11 年前
I didn&#x27;t know about `screencapture`. That&#x27;s a fun one.<p>The Linux equivalent of `open` is `xdg-open`. I usually alias it to `op`, since `&#x2F;bin&#x2F;open` exists.<p>Another bit of terminal-sugar for OS X users:<p><pre><code> alias lock=&#x27;&#x2F;System&#x2F;Library&#x2F;CoreServices&#x2F;&quot;Menu Extras&quot;&#x2F;User.menu&#x2F;Contents&#x2F;Resources&#x2F;CGSession -suspend&#x27; </code></pre> And most Linux users:<p><pre><code> alias lock=&#x27;gnome-screensaver-command -l&#x27; </code></pre> If you find yourself accidentally triggering hot corners, the lock command is your savior.<p>I&#x27;ve sorta-documented this stuff over the years, but only for my own memory. <a href="https://gist.github.com/ggreer/3251885" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;ggreer&#x2F;3251885</a> contains some of my notes for what I do with a clean install of OS X. Some of the utility links are dated, but fixing the animation times really improves my quality of life.
评论 #7753103 未加载
评论 #7749475 未加载
greggman将近 11 年前
These are awesome. I didn&#x27;t know about many of them.<p>One tiny thing though, at the bottom it says<p>&gt; Recall that OS X apps are not true executables, but actually special directories (bundles) with the extension .app. open is the only way to launch these programs from the command line.<p>Actually, you can launch them in other ways. Example<p><pre><code> &#x2F;Applications&#x2F;Google\ Chrome.app&#x2F;Contents&#x2F;MacOS&#x2F;Google\ Chrome --user-data-dir=&#x2F;Users&#x2F;&lt;username&gt;&#x2F;temp&#x2F;delmechrome --no-first-run </code></pre> Will start a new instance of Chrome with it&#x27;s own datastore in ~&#x2F;temp&#x2F;delmechrome. add some URL to the end to have it auto launch some webpage. Delete ~&#x2F;temp&#x2F;delmechrome to start over.
评论 #7748323 未加载
pling将近 11 年前
Another one that I can&#x27;t live without:<p><pre><code> ssh-add -k keyfile </code></pre> Integrates with keychain meaning you can have a passworded private key without having to play around with ssh-agent and shells and profiles. Put keychain access in the menu bar and you can lock the keychain on demand as well. Integration of ssh into the OSX workflow is absolutely awesome.<p>That and some of the examples in that article really make it a killer platform for Unix bits.
wink将近 11 年前
&#x27;open&#x27; is on of the things I long for most as a Linux user. There are several ways to achieve something that are all inferior or downright broken. Usually you don&#x27;t have a huge problem, until you have. xdg-open for example could&#x27;ve solved this, if it was universally working.<p>I wrote related rant once[0] when I tried to debug an issue of a misconfigured default browser.<p>[0]: <a href="http://f5n.org/blog/2013/default-browser-linux/" rel="nofollow">http:&#x2F;&#x2F;f5n.org&#x2F;blog&#x2F;2013&#x2F;default-browser-linux&#x2F;</a>
评论 #7748924 未加载
评论 #7750921 未加载
DCKing将近 11 年前
Could you imagine Apple would have gone for BeOS or a custom developed kernel with no significant terminal-based userland when making OS X? It would probably still be used by many casual users or those doing graphical work, but I doubt it would be used by hackers at all.
评论 #7749304 未加载
评论 #7750441 未加载
评论 #7752574 未加载
nmc将近 11 年前
&#x2F;usr&#x2F;local is the default location for user-installed stuff, but I personally like to have my package manager do its stuff in a separate directory.<p>I like the way Fink [1] uses the &#x2F;sw (software) directory.<p>Does anyone have a valuable opinion on the comparison between Fink and Homebrew — or maybe MacPorts?<p>[1] <a href="http://www.finkproject.org" rel="nofollow">http:&#x2F;&#x2F;www.finkproject.org</a>
评论 #7748407 未加载
评论 #7748272 未加载
评论 #7748284 未加载
评论 #7750203 未加载
评论 #7753271 未加载
评论 #7748262 未加载
Monkeyget将近 11 年前
This was supposed to be few lines of remarks. It expanded quickly in relation with my enthusiasm for this topic.<p>I&#x27;ve been investing some time in the command line on my Mac. I am moving from a dilettante going to the shell on a per-need basis to a more seasoned terminal native. It pays off handesomely! It&#x27;s hard to convey how nice it to have to have a keyboard-based unified environment instead of a series of disjoined mouse-based GUI experiences.<p>Here are some recommendations pertaining to mastering the command line on a Mac specifically:<p>-You can make the terminal start instantaneously instead of it taking several seconds. Remove the .asl files in &#x2F;private&#x2F;var&#x2F;log&#x2F;asl&#x2F;. Also remove the file &#x2F;users&#x2F;&lt;username&gt;&#x2F;Library&#x2F;Preferences&#x2F;com.apple.terminal.plist<p>- Install iterm2. It possesses many fancy features but honestly I hardly ever use them. The main reason to use it instead of the default Terminal application is that It just works©.<p>-Make your terminal look gorgeous. It may sound superficial but it actually is important when you spend expanded period of time in the terminal. You go from this <a href="http://i.imgur.com/cx3zZL8.png" rel="nofollow">http:&#x2F;&#x2F;i.imgur.com&#x2F;cx3zZL8.png</a> to this <a href="http://i.imgur.com/MQbx8yK.png" rel="nofollow">http:&#x2F;&#x2F;i.imgur.com&#x2F;MQbx8yK.png</a> . You become eager to go to your terminal instead of reluctant. Pick a nice color scheme <a href="https://code.google.com/p/iterm2/wiki/ColorGallery" rel="nofollow">https:&#x2F;&#x2F;code.google.com&#x2F;p&#x2F;iterm2&#x2F;wiki&#x2F;ColorGallery</a> . Use a nice font (Monaco, Source Code Pro, Inconsolata are popular). Make it anti aliased.<p>-Go fullscreen. Not so much for the real estate but for the mental switch. Fullscreen mode is a way to immerse yourself into your productive development world. No browser, no mail, no application notification. Only code.<p>-Install Alfred. It&#x27;s the command line for the GUI&#x2F;Apple part of your system. Since I installed it I stopped using the dock and Spotlight. Press ⌘+space then type what you want and it comes up. In just a few keystrokes you can open an application, open gmail&#x2F;twitter&#x2F;imdb&#x2F;..., make a webs search, find a file (by name, by text content), open a directory,... It&#x27;s difficult to describe how empowering it is to being able to go from &#x27;I want to check something out in the directory x which is somewhere deep deep in my dev folders&#x27; to having it displayed in 2 seconds flat.<p>-Make a few symlinks from your home directory to the directories you use frequently. Instead of doing cd this&#x2F;that&#x2F;code&#x2F;python&#x2F;project&#x2F; you just do cd ~&#x2F;project.<p>-Learn the shell. I recommend the (free) book The Linux Command Line: <a href="http://linuxcommand.org/tlcl.php" rel="nofollow">http:&#x2F;&#x2F;linuxcommand.org&#x2F;tlcl.php</a> . It guides you gently from simple directory navigation all the way up to shell scripting.<p>-Use tmux. Essential if you want to spend some time in the terminal. You can split the window in multiple independent panes. Your screen will have multiple terminals displayed simultaneously that you can edit independently. For example I&#x27;ll have the code in one side and on the other side a REPL or a browser. You can also have multiple windows each with its own set of panes and switch from on to the other. With the multiple windows I can switch from one aspect of a project to another instantly. E.g: one window for the front-end dev, a second one for the backend and another for misc file management&#x2F;git&#x2F;whatever.<p>-Pick an editor and work towards mastery. I don&#x27;t care if you choose vi or emacs. You&#x27;ll be surprised how simple features can make a big change in how you type. You&#x27;ll be even more surprised at how good it feels<p>The terminal is here to stay. It&#x27;s a skill that bears a lot of fruits and that deprecate slowly. The more you sow the more you reap.
评论 #7749662 未加载
评论 #7748762 未加载
评论 #7748819 未加载
评论 #7748534 未加载
评论 #7748789 未加载
评论 #7748754 未加载
评论 #7749867 未加载
评论 #7748916 未加载
评论 #7748588 未加载
评论 #7749084 未加载
评论 #7750016 未加载
评论 #7748558 未加载
评论 #7749457 未加载
评论 #7750615 未加载
评论 #7753871 未加载
评论 #7750469 未加载
评论 #7749123 未加载
评论 #7751050 未加载
评论 #7749405 未加载
评论 #7749414 未加载
runjake将近 11 年前
9. &#x2F;usr&#x2F;sbin&#x2F;system_profiler<p>10. &#x2F;System&#x2F;Library&#x2F;CoreServices&#x2F;Applications&#x2F;Wireless Diagnostics (with built-in wifi stumbler)<p>11. &#x2F;System&#x2F;Library&#x2F;CoreServices&#x2F;Screen Sharing.app (Built-in VNC client with hardware acceleration)<p>12. &#x2F;System&#x2F;Library&#x2F;PrivateFrameworks&#x2F;Apple80211.framework&#x2F;Versions&#x2F;A&#x2F;Resources (Command-line wifi configuration and monitoring tool)<p>Combine with sed, awk, and cut, and these tools can provide useful monitoring.
torrent-of-ions将近 11 年前
Another thing you can do to improve speed is learn the keybindings for readline. They are the same keybindings as emacs, and lots of other things use readline too like python shell, sqlite, etc. A very useful set of keys to have in your muscle memory. See the readline manual: <a href="http://tiswww.case.edu/php/chet/readline/rluserman.html#SEC3" rel="nofollow">http:&#x2F;&#x2F;tiswww.case.edu&#x2F;php&#x2F;chet&#x2F;readline&#x2F;rluserman.html#SEC3</a>
评论 #7749483 未加载
_jsn将近 11 年前
mdfind &#x2F; Spotlight can be a fairly powerful tool. Consider this query, which finds all Xcode projects I&#x27;ve tagged as &quot;Active&quot;:<p><pre><code> ~$ mdfind tag:Active kind:xcode &#x2F;Users&#x2F;jn&#x2F;Code&#x2F;xyz&#x2F;xyz.xcodeproj ... </code></pre> Queries like this also work in the Cmd-Space UI, or as a Saved Search. By default each term is joined with AND, but you can specify OR too.
smw将近 11 年前
Put this in your path somewhere, find files, links, directories instantly, with globbing. Makes mdfind actually useful.<p><pre><code> $ mdf &quot;*invoice*.pdf&quot; &#x2F;Users&#x2F;smw&#x2F;Downloads&#x2F;Invoice-0000006.pdf </code></pre> <a href="https://gist.github.com/smw/a21a9f675ed3358830da" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;smw&#x2F;a21a9f675ed3358830da</a>
barbs将近 11 年前
I use multiple POSIX environments (OS X at work, Linux Mint and Xubuntu at home), and I find it handy to create common aliases for differently implemented commands to keep the environments consistent.<p>For example, I set the letter &#x27;o&#x27; as an alias for &#x27;open&#x27; on OS X, and to &quot;thunar&quot; on Xubuntu and &quot;nemo&quot; on Linux Mint.
milla88将近 11 年前
My favorite command is &#x27;say&#x27;. You can do all kinds of silly voices.<p>Try this out: say hello -v Good
评论 #7748190 未加载
评论 #7749087 未加载
评论 #7748328 未加载
评论 #7748174 未加载
pirateking将近 11 年前
After years of living on the command line, OS X specifically, and learning its quirks and tricks, I am actually ready to move on.<p>Right now I am more interested in creating simple visual interfaces on top of UNIX-y tools, for my own personal use cases. The main benefit of this is the ability to better experiment with and optimize my workflows for different properties as needed through different combinations of single responsibility interfaces and single responsibility programs.<p>I am sensing that there is great promise in seeing much higher APMs (actions per minute) for many tasks, even compared to the all-powerful command line. Also, there are lots of interesting possibilities for better visual representations of data to improve comprehension and usability.
评论 #7749068 未加载
ansimionescu将近 11 年前
Additions:<p>* lunchy: wrapper over launchctl, written in Ruby – <a href="https://github.com/mperham/lunchy" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mperham&#x2F;lunchy</a><p>* brew cask: &quot;«To install, drag this icon...» no more&quot;, as they say – <a href="https://github.com/caskroom/homebrew-cask" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;caskroom&#x2F;homebrew-cask</a><p>* have fun with &quot;say&quot; – <a href="https://github.com/andreis/different" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;andreis&#x2F;different</a>
评论 #7752073 未加载
allavia88将近 11 年前
There&#x27;s been a few of these lists over the past few years, most recent one is <a href="https://news.ycombinator.com/item?id=7494100" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=7494100</a><p>It seems like a large portion of HN is less experienced re sysadmin, but is interested in it nonetheless. Perhaps there&#x27;s room to make a &#x27;codecademy for unix&#x27; type course? Curious to see what folks thing.
评论 #7748232 未加载
jpb0104将近 11 年前
Here is a very handy script that takes a screenshot, places it in Dropbox&#x27;s public directory, shortens the public URL, then puts the short URL in your clipboard. Making for very quick screenshot sharing. It combines a few of these hints. <a href="https://gist.github.com/jpb0104/1051544" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;jpb0104&#x2F;1051544</a>
archagon将近 11 年前
Great list! Includes all the old favorites with clear explanations.<p>This is only tangentially related, but I recently wrote a little Automator Service to gather any selected file and folder paths from Finder. I very often need to grab the path of something for programming-related stuff, and doing it from the command line or with the mini-icon drag-and-drop takes way too long. Maybe somebody here will find it useful! <a href="http://cl.ly/1a3s3g1u2Q2w" rel="nofollow">http:&#x2F;&#x2F;cl.ly&#x2F;1a3s3g1u2Q2w</a>
评论 #7748297 未加载
shurcooL将近 11 年前
If you do Go development, you can do this to quickly get to root folder of any Go package:<p><pre><code> function gocd { cd `go list -f &#x27;{{.Dir}}&#x27; $1` } </code></pre> It uses the same syntax as go list to specify packages, so you can do, e.g.:<p><pre><code> ~ $ gocd ...&#x2F;markdownfmt markdownfmt $ pwd &#x2F;Users&#x2F;Dmitri&#x2F;Dropbox&#x2F;Work&#x2F;2013&#x2F;GoLand&#x2F;src&#x2F;github.com&#x2F;shurcooL&#x2F;markdownfmt markdownfmt $ _ </code></pre> So nice.
hibbelig将近 11 年前
I want &quot;remote pbcopy&quot;! I&#x27;d like to be able to log in to any remote host (usually Linux in my case), then tack something onto the command line I&#x27;m typing to copy it into the pastebuffer.<p><pre><code> ssh somehost cd &#x2F;some&#x2F;dir grep -lr foo . | remote_pbcopy </code></pre> I guess something like this is possible with GNU Screen or with Tmux, and perhaps the Tmux&#x2F;iTerm interaction helps, but I&#x27;ve never figured it out.
评论 #7748397 未加载
评论 #7748379 未加载
评论 #7748463 未加载
js2将近 11 年前
Two more for you:<p>sips - <a href="https://developer.apple.com/library/Mac/documentation/Darwin/Reference/ManPages/man1/sips.1.html" rel="nofollow">https:&#x2F;&#x2F;developer.apple.com&#x2F;library&#x2F;Mac&#x2F;documentation&#x2F;Darwin...</a><p>osascript - <a href="https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/osascript.1.html" rel="nofollow">https:&#x2F;&#x2F;developer.apple.com&#x2F;library&#x2F;mac&#x2F;documentation&#x2F;Darwin...</a>
RazerM将近 11 年前
It seems odd to have<p><pre><code> open &#x2F;Applications&#x2F;Safari.app&#x2F; </code></pre> as an example, when<p><pre><code> open -a safari </code></pre> does the same thing.
评论 #7748343 未加载
评论 #7748335 未加载
评论 #7749683 未加载
gotofritz将近 11 年前
Also worth mentioning is dotfiles (not specific to OS X). Basically various well known &quot;power users&quot; share their bash, homebrew, etc settings on github so that they can easily set up a new machine with minimum of fuss. There are a lot of neat trick in those boilerplate files.<p><a href="http://dotfiles.github.io/" rel="nofollow">http:&#x2F;&#x2F;dotfiles.github.io&#x2F;</a>
nicksergeant将近 11 年前
Why the hell would someone change the title from &quot;Eight Terminal Utilities Every OS X Command Line User Should Know&quot; to &quot;OS X Command Line Utilities&quot;.<p>The original title is clearly more accurate &#x2F; useful &#x2F; canonical. The overwritten title is ambiguous. This is indeed not a list of every OS X command line utility.
评论 #7754166 未加载
评论 #7753096 未加载
mmaldacker将近 11 年前
no love for macport?
评论 #7749093 未加载
评论 #7748278 未加载
评论 #7748854 未加载
评论 #7748286 未加载
评论 #7748746 未加载
vladharbuz将近 11 年前
The screencapture options are wrong.<p><pre><code> &quot;Select a window using your mouse, then capture its contents without the window’s drop shadow and copy the image to the clipboard: $ screencapture -c W&quot; </code></pre> -c captures the cursor, W is not an option. The real command for this is:<p><pre><code> $ screencapture -C -o</code></pre>
评论 #7748574 未加载
salgernon将近 11 年前
pbpaste and pbcopy can specify multiple clipboards; one very handy thing I do is<p>&quot;cmd-a&quot; &quot;cmd-c&quot; (copy all)<p>double click on a word I&#x27;m looking for, &quot;cmd-e&quot; to enter it into the find clipboard<p>&#x27;pbpaste | fgrep --color `pbpaste -pboard find`&#x27;<p>I have that aliased as &#x27;pbg&#x27;.
评论 #7750556 未加载
stretchwithme将近 11 年前
The hot keys for screen capture are more useful for daily use. You can paste what you&#x27;ve capture directly into most email clients. Or go to Preview where creating a new file uses what&#x27;s on your clipboard if its an image.
fuzzywalrus将近 11 年前
Notably the screen capture terminal command, while neat, is sold as &quot;more flexible&quot;. I think the author is unaware of Command+shift+4 followed by tapping the spacebar. It&#x27;ll give you the window capture.<p>Otherwise good article.
评论 #7754006 未加载
chrismorgan将近 11 年前
I don’t use a Mac, but have used espeak-via-ssh to deliver a message to my sister who was near my laptop, from the comfort of my bed… I could have (a) called out, or (b) gotten up, but where would the fun have been in that?
chrisBob将近 11 年前
The biggest change I have found for my terminal was adding this to my .bash_profile:<p>export CLICOLOR=1<p>export LSCOLORS=GxFxCxDxBxegedabagaced<p>I thought that was one of the most amazing things when I used a linux system, but OS X is black and white by default.
评论 #7750521 未加载
nemasu将近 11 年前
This is neat. I&#x27;ll be getting a mac soon, and this is right up my ally.
huskyr将近 11 年前
Awesome. I knew about `pbcopy`, but i never knew you could also pipe stuff into it. That saves a lot of time saving script outputs to temporary text files and copying!
评论 #7749121 未加载
RexRollman将近 11 年前
Personally, I was surprised that there is not a command line interface to OS X&#x27;s Notification system. Seems like it would be handy for long running batch jobs.
评论 #7752629 未加载
guard-of-terra将近 11 年前
I wonder if it&#x27;s possible to make OS X to say &quot;As you request, Stan&quot; in Lexx&#x27;s voice.<p>That alone might be sufficient reason to migrate from ubuntu.
评论 #7754101 未加载
fmela将近 11 年前
The &#x27;-name&#x27; argument of mdfind makes it useful to find files with the query string in the name. E.g.: &quot;$ mdfind -name resume&quot;.
conradev将近 11 年前
The one utility I can&#x27;t live without is caffeinate, which prevents a Mac from sleeping.<p>It&#x27;s super useful for keeping long running tasks running.
评论 #7748799 未加载
cormullion将近 11 年前
If you work with images a lot, look up sips. I use it a lot, for converting images, rescaling and resizing, etc.
lastofus将近 11 年前
The article doesn&#x27;t mention the fun you can have with ssh + say.<p>My co-workers and I used to ssh into the iMacs of non-technical users in our office and have a good laugh from a nearby room.
评论 #7748570 未加载
hackeroni将近 11 年前
Thanks for sharing