How to get notify working for the split toggle command for i3wm? - i3

I have this command:
bindsym $mod+q split toggle
This will toggle between hsplit and vsplit. My individual vsplit and hsplit (activated using $mod+v and $mod+h respectively) are:
bindsym $mod+h split h; exec notify-send 'tile horizontally'
bindsym $mod+v split v; exec notify-send 'tile vertically'
As you can see, these individual splits have a notify-send that pop up to tell me which split orientation is being used.
How do I add that to the split toggle command above?
I tried:
bindsym $mod+q split toggle; exec notify-send 'vertical'; exec notify-send 'horizontal'
This doesnt seem to work. The split toggle command on its own does highlight the side of the window that it's being split, i.e. vertical split has right side of the window being highlighted, while horizontal split has the bottom side of the being highlighted.
However, I would like some better visual feedbacks, hence I want to get this notify-send to work.

What you've written essentially wants to call notify-send twice. So what you probably need to do instead is bind the key to a shell script that keeps track of the current split state (or can inquire about it) using i3-msg.

Related

Vim: is there a fast way to go from three horizontal windows to one vertical and two horizontal?

Suppose you have three windows open each with a different file. Let's call the files one two and three. The windows are vertical like so:
Is there a fast way to go from three vertical windows to one vertical on the left side and the other two stacked horizontally on the right side? Like this:
I currently go the far right window, do a horizontal split explicitly giving the name of the middle buffer file, then move to the middle window and quit. There has to be an easier way, right?
do a horizontal split explicitly giving the name of the middle buffer file
You can reduce your typing by using :h alternate-file: if your buffer#2 happens to be alternate for buffer#3 then you can split by Ctrl-WCtrl-S and then switch to alternate buffer by Ctrl-6. And even if it's not you can still do 2Ctrl-6 (note that here 2 is buffer number, not window number).
I would…
move the cursor to the rightmost window:
<C-w>b
close it:
<C-w>q
split the current window to buffer three:
:sb three<CR>
See : help ctrl-w_b, :help ctrl-w_q, :help :sbuffer.

tmux pin to avoid scrolling

Often when I run a command that writes to stdout, and that command fails, I have to scroll up (using uncomfortable key-bindings) looking for the place where I pressed Enter, to see what the first error was (out of hundreds others, across many screens of text). This is both annoying and time-consuming. I wish there was a feature which allowed me to pin my current terminal to the place where I am now, then start the command, see only the first lines of the output (as many as fits below my cursor) and let the rest of the output be written but not displayed. In other words I would like a feature to allow me automatically scroll up to the place where I gave the command, to see the first lines of the output (where usually the origin of the failure is displayed).
I searched for it but I didn't find it. Do you know if such feature exists? Or have an idea how to implement it with some tricks or workarounds?
If you have a unique shell prompt you could bind a key to jump between shell prompts, for example something like this will make C-b S jump to the previous shell prompt then S subsequent ones:
bind S copy-mode \; send -X search-backward 'nicholas#myhost:'
bind -Tcopy-mode S send -X search-backward 'nicholas#myhost:'
Or similarly you could search for error strings if they have a recognisable prefix. If you install the tmux 3.1 release candidate, you can search for regular expressions.
Alternatively, you could use capture-pane to load the entire history into an editor with key bindings you prefer, for example:
$ tmux capturep -S- -E- -p|vim -
Or pipe to grep or whatever. Note you will need to use a temporary file for this to work with emacs.
Or try to get into the habit of teeing commands with lots of output to a file to start with.

To open Vim in ":" mode and die after enter

Command
vim +"%s/fafa//gn" /tmp/1
which shows the count correctly but opens Vim (not wanted).
I want to use Vim only for computation, although I know it is inefficient.
Pseudocommand
vim +"%s/fafa//gn" +"q" /tmp/1
but it does not show the count, only dies.
I think there should be some sort of conditional operator, for instance AND.
How can you show count in ":" mode and die after user pressing enter?
You can combine commands in command mode with pipes, which is similar to how you are doing it with multiple command line arguments. As such, try this:
vim +"%s/fafa//gne|exec getchar()|q" /tmp/1
Without the bit in the middle, it does exactly the same as your original example. However, the exec getchar() command is a bit of VimScript that -- how used here -- simply waits for keyboard input, so it doesn't exit immediately.

Initiate automatic commands in screen (Linux)

I want to initiate those commands automatically when attaching a screen:
Ctrl+a |
Then
Ctrl+a TAB
Then
Ctrl+a :resize 15
Anyway to do this in one command line?
You can put respective commands at the end of your ~/.screenrc file and they'll get executed every time you start screen. In case you'd like this happen only occasionally, you could create a special screenrc-file, e.g. ~/.screenrc.special and then run screen with screen -c ~/.screenrc.special when you want these things to happen.
Your ~/.screenrc in this case should have as last three lines this:
split
focus
resize 15
Split now supports the -v option
split -v
focus
resize 15

How can one put the output of a command into a konsole title bar?

Through the clever use of some escape characters, I used to put the output of arbitrary commands (e.g. "dirs") into my xterm title bar. Can I do the same thing in konsole? If so, how?
It's a little tricky to do what you want, but you can change Konsole's title bar. Go to:
Settings > Edit current profile > Tabs > Tab title format
and change it to %w which means Window Title Set by Shell. I think you need to close Konsole and reopen it for the changes to take effect.
Anyway, go to the prompt and exec:
OUTPUT=`whoami`; echo -ne "\033]2;$OUTPUT\007"
and behold!
This example sets the title of the window temporarily to whatever is outputted by whoami.
You can also do it using dbus:
qdbus $KONSOLE_DBUS_SERVICE $KONSOLE_DBUS_SESSION setTitle 1 $(dirs)
for KDE 3, using dcop:
dcop $KONSOLE_DCOP_SESSION renameSession $(dirs)

Resources