Qutebrowser has a command :close to close the current window and a command :quit, which can be shortened to :q, to quit Qutebrowser, thus closing all windows.
Since I'm used to vim and to vim's tabs, I often enter :q, accidentally confusing it with :close, thus having all windows closed at once.
What I'd like to do, is to make :q behave as :close and maybe define a :qa command which behave as the actual :quit command.
Is it possible to do this?
Yes, you can type in normal mode :set aliases
and then change or add aliases as you wish.
In your case you replace the command quit by close and add "qa": "quit".
B.t.w. for getting the best and fastest answers regarding the qutest browser, check out the possibilities to get help on https://www.qutebrowser.org.
Related
Context
So I finally give a try to Fish, and as one would expect I encounter some frictions due to differences with my usual routines.
The most astonishing for me, as for many other, was the absence of the bang operator. I'm fine with the lose of sudo !!, as the suggested function replacement seems even better to me, I named it gar which means "To make, compel (someone to do something); to cause (something to be done." However I'll need a replacement for !<abc><enter> which grab the last history line starting with <abc> and run it without further ado, suggestions are welcome.
Now, for the more personal things:
- I use a Typematrix 2030 keyboard
- I use a bépo layout
- I like to configure default finger position keys with the most used actions
Aims
As on my keybord <enter> is well positioned and is semantically relevant for that, ideally I would like to achieve the following key binding:
ctrl-enter: accept the whole suggestion and run it without further confirmation
ctrl-tab: accept the whole suggestion and wait for further edit
alt-enter: redo the last command without further confirmation
But according to xev it appears that, at least with Gnome-terminal, this combinations are not recognized. Are they terminal that supports it? For now I remapped these three to <ctrl>-i, <alt>-i and <alt>-I respectively:
bind --preset \ci forward-char execute
bind --preset \ei forward-char
bind --preset \eI forward-word
This works as expected, but it seems that now the tab key will also map to the first item. I guess that tab map to <alt>-i at some point in the shell stack. I wasn't aware of that, so I don't know yet if it will be possible for Fish to separate each of them.
To manage jobs, I also came with
bind --preset \es fg
bind --preset \eS bg
The first works as expected, but the second one doesn't. With application like vim, the binding should be operated in the application configuration itself of course. But for things as trivial as yes, <alt>-S won't work as expected while <crl>-z continue to operate normally.
I also would like to bind some commands like ls -alh and git status --short to a directly executed command, showing the result bellow the currently edited line, allowing to further type seamlessly, but didn't find the way to do it yet.
Summary of remaining question
So here are my more precise questions summarised:
how do I bind the sleep signal to <alt>-S?
is there a terminal I can use where <alt>-<enter> and <ctrl>-<enter> works?
how to seamlessly run command while maintaining the current line edition in place?
can you bind something to <alt>-i without altering <tab>?
how do I bind the sleep signal to -S?
What you are doing with bind \es fg is to alter a binding inside the shell.
But when you execute yes, the shell isn't currently in the foreground, so shell bindings don't apply.
What you'd have to do instead is change the terminal settings via stty susp \cs,
but fish resets the terminal settings when executing commands (so you can't accidentally break them and end up in an unusable environment), so there currently is no way to do this in fish.
can you bind something to <alt>-i without altering <tab>?
Sure. You bind \ei. Which is escape+i, which is alt-i (because in a terminal alt is escape).
Your problem is with ctrl-i, which in the way terminals encode control+character is tab. The application receives an actual tab character, and at that point the information has been lost.
is there a terminal I can use where - and - works?
Most terminals should send \e\r for alt-enter. ctrl-enter again is unencodable with the usual code (because \r is ctrl-m), just like ctrl-tab is.
Any fix to this requires the terminal to encode these combination differently.
how to seamlessly run command while maintaining the current line edition in place?
I don't know what you mean by this. I'm guessing you want fish to remain open and editable while a command also runs in the foreground. That can't work. There's no way to synchronize output from two commands to a terminal, not with cursor movement being what it is.
I have a rails app with an interface like this:
<%= form_tag 'sound/speak', remote: true do %>
<input type='text' name='phrase'>
<%= submit_tag 'Say' %>
<% end %>
Which sends a request to a controller:
def speak
`espeak "#{params['phrase']}"`
end
It works but is this a bad idea in terms of safety? I'm just trying to make my server (raspberry pi) to speak whatever I write into the textbox. However in future this might be used by a group of friends. In this case I need to make sure it's impossible to, say, escape the quotes and the "say" command and execute a malicious script/command on the server. So, am I safe with this code?
What you're doing is dangerous. Consider things like this:
danger = 'antisocial tendencies" $(ls) "'
`echo "#{danger}"`
and think about what else you could do besides running ls.
You could use Shellwords (as in How to escape strings for terminal in Ruby?) but that would mean doing this:
Use Shellwords to escape params['phrase'].
Use string interpolation to build a command line.
Hand that command line to the backticks.
Execute a shell.
Let the shell parse the command line you just built.
Get the shell to run espeak with the desired argument.
You could avoid that by using the tools in Open3 or the multi-argument form of Kernel#system to jump directly to step (6) without involving a shell at all.
The shell is where the quoting problems come in so not involving a shell is a convenient way to cut out a whole class of errors and vulnerabilities. Avoiding the shell is also more efficient (although you'd be hard pressed to notice) and flexible as a bonus.
Thanks to sakurashinken for finding the sort-of-duplicate I linked to above, shame you deleted your answer.
I am using Sublime Text 3 and am trying to access the command palette using ctrl-shift-P. This shortcut is not working. I am running Ubuntu 16.04. Any help to fix this would be greatly appreciated.
The two main reasons for this sort of situation (regardless of the key sequence in question) are:
A user installed plugin or custom key binding is bound to the same key, which is taking precedence and stopping the action that you expect from happening
Some external process is eating the keystroke before Sublime even gets to see it.
In order to diagnose which it might be, you can open the Sublime console with View > Show Console or by pressing Ctrl+`, then enter the following commands:
sublime.log_commands(True)
sublime.log_input(True)
Once you've done that, press the key sequence in question and check the output in the console. In your specific case, you should see this:
key evt: shift+control+p
command: show_overlay {"overlay": "command_palette"}
Not seeing the command that you expect indicates that some other action is bound to the key in question, and usually the command will lead you to what's causing the problem.
Not seeing the key event means that some external process is eating the key. This could be some global program or it could be something in the OS doing it (in the case of Linux, the window manager).
It's also possible that you see a different key event entirely, which indicates that your keyboard layout is not what Sublime expects.
Depending on the situation you may be able to disable whatever is eating the key. Presuming you can't find what that is or otherwise don't want to disable it, or if the event shows that Sublime is seeing a different key, the solution is to change the key binding.
The procedure for this is to find the binding that's not working and copy it to your custom key bindings, changing the key as appropriate to something that Sublime can see.
For core Sublime key bindings, look in Preferences > Key Bindings to find the key in question. For packages, that's generally in Preferences > Package Settings > PACKAGENAME > Key Bindings.
In your case, the setting is a default key binding, so looking in the default key bindings yields the following binding, which you can put in your custom key bindings and change as needed:
{
"keys": ["ctrl+shift+p"],
"command": "show_overlay",
"args": {"overlay": "command_palette"}
},
Something that I found:
Weirdly my Sublime Text 3 doesn't recognise the command if I use LCTRL abd LSHIFT. Using RCTRL+RSHIFT+p opens the command palette, so try that.
In my case it was an app called https://noiz.io which had stolen this shortcut. It can take a bit of time as there isn't (AFAIK) a way to find the application which is bound to a shortcut.
In my case a Pomodoro app I just installed had a command for starting clock defined with the same shortcut and it was stealing the event from Sublime. Just removed the shortcut assignment and it works now.
Ok, We all love fsi, but I hate it when I type in the wrong thing and then I want to go up a line and it won't let me....
Is there some kind of shortcut I am missing?
For example, here is a mutually recursive discriminated union. Oh crap, I screwed it up. I want to go back, but I can't.
How do I go up one line and fix stuff?
If you've already committed the line, you can either redefine it (you can define the same types/functions as many times as you want in FSI), or start over. That's why the preferred way to use FSI is: write the code in a script file and 'Send to Interactive'. That avoids this issue.
I type <%= often enough in rails that I want to find a shortcut for it. I am looking for a VIM solution (I specifically use macVim)
I know I can map it to keys or create my own snippetMate.vim snippet but I'm wondering if there's a generally accepted way of doing this.
Vim has abbreviations functionality out of the box. Enter:
:ab < <%=
then when you type < followed by <SPACE> in insert mode it will expand to <%=.
See :help :ab for more information.
tpope has created a plugin that you might find useful called Ragtag
It comes bundled with many mappings, but specifically the following
Mapping Changed to (cursor = ^) ~
<C-X>= foo<%= ^ %>
tpope has a great collection of plugins:
rails.vim
surround
pathogen
endwise
unimpaired
If you are doing any rails development I would highly suggest you look into rails.vim
The snippet way seems the best way to do that.
You can also add the following to your .vimrc:
imap <c-b> <%=
This adds the <%= whenever you type Control b.