How to map custom ideavim keybinds to only normal mode? - intellij-idea

In ideavim normal mode, I would like to switch between my tabs and splitters similarly to how it is in the firefox extension vimium. My current solution has been to use caps lock if I wanted to type those letters in capitol.
My intended behavior is:
Select next/previous tab:
Pycharm keybind: "Alt + right/left"
Intended ideavim normal mode keybind: "Shift + k/j"
Select next/previous splitter:
Pycharm keybind: "Alt + ./,"
Intended ideavim normal mode keybind: "Shift + l/h"
Currently this is my unsuccessful code for it in .ideavimrc. Any ideas on what might be going wrong?
nmap <S-j> <M-Left>
nmap <S-k> <M-Right>
nmap <M-.> <S-l>
nmap <M-,> <S-h>
let g:ideavim_custom_mappings = 1

It's not possible to bind a vim shortcut to the IntelliJ IDEA shortcut when using IdeaVIM and you need to bind action for it. , but you could try the below instead which works and better:
nmap <S-j> <action>(PreviousTab)
nmap <S-k> <action>(NextTab)
nmap <M-.> <action>(NextSplitter)
nmap <M-,> <action>(PrevSplitter)
You could see all the action list via :actionlist.

Related

How to set window title in the GNU screen to a hostname of current machine?

There is a documentation about setting window title: https://www.gnu.org/software/screen/manual/html_node/Naming-Windows.html
I don't want to change .bashrc on all machines to make dynamic screen. However it will be good set hotkey in my .screenrc to set title using :title (C-a A) command with proper argument.
Maybe there is a solution to provide an output from uname -n to :titile command. Or something similar which automatically or semi-automatically sets window title to hostname.
Questions are:
is there a way to provide output of uname -n to :title command?
is there any other way to set window title to current hostname without changing .bashrc?
There are two approaches to solve it:
Print out sequence which gnu screen can parse for window titile ESC k my-titile ESC \. Screen will extract my-title. It can be done via:
printf '\ek%s\e\\' $(uname -n);
Run screen -X title my-titile to set a titile of current window.
Since I want to do it for all hosts which I sshed into, there is a trick to wrap actual ssh command into ssh() function using one of aforementioned approaches.
E.g.:
ssh() { printf '\ek%s\e\\' "$1"; command ssh "$#"; }
Thanks to #screen on freenode : )
ref.: https://www.gnu.org/software/screen/manual/html_node/Dynamic-Titles.html#Dynamic-Titles

oh-my-zsh cursor up before program has finished vs after, how to make them behave consistently

