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

Aliases with function improvement #152

Open
ZappaBoy opened this issue Aug 14, 2022 · 3 comments
Open

Aliases with function improvement #152

ZappaBoy opened this issue Aug 14, 2022 · 3 comments

Comments

@ZappaBoy
Copy link
Contributor

Hi everybody,
I'm using dmenu-extended since two one year and I feel I can make a suggestion about an improvement.

I noticed that aliases work (of course) but "simple" aliases. Aliases that call a function not works. And it can be very useful add this. feature

Let me give you an example, it might be clearer:

# This alias work for me
alias edit-note="emacs ~/notes.org""
# This alias does not work for me
function edit-note() {
    emacs ~/notes.org
}
alias edit-note="edit-note""

Obviously if I run that alias from terminal all work.

I think the problem is that the functions defined in the "~/.bash_aliases" (in my case) are not loaded.

@MarkHedleyJones
Copy link
Owner

Hi @ZappaBoy,
Thanks for the suggestion.
I had a quick play around with loading the full interactive shell and sourcing .bashrc when executing commands (which is the missing part of why your defined functions can't be executed).
I didn't get anything satisfactory working and gave up quite quickly.

Depending on what people have defined in their .bashrc, a delay can be introduced by whatever is defined in there so I would prefer not to enable this behaviour by default.
With that said, it would be nice to at least have the option to load the full interactive shell by setting something in the configuration file.

This change isn't something I have the resources to try and support in the near future as I'm currently trying to refactor the codebase to make it cleaner simpler - as it's a complicated mess at the moment 😂
In the meantime I'm trying to focus on implementing those updates when I have time.

You're welcome to open a pull-request if you want to have a go at it yourself.
I'm happy to offer any guidance when I can.
To be merged, it should support zsh as a shell too (as this is something I suspect many users are using).
The shell could be automatically detected using the $SHELL environment variable.
Perhaps a setting like interactive_shell in the configuration with [True, False] as the available options.

Otherwise, we can leave this issue open as a reminder for future.
You can always write everything you need into the alias definition directly, including chaining multiple commands together.
That way, if you were willing to rewrite the alias definitions, you could get the menu working as you wanted without changing anything in dmenu-extended.

@ZappaBoy
Copy link
Contributor Author

@MarkHedleyJones I totally agree with you, load the complete shell means delay for each use.
I will try to come up with something about it when I have some free time.

@MarkHedleyJones
Copy link
Owner

@ZappaBoy Awesome, thanks for taking the time to have a go at this.
I'll keep an eye on your pull-request and help out when I can.

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

No branches or pull requests

2 participants