9

I have recently switched to fish shell, and its autocomplete is really nice.

However, I find myself wanting to use tab to use the complete_autocomplete feature, as opposed to when it's unambiguous. The forward and end keys both do this, but they're out of reach of my fingers in a normal typing position.

I would love to use the Capslock key for this, as I never ever use that key but it's in such a nice position.

I've tried setxkbmap -option caps:none but that seems to disable the capslock key entirely. I suppose I could bind it to the forward or end key but I'm not sure how to do this either.

Also, I can't seem to find a key binding in fish shell for capslock:

cowpig@gerty:~$ bind -K
b2
backspace
btab
dc
down
end
enter
f1
f2
f3
f4
f5
f6
f7
f8
f9
f10
f11
f12
f13
f14
f15
f16
f17
f18
f19
f20
home
ic
left
npage
ppage
right
sdc
send
sf
shome
sic
sleft
snext
sprevious
sr
sright
up
mavix
  • 127
  • I believe you'll have to find a system-level remapping tool for Ubuntu, as user-land programs usually cant suppress default caps-lock behavior. – Nick Sweeting Sep 20 '16 at 21:50
  • I guess you can use xbindkeys to set the default caps lock behaviour, tell it to send a different event, and handle that event in fish? – XtrmJosh Sep 28 '16 at 00:58
  • Does http://askubuntu.com/questions/574208/deactivate-caps-lock-in-14-04 help? – cubecubed Sep 28 '16 at 15:36
  • Possibly related: http://askubuntu.com/questions/82837/how-do-i-make-the-caps-lock-key-a-third-shift-key/820421#820421 – Elder Geek Sep 28 '16 at 16:40
  • You might be able to write a Python daemon to handle this. Some basic info here: http://stackoverflow.com/questions/22367358/listening-for-global-key-combinations-in-python-on-linux – Nandakumar Edamana Oct 09 '16 at 14:02

1 Answers1

2

First, check the manual because I think that Ctrl + F will also autocomplete. You can see it typing help in fish.

If you want to go ahead with the mapping, run xev and press capslock to get the keycode. Mine is 66:

enter code hereKeyRelease event, serial 37, synthetic NO, window 0x5200001,
root 0x4b7, subw 0x0, time 6149967, (918,609), root:(984,661),
state 0x10, keycode 66 (keysym 0xff57, End), same_screen YES,
XKeysymToKeycode returns keycode: 37
XLookupString gives 0 bytes: 
XFilterEvent returns: False

Now create a script (i.e. ~/xmodmap.sh) with permission 755 and the following text:

#/bin/bash
xmodmap -e "keycode 66 = End"
xmodmap -e "clear Lock"

Run the script and it will convert the capslock into the End key.

To make this permanent, add this command to the startup applications:

/bin/bash -c "sleep 7 && /home/myusername/xmodmap.sh"

I've tried it with the fish shell and it does auto complete the command.

I use Alt Gr to map some keys to closer positions: Customize keyboard layout including navigation keys

Katu
  • 3,593
  • 26
  • 42