Bug 424279

Summary: Add bookmarking of typed commands to Konsole
Product: [Applications] konsole Reporter: medin <med.medin.2014>
Component: generalAssignee: Konsole Developer <konsole-devel>
Status: RESOLVED WORKSFORME    
Severity: wishlist CC: tcanabrava
Priority: NOR    
Version: 20.04.3   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: demo bookmark commands Konsole
Use fuzzy search with Ctrl + R

Description medin 2020-07-16 10:22:47 UTC
It would be cool if Konsole could bookmark a list of commands which the user could expend by selecting a command by mouse/shortcut or simply add the previous executed command. 

For example as an average user I found myself typing a number of repeated commands for example : updating/upgrading, install/remove packages, diagnostic of boot time/errors/logs, cleaning var/logs... and sometimes I forgot how to type them so I always spent a quite time to search inside blogs to find them again.

So it would great if Konsole could keep a saved list of those commands and when user click on a shortcut or menu item a window with search bar appears where user could type word(s) and search in the saved list of commands, then the selected item could be paste to Konsole.
Comment 1 tcanabrava 2020-07-16 11:04:34 UTC
What about adding your commands as functions to ~/.bashrc or your shell configuration file? this way you also have tab completion.
Comment 2 medin 2020-07-16 11:49:50 UTC
(In reply to tcanabrava from comment #1)
> What about adding your commands as functions to ~/.bashrc or your shell
> configuration file? this way you also have tab completion.

The old days of messing with config files are gone, and Linux desktop is not the server version, also the average users don't like to edit those hidden config files, and KDE is the only Desktop manager which able to overcome the manual editing and gives the user complete control using graphic interfaces.

I don't even memorize the commands I type, I search them then copy/paste.
Comment 3 tcanabrava 2020-07-16 13:12:46 UTC
but you do know the commands that you need to type, adding a menu that executes arbitrary shell commands is a security risk - think for instance that someone changed the `copy` action on your menu to `rm -rf /*`

I won't implement such feature, if you want to run commands on the command line you can implement the functions that will run the commands in the correct file, ~/.bashrc for instance.

The reasons:
- It's easier to verify what's the function you are calling (just look at the source of ~/.bashrc and you have your function)
- I won't add a security risk to konsole
- Users should be expected to learn the tool that they are using, creating a function in shell is the proper way to add "typing a repeated commands"

But thinking a bit on this, we can actually make this userfull:
- A side panel with "shortcuts" that do show what the command is and a title / comment for it.
- a way to verify for errors (running shellsheck on the file?)

are you willing to help develop such feature?
Comment 4 medin 2020-07-16 14:05:23 UTC
(In reply to tcanabrava from comment #3)
> but you do know the commands that you need to type, adding a menu that
> executes arbitrary shell commands is a security risk - think for instance
> that someone changed the `copy` action on your menu to `rm -rf /*`
> 
> I won't implement such feature, if you want to run commands on the command
> line you can implement the functions that will run the commands in the
> correct file, ~/.bashrc for instance.
> 
> The reasons:
> - It's easier to verify what's the function you are calling (just look at
> the source of ~/.bashrc and you have your function)
> - I won't add a security risk to konsole
> - Users should be expected to learn the tool that they are using, creating a
> function in shell is the proper way to add "typing a repeated commands"
> 
> But thinking a bit on this, we can actually make this userfull:
> - A side panel with "shortcuts" that do show what the command is and a title
> / comment for it.
> - a way to verify for errors (running shellsheck on the file?)
> 
> are you willing to help develop such feature?

I wish I could, I know only some Java/JavaFX/C# basics.

I think you didn't understand well what I meant, What I mean not creating a menu with list of commands, I said to have a separate window with search bar at top and list of commands at center, the list contains only commands content as texts, so when user type something in the search bar the commands that correspond to entered text appear bellow, then user selects the correct item by pressing enter or double click with mouse which will just copy the content of the command to the terminal then the user executes the command in the terminal by pressing enter.

I demonstrated what I meant with Copyq and Konsole in the attached video. (unfortunately Copyq saves all copied texts from desktop in one list and does not have specific list for only commands)
Comment 5 medin 2020-07-16 14:05:56 UTC
Created attachment 130171 [details]
demo bookmark commands Konsole
Comment 6 tcanabrava 2020-07-16 14:19:04 UTC
Created attachment 130172 [details]
Use fuzzy search with Ctrl + R

You don't need that in konsole because this is what fuzzy search gives you.
Comment 7 medin 2020-07-17 00:50:54 UTC
(In reply to tcanabrava from comment #6)
> Created attachment 130172 [details]
> Use fuzzy search with Ctrl + R
> 
> You don't need that in konsole because this is what fuzzy search gives you.

Thanks that was really helpful and I learned a new tool fzf, I never used it before and was only using text files to store my long commands for future usage.

Thanks for your great guidance ;)
Comment 8 2wxsy58236r3 2020-07-17 09:28:09 UTC
If you are going to run a (long) command frequently, you would want to set it as an alias in your ~/.bashrc:

> alias custom-pacman-update='sudo pacman-mirrors --country-config --bar-parameter --another-parameter && sudo pacman -Syyu'
Afterwards you can just type "custom-pacman-update" instead of searching the history.
Comment 9 medin 2020-07-17 09:51:17 UTC
(In reply to 2wxsy58236r3 from comment #8)
> If you are going to run a (long) command frequently, you would want to set
> it as an alias in your ~/.bashrc:
> 
> > alias custom-pacman-update='sudo pacman-mirrors --country-config --bar-parameter --another-parameter && sudo pacman -Syyu'
> Afterwards you can just type "custom-pacman-update" instead of searching the
> history.

That's really cool, I created an alias called "java8" for an old extracted JRE 8 which some JavaFX8 apps still need to run, and it worked perfectly instead of switching the whole default JRE each time for only a specfific app.
Comment 10 Kurt Hindenburg 2024-03-24 01:02:42 UTC
Also, Konsole has quickcommands plugin which might help in addition to the other comments on how to achieve this.  Let us know if those don't work for you.
Comment 11 Bug Janitor Service 2024-04-08 03:47:35 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 12 Bug Janitor Service 2024-04-23 03:47:24 UTC
This bug has been in NEEDSINFO status with no change for at least
30 days. The bug is now closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!