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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Z – Jump around

139 点作者 lovestaco超过 1 年前

24 条评论

latexr超过 1 年前
I tried this and a handful of alternatives a while back, but would often get frustrated because they’d jump to something different than what I intended or were missing some directory I wanted.<p>Eventually I came up with an alternative using fd¹ and fzf². I have a variant of this in my .zshrc:<p><pre><code> function n { cd &quot;$(fd . &quot;${HOME}&quot; --type d --color never | fzf --select-1 --query &quot;${*}&quot;)&quot; ls } </code></pre> Call it with `n` and get an interactive fuzzy search for your directories. If you do `n &lt;argument&gt;`, it’ll start the find with `&lt;argument&gt;` already filled in (and if there’s only one match, jump to it directly). The `ls` is optional but I find that I like having the contents visible as soon as I change directories.<p>In my personal setup I’m also including iCloud Drive while excluding the rest of the Library directory³ as that is too noisy. I have a separate `nl` function which searches just inside `~&#x2F;Library` for when I need it, as well as other specialised `n&lt;char&gt;` functions that search inside specific places that I use frequently.<p>¹ <a href="https:&#x2F;&#x2F;github.com&#x2F;sharkdp&#x2F;fd">https:&#x2F;&#x2F;github.com&#x2F;sharkdp&#x2F;fd</a><p>² <a href="https:&#x2F;&#x2F;github.com&#x2F;junegunn&#x2F;fzf">https:&#x2F;&#x2F;github.com&#x2F;junegunn&#x2F;fzf</a><p>³ Change the fd command to: fd . &quot;${HOME}&quot; &quot;${HOME}&#x2F;Library&#x2F;Mobile Documents&#x2F;com~apple~CloudDocs&quot; --exclude &#x27;&#x2F;Library&#x2F;&#x27; --type d --color never
评论 #39030391 未加载
评论 #39030982 未加载
评论 #39035725 未加载
评论 #39029911 未加载
评论 #39030611 未加载
pprotas超过 1 年前
I use this Rust clone which works great, no complaints: <a href="https:&#x2F;&#x2F;github.com&#x2F;ajeetdsouza&#x2F;zoxide">https:&#x2F;&#x2F;github.com&#x2F;ajeetdsouza&#x2F;zoxide</a><p>Although, I don&#x27;t know what the difference is, other than the language of choice.
评论 #39028622 未加载
评论 #39028578 未加载
评论 #39035335 未加载
评论 #39028161 未加载
评论 #39032902 未加载
7839284023超过 1 年前
I like to use Z as a fish shell plugin. [1]<p>&gt; A pure-fish port means z is fast and fish-friendly, with tab-completions and lazy-loading. Top that off with great customizability and a small amount of added functionality.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;jethrokuan&#x2F;z">https:&#x2F;&#x2F;github.com&#x2F;jethrokuan&#x2F;z</a>
评论 #39031834 未加载
m1keil超过 1 年前
Alternatives: zoxide, autojump, fasd, and probably couple other
评论 #39027725 未加载
评论 #39027026 未加载
评论 #39027143 未加载
评论 #39027476 未加载
hiAndrewQuinn超过 1 年前
Theory: The likelihood of me using a command line tool goes down roughly exponentially with the number of keystrokes I have to make to call.<p>Z is really good in this regard, but I still find myself relatively reaching for fzf&#x27;s Alt+C keybinding, as I outlined in <a href="https:&#x2F;&#x2F;andrew-quinn.me&#x2F;fzf" rel="nofollow">https:&#x2F;&#x2F;andrew-quinn.me&#x2F;fzf</a> way back. I think I need to come across some killer thing `z` does that I suddenly can&#x27;t live without to overcome the activation energy.
评论 #39027808 未加载
评论 #39030423 未加载
评论 #39027846 未加载
wingerlang超过 1 年前
My lowtech solution was to make a function with an array of hardcoded paths, it would then present a menu where you could select 0-N and it would jump. It also started with Terminal.
评论 #39032748 未加载
whirlwin超过 1 年前
Anyone who have used both z and autojump? What is the difference?<p><a href="https:&#x2F;&#x2F;github.com&#x2F;wting&#x2F;autojump">https:&#x2F;&#x2F;github.com&#x2F;wting&#x2F;autojump</a>
评论 #39031379 未加载
评论 #39027460 未加载
kazinator超过 1 年前
It would be good to have a log of the last N directories visited in variables like cd1, cd2, cd3, ... cd9.<p>These could be interpolated into commands:<p><pre><code> $ cd somewhere # found via CDPATH &#x2F;path&#x2F;to&#x2F;somewhere $ cp $cd1&#x2F;file.txt . # copy file from where we were just before the cd, to here </code></pre> cd1 would be always the most recent, cd2 second most recent.<p>Here it is up to cd4:<p><pre><code> if [ -z &quot;$c1&quot; ] ; then c4= c3= c2= fi cdlog_chdir() { local cur=$PWD if command cd &quot;$@&quot; ; then c4=$c3 c3=$c2 c2=$c1 c1=$cur fi } cdlog_chdir() { local cur=$PWD if command cd &quot;$@&quot; &amp;&amp; [ &quot;$PWD&quot; != &quot;$cur&quot; ]; then # only if we successfully change to a different # directory do the following if [ &quot;$cur&quot; == &quot;$c2&quot; ] &amp;&amp; [ &quot;$PWD&quot; == &quot;$c1&quot; ] ; then # Special case: if we changed to the directory that is second # in the cdlog, then just swap between those two. c2=$PWD c1=$cur else # Otherwise rotate through all four. c4=$c3 c3=$c2 c2=$c1 c1=$cur fi fi } </code></pre> Tip: in bash use ESC Ctrl-E to expand variables in the command line before running it. Then the command is recorded with concrete paths, rather than variables that are changing. You can recall the command from history to repeat it.<p>Handy aliases:<p><pre><code> alias cd=&#x27;cdlog_chdir -P&#x27; alias cs=&#x27;cdlog_chdir &quot;$c1&quot;&#x27; </code></pre> &quot;cs&quot; goes back to the previous; if that is repeated, it triggers the swapping behavior in cdlog_chdir, hence the &quot;cs&quot; name.
评论 #39038700 未加载
tkellogg超过 1 年前
FYI for windows, I made this a long time ago:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;tkellogg&#x2F;Jump-Location">https:&#x2F;&#x2F;github.com&#x2F;tkellogg&#x2F;Jump-Location</a><p>Which was fun and all, but eventually replaced by a pure PowerShell implementation that&#x27;s become far more active:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;vors&#x2F;ZLocation">https:&#x2F;&#x2F;github.com&#x2F;vors&#x2F;ZLocation</a>
kazinator超过 1 年前
I&#x27;ve experimented in this area. I once made a &quot;pcd&quot; (parent cd). The idea is that &quot;cd&quot; (if relative) changes the last component of your directory: if you&#x27;re in foo&#x2F;bar and type &quot;cd baz&#x2F;xyzzy&quot;, then the &#x2F;bar component is rewritten to &#x2F;baz&#x2F;xyzzy&quot;.<p>My &quot;pcd&quot; would similarly rewrite the parent component instead. If you&#x27;re in &quot;a&#x2F;b&#x2F;c&quot; and do &quot;pcd x&quot; you change to &quot;a&#x2F;x&#x2F;c&quot;; and &quot;pcd x&#x2F;y&quot; would change to &quot;a&#x2F;x&#x2F;y&#x2F;c&quot;. Useful for when you have some similar directories with parallel structures.<p>I gave it a numeric argument defaulting to 1. &quot;pcd 0&quot; is like cd, &quot;pcd 1&quot; is like pcd, and then higher integer switch higher components.
pama超过 1 年前
A simple Emacs imitation for eshell: <a href="https:&#x2F;&#x2F;karthinks.com&#x2F;software&#x2F;jumping-directories-in-eshell" rel="nofollow">https:&#x2F;&#x2F;karthinks.com&#x2F;software&#x2F;jumping-directories-in-eshell</a>
StanAngeloff超过 1 年前
Heavy user of `z` for many years... that is until it corrupted its own database one final time. There&#x27;s nothing more frustrating than a dropped or corrupted directory database just as you&#x27;ve got the damn thing to remember all your favourite spots on the disk.<p>These days I use <a href="https:&#x2F;&#x2F;github.com&#x2F;gsamokovarov&#x2F;jump">https:&#x2F;&#x2F;github.com&#x2F;gsamokovarov&#x2F;jump</a> which I&#x27;ve mapped to `z`. Happy days.
junon超过 1 年前
Fish does something similar but it&#x27;s not recency&#x2F;frequency related. I can type just a small part of each path leaf, including slashes, and hit tab, and Fish will auto complete the entire path unless there&#x27;s an ambiguity.<p>99% of the time it gets it right, 0.9% of the time it&#x27;s ambiguous, and only a handful of times did it find something I didn&#x27;t intend (shocking twist: I had misspelled something).
soissons超过 1 年前
I used something different, but it didn&#x27;t work as expected because I have multiple directories that start with the same letter. Consequently, the shortcuts changed their paths and I never ended up where I wanted.<p>I built my own tool called Zee, that takes a simplified approach by only utilizing explicit user-defined shortcuts: <a href="https:&#x2F;&#x2F;github.com&#x2F;dnsv&#x2F;zee">https:&#x2F;&#x2F;github.com&#x2F;dnsv&#x2F;zee</a>
dinkleberg超过 1 年前
If you’re using oh-my-zsh you can add z to your plugins list and you’ll get the functionality without needing to install anything.<p>It is a must have
评论 #39027761 未加载
aperum超过 1 年前
I&#x27;ve been using enhancd for years now.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;babarot&#x2F;enhancd">https:&#x2F;&#x2F;github.com&#x2F;babarot&#x2F;enhancd</a>
评论 #39031329 未加载
patja超过 1 年前
Is there history or a meme that holds that z is for jump?<p>Just wondering if that is why the hotkey for the jump action in Baldur&#x27;s Gate 3 is z
评论 #39034646 未加载
cunningfatalist超过 1 年前
I have been using z for many years now, and I cannot recommend it enough. This is one of the most useful tools ever.
mehdix超过 1 年前
Z is part of my dotfiles. Everywhere I clone them, Z would be available immediately.
CamperBob2超过 1 年前
I just use batch files &#x27;1&#x27;, &#x27;2&#x27;, &#x27;3&#x27; ... to cd to commonly-used directories. No need for anything special beyond a &quot;qcd.exe&quot; program to write the batch files (e.g., &quot;qcd 1&quot; allows &quot;1&quot; to return to the current working directory.)
riddley超过 1 年前
Why is this better than CDPATH that is already built into my shell?
评论 #39034846 未加载
评论 #39030481 未加载
评论 #39034868 未加载
评论 #39029208 未加载
tambourine_man超过 1 年前
I&#x27;ve been using for years, can recomend.
coopykins超过 1 年前
This looks great, I love finding simple productivity boosts like this. Not simple in implementation but simple in how easily it becomes part of your workflow.
ChatGTP超过 1 年前
Been using for probably 8 years, amazing