Skip to content

Conversation

@prime-run
Copy link
Collaborator

Description

This PR introduces three functions to .zshenv taking advantage of fzf, aiming for better and faster Terminal navigation.

The mentioned aliased functions are as follows:

- f_efc='_fuzzy_edit_search_file_content'       # [fz]f [e]dit  [f]ile, search by [c]ontent
- fcd='_fuzzy_open_directory'             # [fz]f [o]pen [d]irectory
- f_ef='_fuzzy_edit_search_file'          # [fz]f [e]dit [f]ile

This approach takes advantage of fzf by directly inputting query which benefits us by:

  • a) generally faster navigation
  • b) triggering fzf filters at once

Some extra features:

1- excluding unwanted search results in fod function
2- null $EDITOR fallback
3- adjustable max_depth=5 for fuzzy finding
4- etc...

Type of change

Please put an x in the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (non-breaking change; modified files are limited to the documentations)
  • Technical debt (a code change that does not fix a bug or add a feature but makes something clearer for devs)
  • Other (provide details below)

Checklist

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My commit message follows the commit guidelines.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added a changelog entry.
  • I have added necessary comments/documentation to my code.
  • I have added tests to cover my changes.
  • I have tested my code locally and it works as expected.
  • All new and existing tests passed.

Screenrecors

fcd

fzf-hyde.mp4

instead of doing : cd ~/Projects/rust/wallrust/src
we just fuzzy it via fcd

video demonstrates 2 fuzzy "searchings" for the target dir!


f_efc

2025-05-04.19-57-11.mp4

we fuzzy find files containing target keyword (in this case save and os) in the directory and selecting it opens the file in $EDITOR

Additional context

  • This features can elevated with tools like bat and ripgrep
  • same aliases for fish shell will be pushed in a different PR

Configs/.zshenv Outdated
Comment on lines 210 to 212
alias f_efc='_fuzzy_edit_search_file_content' # [fz]f [e]dit [f]ile, search by [c]ontent
alias fcd='_fuzzy_open_directory' # [fz]f [o]pen [d]irectory
alias f_ef='_fuzzy_edit_search_file' # [fz]f [e]dit [f]ile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO it's better to have a conventional namespace for fzf.

Example:

We use ff as prefix (I guess it's not straining than flat_`

ffcd - Fuzzy Finder Change Directory
ffe - Fuzzy Finder Edit (edit and search keywords can be omitted as Fuzzy Finder already indicates a Search and in linux everything is a file)
ffec - Fuzzy Finder Edit Content (Consistent according to above with [c] being treated as a flag. Edit Content)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to have a conventional namespace for fzf.

I AGREE!
I'll paypal you $0.42 if you take over the namings 😄😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I currently have 0.0011 so that would be a lot 😂

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like how my PRs literally turn into a discor chat ! 😄😄

@kRHYME7
Copy link
Contributor

kRHYME7 commented May 5, 2025

@prime-run Might be too much but check this out first.

Also, the older implementation seems useless if you have files that are deeply nested. so I explicity add find command on every level. Though, it makes the function long. I guess this can be refactored.

Preview

250505_13h09m29s_recording.mp4

Configs/.zshenv Outdated
content_search=true
shift
;;
--regex)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can go so wrong on lower end machines!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useless if you have files that are deeply nested

could please elaborate with an example.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't search .zshrc because there is zshrc in .config/cfg_backups/.zshrc which always comes first.

also better to load shallower files than deep.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what could cause a bootleneck in here? regex? or multiple find command?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't search .zshrc

unless you mean .zshrc\ directory, I'd call it a feature not a bug😄 (the -d flag in find command)


what could cause a bootleneck

I would argue the whole while loop!
you can monitor your memory allocation to confirm!

@prime-run
Copy link
Collaborator Author

prime-run commented May 5, 2025

and about _fuzzy_change_directory, I think it's killing the intent of the ailias! (I think it should be a different ailias)

like in the screen shot below, the goal is to cd to /home/<username>/.config/hyde/themes/Decay Green by fuzzy searching hyde/decay
am i missing something in the new _fuzzy_change_directory implementation?

250505_10h54m19s_screenshot

UPDATE: now i see what you did there! I guess i stand by:

I think it's killing the intent of the ailias!

and to be honest, as a yazi user, I don't see how i might use the new _fuzzy_change_directory

@kRHYME7
Copy link
Contributor

kRHYME7 commented May 5, 2025

Ah yeah. I see... how about the ffe and ffec?

I'll revert the ffod later as I understand the intent.

@kRHYME7
Copy link
Contributor

kRHYME7 commented May 5, 2025

Owww Cool!

@prime-run
Copy link
Collaborator Author

prime-run commented May 5, 2025

I'll revert the ffod later as I understand the intent.

I commited some edits ffcd should be fine as is rn.


how about the ffe and ffec?

tbh I think my first commits was simple, fast and fairly usable!
don't get me wrong your's is practical as well but its looks really niche to me

