You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was almost able to replace dmenu with rofi except for one missing functionality.
In dmenu I can source and run custom aliases and functions. Basically, I created a file ~/.zsh_aliases which contains all my custom aliases and functions. I am using it together with a small script that sources these aliases and functions and allows me to call them from dmenu. The advantage here is that I can also source the exactly same file in my shell rc file.
What do you think about including support for custom aliases and functions into rofi and what would be the best approach to do that?
I do not know how different shells handle aliases?
Also they might not be in a single file, I f.e. set aliases from multiple files, depending on purpose.
Under bash I can get a list of aliases using: 'alias' command, maybe that is the way to go?
I am not sure if every shell uses the same format.
As far as I know, Bash and Zsh use the same format for aliases. And these two shells are the most frequently used ones. Thus, maybe starting to support these ones first with extending it to more shells, such as Fish, in the future?
You need to do the run-command, otherwise rofi will try to execute the command, but in case of an alias this is not possible, the 'shell' should execute it. By using the run command it will call bash, and use bash to execute it.
Activity
DaveDavenport commentedon Dec 12, 2014
Having support for aliases would be nice..
Executing the aliasses in run mode is a matter of tweaking the command that executes.
For bash this works:
rofi -rnow -run-command "bash -i -c '{cmd}'"Question is how (in a portable way) does rofi know about available aliasses.
orschiro commentedon Dec 13, 2014
What do you mean by portable way? Does rofi provide a config file where the path to the custom aliases file could be defined?
DaveDavenport commentedon Dec 14, 2014
I do not know how different shells handle aliases?
Also they might not be in a single file, I f.e. set aliases from multiple files, depending on purpose.
Under bash I can get a list of aliases using: 'alias' command, maybe that is the way to go?
I am not sure if every shell uses the same format.
orschiro commentedon Dec 15, 2014
As far as I know, Bash and Zsh use the same format for aliases. And these two shells are the most frequently used ones. Thus, maybe starting to support these ones first with extending it to more shells, such as Fish, in the future?
DaveDavenport commentedon Jan 5, 2015
I have added a command 'run-list-command'. This can call a list that can return a list of 'extra' commands to include in the run-dialog.
orschiro commentedon Jan 6, 2015
@DaveDavenport
Thanks! How can I call it? Tried:
Returns no error, neither any window.
DaveDavenport commentedon Jan 6, 2015
rofi -run-list-command "path to magic script returning aliases" -rnow
You might also want adjust the -run-command to execute the result using zsh.
orschiro commentedon Jan 6, 2015
I begin to understand. So, given that my aliases are stored in
~/.zsh_aliases, something like the following should almost do the trick:~/.zsh_aliases:However, it fails finding the alias file:
DaveDavenport commentedon Jan 6, 2015
No.
I have a script alias.sh that lists all possible commands:
This only lists aliases, but you can add a list of 'functions' too.
Then I execute rofi like this:
You need to do the run-command, otherwise rofi will try to execute the command, but in case of an alias this is not possible, the 'shell' should execute it. By using the run command it will call bash, and use bash to execute it.
How the exact line is for zsh I do not know.
DaveDavenport commentedon Jan 6, 2015
Note to self: With history possible duplicate entries are possible.
orschiro commentedon Jan 7, 2015
Strangely this command does not find all my aliases...
Example of such an alias:
Output of the awk command returns nothing:
The shell, however, is able to find the alias:
DaveDavenport commentedon Jan 7, 2015
I have no idea about zsh. You do not have to use the awk line I provided. that was just an example.
orschiro commentedon Jan 7, 2015
Many thanks for your dedicated help! Finally found a zsh-compatible solution.
zsh_aliases_functions.sh:Function to call the menu in Openbox'
rc.xml:With this extra feature, rofi is close to perfect. 👍
DaveDavenport commentedon Jan 7, 2015
happy you got it working!
DaveDavenport commentedon Jan 7, 2015
Need to fix the duplicates with history still :D
orschiro commentedon Jan 7, 2015
Can you outline what you mean by possible duplicates? Haven't noticed any.
DaveDavenport commentedon Jan 7, 2015
duplicate entries. It might not be there.. but I am not 100% sure, so want to double check .
orschiro commentedon Jan 7, 2015
Alright.
Please let me know if I can do any testing.
Robert
On 07.01.2015 10:12, Dave Davenport wrote:
Sharing my passion & inspiration for
#sustasty lifestyles #transitions
#OpenSource #Sufficiency
#ResourceEfficiency
Flying is old-school and the
world cannot be saved part-time
Co-Creator of @MindfulMeerkats
www.robert.orzanna.de
twitter.com/@orschiro
Fix bug #97: Remove duplicates.
orschiro commentedon Jan 12, 2015
@DaveDavenport
I renamed my alias
wifi-restarttowifiRestartbut it still shows up. Is this a result of theremove duplicatesissue?Screenshot:
DaveDavenport commentedon Jan 12, 2015
It is history... do shift-del to remove the old entry.
orschiro commentedon Jan 12, 2015
You are great. Thank you!
tylerjdurden commentedon Apr 10, 2016
I'm attempting to do this on bash. I've written a script:
I'm running rofi in i3wm. My command to open rofi, without the
-run-list-commandargument, has worked in the past. Now I've changed my command to be:bindsym $mod+d exec rofi -run-list-command ". ~/scripts/print_alias.sh" -run-commmand "/bin/bash -i -c '{cmd}'" -rnow -font "terminus 24" -show runWhen I press mod+d, rofi opens for a split second then crashes.
First, are there any log files I can look at to find the problem or give you more information?
Secondly, let me know if you know the solution offhand.
DaveDavenport commentedon Apr 10, 2016
please do not resurrect an very old bug report.
Please make a new bug report with the requested information.