Skip to content

aliasrc | improve se() #1433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 28, 2025
Merged

aliasrc | improve se() #1433

merged 2 commits into from
Feb 28, 2025

Conversation

emrakyz
Copy link
Contributor

@emrakyz emrakyz commented Sep 2, 2024

  1. Remove external commands like find.
  2. Remove extensions (possibly .sh) and path (/home/username/.local/bin/) from the names in fzf.
  3. Only open the editor if there is a selection.

Do all of these without using find, sed, grep.

  • First line creates an array with the files in the scripts directory.

  • Second line removes path :t and the extensions :r from the scripts.

  • [[ "${c}" ]] checks if this variable is non-empty.

  • ${${(M)s:#*/${c}*}[1]} This works like grep

(M) enables "match" mode.
:# anchors the pattern to the start of each array element.
*/${c}* matches any path containing the selected basename.
[1] selects the first matching item.

1. Remove external commands like find.
2. Remove extensions and path (if present) from the names in fzf.
3. Only open Nvim if there is a selection.

Do all of these without using find, sed, grep.

- First line creates an array with the files in the scripts directory.

- Second line removes path (:t) and the extensions (:r) from the scripts.

- [[ "${c}" ]] checks if this variable is non-empty.

- ${${(M)s:#*/${c}*}[1]}
(M) enables "match" mode.
:# anchors the pattern to the start of each array element.
*/${c}* matches any path containing the selected basename.
[1] selects the first matching item.
@2084x
Copy link
Contributor

2084x commented Sep 7, 2024

doesn't pick up scripts in subdirectories eg. statusbar/

@emrakyz
Copy link
Contributor Author

emrakyz commented Sep 7, 2024

@2084x

We can use a more capturing glob pattern then that is supported by Zsh.

s=("${HOME}/.local/bin/"**/*(.))

This would capture sub-directories' contents too.

@LukeSmithxyz LukeSmithxyz merged commit e2d7879 into LukeSmithxyz:master Feb 28, 2025
@aartoni aartoni mentioned this pull request Mar 15, 2025
LukeSmithxyz added a commit that referenced this pull request Mar 18, 2025
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.

4 participants