I've noticed that if I press up arrow at a prompt then I get the previous command and up again gets me the command before that.
Whereas if I press up arrow before the previous program has completed then instead I get the previous command displayed, the cursor is at the end of the line, but oh-my-zsh is now in "search for lines that start with ... " mode meaning I can't press up to get the previous command.
I'm sure this behavior is well known and expected but just in case you don't get it you can repo it like this
Type ls return
Type sleep 3 return
wait 3 seconds for prompt to appear
press ⬆ (should show sleep 3)
press ⬆ again (should show ls)
press return (to run ls)
Type sleep 3 return ⬆ (press the up arrow before the 3 seconds elapses)
It should now be showing sleep 3
Press ⬆
it will still be showing sleep 3 but it want it to be showing ls. Instead it is in "search for commands that start with sleep 3 mode instead of just go to previous command mode.
To make try to clear in both cases these are the steps
lsreturn
sleep 3return
⬆
⬆
But they end up with different results depending on if step3 happens before or after step2 finishes.
Note I saw this Q&A: https://unix.stackexchange.com/questions/324623/how-to-make-oh-my-zsh-history-behavior-similar-to-bashs
But that doesn't seem to be what I'm looking for. I like oh-my-zsh's partial line + up = search for lines that start with the partial. What I'm trying to fix is that if I press up on step 2 above it magically inserts a partial where as if I wait until step 2 finishes it doesn't.
How do I get oh-my-zsh to be consistent here so that a premature up arrow behaves the same as a normal up arrow?
I'm surprised this question isn't common. It's seriously infuriating to have the terminal act inconsistently. I'd except most devs using oh-my-zsh to run into this issue all the time and be massively frustrated.
The example above with sleep 3 is only to make it easy to show the problem. In actual usage the problem happens frequently even with short lived commands. I type say git status return git commit somefile -m "short comment" return ⬆⬆ expecting to see "git status". 66% of the time I get git status and the other 34% I get `git commit somefile -m "short comment" and pressing ⬆ again just blinks the cursor and I have to press Ctrl-C to break out of zsh's partial complete mode.
The fact that this does not seem to be a common complaint for oh-my-zsh makes me wonder if I have something setup wrong.
To make it clearer run zsh without oh-my-zsh.
zsh -d -f
autoload -U up-line-or-beginning-search
zle -N up-line-or-beginning-search
bindkey "^[[A" up-line-or-beginning-search
Now try the steps above. You'll get consistent behavior.
This might be an overkill solution but, following this guide you can see that you can bind new actions to the up/down arrow key. So if you add:
bindkey "^[[A" up-line-or-beginning-search # Up
bindkey "^[[B" down-line-or-beginning-search # Down
to your ~/.zshrc, it should remove the functionality you talked about. I managed to get it to work while still maintaining regular search capabilities but this is not thoroughly tested and should probably be used with care.

SSH Paramiko-Python interactive script-Need to highlight a line from the list and select it

I am using paramiko for ssh interactive commands. I am able to successfully send all the required commands. I am stuck on one issue. i need somebody help to automate this task.
Issue is on output, i will get 4 options, from this options, i need to move to the required option by using arrow keys and then press enter button to select that option.
Please let me know if anybody knows about this.
import paramiko
import time
import os
ssh=paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('server',port=22,username='user',password='pass123')
print("connected to the linux machine from windows machine.")
channel=ssh.invoke_shell()
channel_data = str()
while True:
if channel.recv_ready():
channel_data += channel.recv(9999).decode(encoding='utf_8', errors='strict')
os.system('cls')
print("##### Device Output #####")
print("\n",channel_data)
print("\n #####################")
else:
continue
time.sleep(5)
if channel_data.endswith('[root#home ~]# '):
channel.send('somecommand\n')
#highlight and then press enter button to select that option. please help for below code
ifelse channel_data.endswith('I am trying to choose this option from the list'):
channel.send('\n')
We need to send the keycode. for down arrow key, "[B 1b 5b 42" is key code.
Below is the link for complete list of keycode mapping.
http://www.comptechdoc.org/os/linux/howlinuxworks/linux_hlkeycodes.html

GNU screen: how to highlight status bar when the command character is pressed

I have just started using the hardstatus capability of GNU screen to get a status bar of at the bottom of my terminal. This is particularly useful when running nested screen processes as I get nested status bars which makes it clear how many times I have to press the command key to access a particular screen instance.
For example
tom#stilton:~% ls
a/ b/ c/ d
.
.
.
[stilton] [1* zsh 2$ mutt]
[cheddar] [1$ emacs 2* ssh]
* indicates which window is selected. This makes it clear that I am running screen on cheddar with two windows: emacs and ssh. In the latter I am running another screen session on stilton with two windows: zsh and mutt. To switch to mutt on stilton I need to do "C-a a 2".
This is very useful, but could be more useful.
My question: when the command key is pressed, can I indicate this in the status bar, for example by highlighting it?
This would mean that when "C-a" is pressed the [cheddar] status bar would be highlighted and I would know that commands would be sent to that screen instance. If I were to further press "a" to send a literal "C-a" to the nested screen process the [cheddar] status bar would lose its highlight and the [stilton] status bar would highlight.
This would decrease the cognitive load of using screen considerably!
In git version, that feature was committed recently.
http://git.savannah.gnu.org/cgit/screen.git/commit/?id=db59704c1297c056cec0cc9305ae92e44a15bf33
This new string escape character %E can be used in the same manner as %F both caption and hardstatus.
In the following examples, when you press C-a, then foreground color of hostname %H changes to yellow
hardstatus alwayslastline '%m/%d %02c:%s %?%E%{= .Y}%:%{= .g}%?%H%{-} %L=%-w%45L>%{= g.}%n %t%{-}%+w %-17<%=%{= .y}(%l)'

How can I set tmux hotkey as Ctrl-, that is, Ctrl+comma

I've got some trouble when setting my preferred tmux hotkey on Mac OS X.
The most common hotkeys that invokes tmux's magics are CTRL+A and CTRL+B. But I would rather select other keystrokes for the following reasons: C-a is the global hot key for "jumping to the beginning of a line"; C-b is for "moving backward on a line" and "Page UP in Vim". I don't want to break these nice rules in tmux.
So, I try to set some non-so-frequently-used keystrokes for tmux hotkey. What I choose is CTRL-, , CTRL-., or CTRL-;
I write this statement in my .tmux.conf file:
set-option -g prefix C-,
I start tmux. Oh, it says "bad key". I replace C-, with C-. or C-;. It doesn't work either.
So, how can I set tmux hotkey to CTRL-,?
Had to dig into the source code for this one. The control key can only be applied to letters, #, space and ? (and C-# seems to be equivalent to C-space). Sorry, doesn't look like C-, is possible, at least in tmux-1.6.
None of comma, period, or semicolon are standard control characters. Your terminal emulator probably just sends the plain character, or nothing at all when you type them; you can type them at into cat -v to see what it is sending.
See Wikipedia’s “ASCII control characters” and “How control characters map to keyboards”.
If you can reconfigure your terminal emulator to send some other character/sequence, you should be able to use it in tmux (e.g. have your terminal emulator send the same character as C-\ (hex 1C), and set your prefix to that).
Using xterm terminal
1) put these in your ~/.Xresources to generate escape sequence of F13 when CTRL-,, CTRL-. or CTRL-; is pressed
XTerm.VT100.translations: #override \
Ctrl<Key>period: string(0x1b) string("[1;2P") \n\
Ctrl<Key>comma: string(0x1b) string("[1;2P") \n\
Ctrl<Key>semicolon: string(0x1b) string("[1;2P")
run xrdb ~/.Xresources to load these conf.
2) change prefix in your ~/.tmux.conf
set -g prefix F13
3) fire xterm and tmux
$ tmux