Skip to content
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

aliasrc | improve se() #1433

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .config/shell/aliasrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ for command in mount umount sv pacman updatedb su shutdown poweroff reboot ; do
done; unset command

se() {
choice="$(find ~/.local/bin -mindepth 1 -printf '%P\n' | fzf)"
[ -f "$HOME/.local/bin/$choice" ] && $EDITOR "$HOME/.local/bin/$choice"
}
s=("${HOME}/.local/bin/"**/*(.))
c="$(print -lnr ${s:t:r} | fzf)"
[[ "${c}" ]] && "${EDITOR}" ${${(M)s:#*/${c}*}[1]}
Copy link

@RetroViking RetroViking Oct 6, 2024

Choose a reason for hiding this comment

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

Suggested change
[[ "${c}" ]] && "${EDITOR}" ${${(M)s:#*/${c}*}[1]}
[ -n "${c}" ] && "${EDITOR}" ${${(M)s:#*/${c}*}[1]}

Prevents that error when you press esc instead of selecting something.
This is a neat showcase of zsh features, but it might break portability.

~/.config/shell/aliasrc – a separate file called by the zshrc for loading aliases that might be shared in common with bash or other shells.
source

I tried this tweak and still use it.

}

# Verbosity and settings that you pretty much just always are going to want.
alias \
Expand Down