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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Shell History Is Your Best Productivity Tool

47 点作者 nalgeon大约 1 年前

8 条评论

jeffwiederkehr大约 1 年前
Great article! I had a similar set up using zsh and fzf but recently switched to <a href="https:&#x2F;&#x2F;atuin.sh&#x2F;" rel="nofollow">https:&#x2F;&#x2F;atuin.sh&#x2F;</a> and can&#x27;t recommended it enough. It just works and I love the default built in search by current directory vs global.
评论 #39995189 未加载
mdaniel大约 1 年前
An alternative perspective for consideration:<p>The very act of remembering something embeds it deeper into memory versus control-r &quot;something&quot;, oh yeah that, enter. I&#x27;m cognizant that this is roughly the same argument as &quot;google is making us dumber&quot; which it&#x27;s just &quot;for your consideration&quot; and not an axiom<p>And shell is one of those DSLs folks speak so highly of, in that one can build up a vocabulary that is meaningful to you, or your team, or your line of business in ways that &quot;here&#x27;s my .bash_history good luck&quot; type sharing doesn&#x27;t. Most good unix-y tools support hooks based on the script name to extend common systems with other verbs: brew, git, kubectl, and likely more<p>So, if one needs to remember the 5 distinct commands to cut a release, why not put them in .gitlab&#x2F;scripts&#x2F;run-release versus &quot;oh, I think Jane runs that, ask her to look in her shell history&quot;<p>Merely as a bit of ancedata, I have two forms of shell history suppression: $(ln -sf &#x2F;dev&#x2F;null .bash_history) and the almighty $(export HISTIGNORE=both) which allows me to prefix commands with a space in order to keep them out of even the local shell session&#x27;s history. I am pretty disciplined about doing it for destructive commands so the inadvertent up-arrow+enter doesn&#x27;t go off the rails<p>I&#x27;ve also had great luck with &quot;poor person&#x27;s dry run&quot; as in<p><pre><code> N=echo for i in ...; do $N something destructive &quot;$i&quot; done </code></pre> eyeball the output, then N=&quot;&quot; and run it for reals
评论 #39998879 未加载
评论 #40007197 未加载
add-sub-mul-div大约 1 年前
I go so far as to log all sessions, everything that comes across the screen. Sometimes it&#x27;s a lifesaver or just convenient to be able to grep through everything to find a specific command, sql query, their output, etc.<p>One time long ago I wiped out a long crontab by using -r instead -e and got a perfect recent copy from my terminal history, so no harm done.
评论 #39995794 未加载
评论 #39998904 未加载
评论 #39998890 未加载
mmh0000大约 1 年前
I agree with the author.<p>My shell has a lot of history:<p><pre><code> $ history|wc -l 152298 </code></pre> I&#x27;m usually not typing in new commands, but rather, using ctrl+r and searching for things I remember that I&#x27;ve done.<p>For ZSH users, I would also recommend setting:<p><pre><code> $ setopt EXTENDED_HISTORY </code></pre> Which saves history in the format Format : [beginning time]:[elapsed seconds];[command]<p>And<p><pre><code> $ setopt INC_APPEND_HISTORY_TIME </code></pre> man page says: This option is a variant of INC_APPEND_HISTORY in which, where possible, the history entry is written out to the file after the command is finished, so that the time taken by the command is recorded correctly in the history file in EXTENDED_HIS‐ TORY format. This means that the history entry will not be available immediately from other instances of the shell that are using the same history file.
qweqwe14大约 1 年前
Personally I just disable history in everything I use, including the shell and the browser. If something is potentially worth remembering, just save it into a script&#x2F;make a bookmark.<p>Not having (persistent) history in a shell actually forces you to think about your workflow, which is a good thing.
aninuth大约 1 年前
I&#x27;ve recently started using Atuin (<a href="https:&#x2F;&#x2F;atuin.sh&#x2F;" rel="nofollow">https:&#x2F;&#x2F;atuin.sh&#x2F;</a>), and can&#x27;t get enough. Now it&#x27;s one of the first things I install on any new machine&#x2F;environment I work with, and it&#x27;s been an absolute game-changer.
klooney大约 1 年前
I&#x27;ve become extraordinarily reliant on fzf&#x27;s shell history integration.
评论 #39994718 未加载
评论 #39992726 未加载
charlieok大约 1 年前
if you&#x27;re going to bother syncing your shell history across machines, you probably also would strongly consider syncing your entire home directory.