Live data from Hacker News

FZF and RipGrep – Navigate with bash faster than ever before

owen.cymru

41–50 of 55 posts

Re: FZF and RipGrep – Navigate with bash faster than ever before

#42

I love the combination of these! Really opens up a world of possibilities. The one command I'm still trying to replace is `cd` itself. For instance, can anyone suggest a way to add bookmarks, so that I can move around faster? I found a few, but was never happy with them.

> The one command I'm still trying to replace is `cd` itself. zsh will implicitly cd if you just mention a directory e.g. `$ ../foo/bar [RET]` will cd there without mention. These days I only use `cd -`.

IIRC that isn't the default. You need to enable the option for that to work.

zsh has about a thousand options you can configure.

Re: FZF and RipGrep – Navigate with bash faster than ever before

#43

Earlier quoted context omitted.

> The one command I'm still trying to replace is `cd` itself. zsh will implicitly cd if you just mention a directory e.g. `$ ../foo/bar [RET]` will cd there without mention. These days I only use `cd -`.

IIRC that isn't the default. You need to enable the option for that to work. zsh has about a thousand options you can configure.

> IIRC that isn't the default. You need to enable the option for that to work.

You're right, it's been so long I completely forgot.

It's auto_cd, and auto_pushd will also automatically push new directories to the dstack.

> zsh has about a thousand options you can configure.

I should probably go through the options list in its entirety one day, but technically according to http://zsh.sourceforge.net/Doc/Release/Options.html it's closer to a quarter of that ;)

Re: FZF and RipGrep – Navigate with bash faster than ever before

#44
post #3

These look awesome! If you're willing to put in that much effort to learn new tools though, could also try zsh or fish. The built-in autocomplete of both over bash is on another level.

There are good reasons to use Zsh beyond its autocomplete system. Zsh parameter expansions are a beautiful thing. When I write CLI scripts, I don't write Bash scripts, I write Zsh scripts. Documentation, however, is lacking. It's not quite as bad as Vim, but there are massive swaths of the program, entire subsystems, that are more or less completely undocumented. It's very user unfriendly. Also, the ad-hoc "plugin" e…

> There are good reasons to use Zsh beyond its autocomplete system...

zsh also performs much better in practice than bash. Not only does it run the same code faster, it subsumes a great deal of functionality that normally requires external utility calls (which are very slow) into the shell itself.

For example:

* zsh has native floating-point arithmetic, so no need for `awk` or whatever. It can even format (digit-group) the numbers

* Regular-expression matching with =~ can be replaced by extended globs (which offer similar functionality but are significantly faster in most cases)

* `basename`, `dirname`, `readlink -m`, and `readlink -f` can be replaced by parameter-expansion modifiers

* `sort` can be replaced by parameter-expansion flags

* `grep` can be replaced by parameter-expansion flags and extended globs

* `find` (including its `-type` and `-exec` features) can be replaced by globs

* `date` can be replaced by prompt expansion or the `zsh/datetime` module

* `cp`, `mkdir`, `rm`, and so on can be replaced by the `zsh/files` module

* `stat` can be replaced by the `zsh/stat` module

* `column` can be replaced by `print -c` or `print -C`

> there are massive swaths of the program, entire subsystems, that are more or less completely undocumented

Like what? I'm not sure i'd noticed that myself. Sometimes the documentation is vague, maybe hard to find (e.g., the completion system's documentation is a bit overwhelming), but it's always been there when i went looking for it.

> Also, the ad-hoc "plugin" ecosystem is in a strange and fragmented state.

The plug-in ecosystem (i assume you mean OMZ, zplug, and stuff like that) is entirely unofficial and most of the zsh developers don't seem to care for any of it because it tends to be slow, error-prone, and often just unnecessary. It's also a major support burden for the people on IRC and in the mailing list, which doesn't endear them to it. Might be cool to have something official though.

> It's a shame that more people don't write actual modules in C (yes, Zsh has a native module system), but then again, is the API even documented?

I don't think it is, there's just an example module you can build. bash also supports loadable modules and it's the same way AFAIK.

> One more thing about Zsh: it has emacs syndrome. Do your really need an FTP client and calendar built into your shell?

Most of the weird stuff like the FTP client and calendar and Tetris game are optional modules or even just regular shell scripts. None of them are enabled by default and packagers can omit them (and they often do, especially with static builds).

Re: FZF and RipGrep – Navigate with bash faster than ever before

#45
post #22

I am using ag. Is it worth changing to RipGrep ? The other unix command line tool that I love is autojump. I am thinking on trying fish and probably fzf.

FZF and fish don't play well if I remember correctly (I hope I'm mistaken though.)