UPDATE: now that we are clear with ffcd intent,
let me clarify on the other 2:

  • _fuzzy_edit_search_file : replaces : cd some/directory/path and $EDITOR taget.file.name . and is mostuseful when you are not really sure where that file is but you have a general idea! for example you have to cd some/dir then do and ls and check the list or maybe cd back and ls again then do a final cd path and idk maybe another ls to see your file listed then do an nvim taget.file.name

  • fuzzy_edit_search_file_content: for when you have several files in the cwd but you are not sure which one you want to edit but you know what content the file should have! if not use the alias, i gues you'd grep -irnC3 ./* and read them through then you open the file in editor or idk cat | grep <regex> all files one by one reading through them !!! also you lose the fuzzy finding. this way you just do f_efc <your target content> and you are set!

@prime-run
Copy link
Collaborator Author

prime-run commented May 5, 2025

@kRHYME7

ffcd - Fuzzy Finder Change Directory
ffe - Fuzzy Finder Edit (edit and search keywords can be omitted as Fuzzy Finder already indicates a Search and in linux everything is a file)
ffec - Fuzzy Finder Edit Content (Consistent according to above with [c] being treated as a flag. Edit Content)

is this final ?
I can apply them and nuke new implementations for now.
how does that sound ?

maybe we can move our fzf stuff to a seprate file and built on top of that in future if that fits your vision

@kRHYME7
Copy link
Contributor

kRHYME7 commented May 5, 2025

maybe we can move our fzf stuff to a seprate file and built on top of that in future if that fits your vision

We can add it as a plugin on our plugin installation for zsh or make it a core script and make it POSIX as much possible.


is this final ?

This

  • ffe
  • ffec
  • ffod

I don't mind nuking the _fuzzy_search_directory (former _fuzzy_change_directory) and use ffod for that.

But please add fzf args to make it like a inline pop menu not a fullscreen (So it feels natural drop down ).

image

  fzf_options+=(
        --height "80%"
        --layout=reverse
        --preview-window
        right:60% --cycle
    )


About ffec I can't really navigate it well specially .config/ always comes first. and fzf just takes eternity searching all files. For now this will do but gotta find a way to fuzzy search plus prioritize shallow files.

@prime-run
Copy link
Collaborator Author

prime-run commented May 5, 2025

About ffec I can't really navigate it well

well it's assumed you are in the correct directory and you want to search for the file via its content. other wise the search results would be a mess!

for example cd to your .conf/hypr and ffec for a keybind you have added.

Basically using it in lower level directories such as ~ is a bad idea :)
in other words it's best if used in a Project directory such as ~/.config/hyde/theme/Decay Green


but gotta find a way to fuzzy search plus prioritize shallow files.

that's doable for sure! we can use history or we can add zoxide and rigpre to the core packages 😄😄

@kRHYME7
Copy link
Contributor

kRHYME7 commented May 5, 2025

Cool, ready for merging?

@prime-run
Copy link
Collaborator Author

ready for merging?

I think so

@kRHYME7 kRHYME7 merged commit 503711a into HyDE-Project:dev May 5, 2025
2 checks passed
@prime-run
Copy link
Collaborator Author

We can add it as a plugin on our plugin installation for zsh or make it a core script and make it POSIX as much possible.

so let me pull of the exact same thing (ffe, ffec, ffcd) for fish

cool ?

@prime-run prime-run deleted the more-fzf branch May 5, 2025 15:38
kRHYME7 added a commit that referenced this pull request May 9, 2025
This is an automated PR to promote changes from `dev` to `master`.
Please review and test before merging.

## For Testers
See [TESTING.md](./TESTING.md) for complete testing instructions.

## Suggested Merge Schedule
According to our release policy, this PR is expected to be merged on:
**Friday**
Testers are encouraged to test the changes before merging.
Please note that this schedule may be adjusted based on the needs of the
project.
## Commits to be merged:
---
* chore Add keybind for game launcher (#597) (891b181) by ProfShiba
* feat (hyde-ipc): Our very own IPC handler! (5c4221f) by kRHYME7
* fix(zsh): Use `.user.zsh` (f1446ab) by kRHYME7
* feat(hyde-config): A Go implementation of the parse.config.py
(b6c7bb8) by kRHYME7
* chore Add missing modules to Starship config (#577) (12d113b) by
prime-run
* fix: [Bug]: Defer oh-my-zsh loading may not be the best option #578
(882fef0) by kRHYME7
* chore implement fzf-shell integration for `fish` (#575) (e750c97) by
prime-run
* fix(fastfetch): Correct random handler (3cb0434) by kRHYME7
* chore add best fzf aliases ever (#569) (503711a) by prime-run
* fix(zsh): Explicit history integration (55721cb) by kRHYME7
* fixed the link color being same as normal text (#570) (ca3c158) by
amit
* fix: [Bug]: Game Launcher isn't showing anything #447 (96be51a) by
kRHYME7
* chore style: discord dcol file changes (#566) (63a2949) by amit
* chore refactor(zsh): cleanup zsh for incoing fzf features (abc1a7b)
by prime-run
* chore breaking(zsh): move ~/.hyde.zshrc to more consistent name
`~/.user.zsh` (bb76750) by kRHYME7
* chore Merge branch 'master' of https://github.com/hyde-project/hyde
into dev (1254f3f) by kRHYME7
* chore Merge branch 'master' into dev (73efd7c) by Khing
---

Please review the changes carefully before merging.
@frankjuniorr frankjuniorr mentioned this pull request Jun 16, 2025
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants