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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: Your favorite practical, underutilized programming tip?

15 点作者 dpmehta02大约 11 年前
Example:<p>Tip: Bash reverse search, because manually scrolling through your history is a nuisance.<p>How (OS X): CTRL+R, start typing a word from your command history. Press CTRL+R to cycle through matches, ENTER to execute, TAB to edit. If you want to add forward search to bash, you can re-map your key bindings in your bash profile with the following (maps to CTRL+T): bind &quot;\C-t&quot;:forward-search-history

7 条评论

pjungwir大约 11 年前
Just stumbled on this one recently, I forget where:<p><pre><code> foo | awk &#x27;{ print $NF }&#x27; </code></pre> That prints the last column. $NF = number of fields. I use it a lot like this:<p><pre><code> git status | grep deleted: | awk &#x27;{ print $NF }&#x27; | xargs foo </code></pre> I actually just realized, though, that I don&#x27;t understand why this works. It seems like it should be &#x27;{ print ${$NF} }&#x27; or something, and the command as-given should just print &quot;3&quot; or &quot;6&quot; or whatever. I&#x27;m not an awk expert, so I&#x27;d love to understand what&#x27;s going on here.
评论 #7670237 未加载
评论 #7679440 未加载
评论 #7693765 未加载
pjungwir大约 11 年前
<p><pre><code> rails g migration add_foo_to_bar vi db&#x2F;migrate&#x2F;*!$* </code></pre> or<p><pre><code> bundle exec !! </code></pre> or<p><pre><code> rake db:migrate RAILS_ENV=test !!</code></pre>
评论 #7669676 未加载
arh68大约 11 年前
I&#x27;ll cheat and throw out a tip I haven&#x27;t used yet: apparently if you read <i>man bash</i> long enough, you get to the built-in TCP&#x2F;UDP sockets! [1]<p><pre><code> bash$ cat &lt;&#x2F;dev&#x2F;tcp&#x2F;time.nist.gov&#x2F;13 53082 04-03-18 04:26:54 68 0 0 502.3 UTC(NIST) * </code></pre> [1] <a href="http://hacktux.com/bash/socket" rel="nofollow">http:&#x2F;&#x2F;hacktux.com&#x2F;bash&#x2F;socket</a>
loumf大约 11 年前
1. Using a copy-paste manager to get more than 1 buffer (like Keyboard Maestro, but there are free ones)<p>2. In a lot of editors (not vi), if you need to get back to the point of your last edit (because you scrolled away) use the keyboard shortcuts for UNDO, REDO. So in a lot of editors, CTRL-Z, SHIFT-CTRL-Z -- this jumps you right back to where you last changed something.
评论 #7670326 未加载
oweiler大约 11 年前
Define an old function in your .bashrc<p><pre><code> old() { mv &quot;$1&quot;{,.old} } </code></pre> I use this as a cheap way to backup old files (alternatively use cp instead of mv).
palcu大约 11 年前
In Sublime Text, you can put bookmarks in code using <i>Cmd+F2</i> and navigate between them using <i>F2</i>. It&#x27;s really helpful if you work with big files.
mesozoic大约 11 年前
<p><pre><code> continue;</code></pre>