Fish user here! FZF works beautifully with fish, no plugin manager needed. `brew install fzf` gives you the option to install scripts for fish if it's your shell (IIRC).

Re: FZF and RipGrep – Navigate with bash faster than ever before

#46

Earlier quoted context omitted.

> The one command I'm still trying to replace is `cd` itself. zsh will implicitly cd if you just mention a directory e.g. `$ ../foo/bar [RET]` will cd there without mention. These days I only use `cd -`.

IIRC that isn't the default. You need to enable the option for that to work. zsh has about a thousand options you can configure.

I think it is enabled by default. I never explicitly enabled it for my zsh configuration and it behaves that way.

Re: FZF and RipGrep – Navigate with bash faster than ever before

#47
post #16

I love the combination of these! Really opens up a world of possibilities. The one command I'm still trying to replace is `cd` itself. For instance, can anyone suggest a way to add bookmarks, so that I can move around faster? I found a few, but was never happy with them.

It isn't super clear in the article, but I now use bfs & fzf for replacing cd. https://github.com/bag-man/dotfiles/blob/master/bashrc#L73 Lets you change directory with alt+c, although I have tweaked it so you always search from your root folder. Which isn't for everyone. Otherwise fzf alt+c doesn't let you go back up directories which gets frustrating.

Hey, bfs author here, glad you've found it useful! You can do that whole thing in one command with

    bfs ~ -nohidden -type d -printf '~/%P\n'

Re: FZF and RipGrep – Navigate with bash faster than ever before

#48

I am using ag. Is it worth changing to RipGrep ? The other unix command line tool that I love is autojump. I am thinking on trying fish and probably fzf.

I use both ag and rg with fish. For me, both are equally fast (because my repositories are small enough that it doesn't matter), but ag has better UI (I remember the --python option, but have no idea how to filter with rg). Those are about the only differences that matter to me, so I use whatever is muscle memory. Usually rg, unless I want to search for specific filetypes.

If you're wondering whether to switch, don't bother unless you find ag slow.

Fish, on the other hand, I can't live without. I recommend fisherman and z, and a few other plugins I forget now (I use one that shows a notification if your long running command completes while the terminal is in the background, I love it).

Re: FZF and RipGrep – Navigate with bash faster than ever before

#49

I love the combination of these! Really opens up a world of possibilities. The one command I'm still trying to replace is `cd` itself. For instance, can anyone suggest a way to add bookmarks, so that I can move around faster? I found a few, but was never happy with them.

> The one command I'm still trying to replace is `cd` itself. zsh will implicitly cd if you just mention a directory e.g. `$ ../foo/bar [RET]` will cd there without mention. These days I only use `cd -`.

> These days I only use `cd -`.

There's also `cd foo bar` in zsh, which substitutes foo with bar in the name of $PWD. I rarely used it, and when I do, it's usually for a well known pair of lengthy named dirs, yet it also shaves off a couple of keystrokes pretty much daily for me.

Re: FZF and RipGrep – Navigate with bash faster than ever before

#50

I am using ag. Is it worth changing to RipGrep ? The other unix command line tool that I love is autojump. I am thinking on trying fish and probably fzf.

I use both ag and rg with fish. For me, both are equally fast (because my repositories are small enough that it doesn't matter), but ag has better UI (I remember the --python option, but have no idea how to filter with rg). Those are about the only differences that matter to me, so I use whatever is muscle memory. Usually rg, unless I want to search for specific filetypes. If you're wondering whether to switch, don't…

> don't bother unless you find ag slow

Or if you want more correct gitignore matching.

> (I remember the --python option, but have no idea how to filter with rg)

    rg -tpy 'def __init__'
or, to exclude Python files

    rg -Tpy 'def __init__'
You can see the list of types available with `rg --type-list`.
Post reply on HN