Here’s a closer look at my dotfiles.
.xinitrc
The capslock key is probably my least used key, but it’s also a very easy key to reach. The escape key on the other hand is one of my most frequently used keys (I like to use vi bindings everywhere) but it’s annoying to reach everytime. Also the left ctrl key is kinda bothersome to reach when i want to ctrl-c -d or -l in my terminal.
So to arrange those keys in a better, I added the following lines to my .xinitrc:
setxkbmap -option ctrl:nocaps
xcape -e 'Control_L=Escape'
The first one makes the capslock key behave like a ctrl key, so now the ctrl-* shortcuts are more comfortable. To solve the escape key problem i used xcape: now a short keypress of the capslock key (without pressing any other key) triggers the escape key behaviour.
Yeah.. but why bother? I know, I know, to many this will look like a stupid thing to change. In the end it’s true: those keyboard changes won’t make anyone a better sysadmin, nor will save hours of time. But to me these changes makes things more comfortable and, especially for Vim/emacs users, once you will get used to the new ctrl/escape key, it’s difficult to go back.
So, should You also change your keyboard layout? Well it depends (though I dont think there are problematic side effects). I would say that if you just started using Vi/Emacs or use them a lot, it’s a must: Vim relies heavly on the escape key and emacs ctrl+* shortcuts are literally painful. If you just use the terminal or the classic copy paste shortcuts, the new keys arrangement won’t make that much of a difference, just a little better.
.bashrc
Many people don’t know that the linux terminal has some emacs shortcuts to use while writing a command. They can be handy, if you know emacs, but there’s also support for vi binding, just enable them with:
set -o vi
now the terminal will feel _almost _like a vim buffer (unfortunately not every command is supported (e.g. ci”))
To me that’s a great tweak to the command line, but unfortunately the ‘clear’ shortcut (ctrl+l) doesnt work anymore because it is already bound to a vi shortcut. So in order to preserve the clear screen shortcut while being in insert mode, i’ve added:
bind -m vi-insert "\C-l":clear-screen
.bash_profile
One thing that bothers me a lot is the presence of unknown hidden files/directories in my ~/ Since I am very messy, I decided to use the xdg directory structure to make some sense.
export XDG_DESKTOP_DIR="$HOME/tmp"
export XDG_DOCUMENTS_DIR="$HOME/tmp"
export XDG_DOWNLOAD_DIR="$HOME/Downloads"
export XDG_MUSIC_DIR="$HOME/tmp"
export XDG_PICTURES_DIR="$HOME/tmp"
export XDG_PUBLICSHARE_DIR="$HOME/tmp"
export XDG_TEMPLATES_DIR="$HOME/tmp"
export XDG_VIDEOS_DIR="$HOME/tmp"
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_RUNTIME_DIR="/run/user/1000"
export XDG_DATA_DIRS="/usr/local/share:/usr/share"
export XDG_CONFIG_DIRS="/etc/xdg"
export XAUTHORITY="$XDG_CONFIG_HOME/Xauthority"
Those are some of the variables to set in order to direct all the xdg compliant application to the right directories.
the next line will remove the .lesshst file that is generated using less.
export LESSHISTFILE=-
You could also use this script to filter all the unwanted files
#!/bin/bash
DOTF="$(ls -d ~/.??*)"
ALLOWED="bash_history bash_logout bash_profile bashrc cache config local ssh xinitrc pki"
for file in $DOTF
do
[[ "$ALLOWED" != *"${file##*.}"* ]] && echo "$file"
done
i3wm
Tiling window managers are really worth learning. After you memorize those 7/8 shortcuts, you can really feel the difference and might search equivalents for macOS or Windows. My i3wm config has nothing special, just some small edits. The only thing that i mention is my custom i3block for spotify, it basically prints the song and artist name in a circular buffer (like on 2000s stereos). Sometimes some special chars breaks everything, but i’m too lazy to fix that.
You can find that i3block here: Link.
Vi,Vim,Neovim
I started using vim during my first year of university and I used it the wrong way for almost a whole year. The ‘wrong’ way to use vim is trying to make it look like an IDE by installing loads of autocomplete plugins, using windows instead of buffers, not learning new commands every now and then, using arrows instead of hjlk… and many more. People get frustrated with vim mainly because:
- They expect to use vim about the same way as another text editor.
- They don’t rebind keys to be more accessible.
The main concept to understand in vi, is that writing a text (or code) take less time than making small changes and fixes to the same. More time is spent on fixing accents, changing words, values, rewriting sentences… So the vi approach is to have different modes/commands for each of these tasks, in order to make them faster. Another important thing to me is having simple shortcuts, easily reachable. Some criticize the emacs shortcuts because they are hard to perform, however many don’t know that keyboards layout used to be different back than. That’s why replacing caps lock with ctrl or escape is (imho) crucial.
Talking about Plugins, I like to keep a relatively small config and not use loads of them (especially those heavy autocomplete ones).
My most favourite plugin is vim-easymotion, it allows to quickly move through text without having to think “which motion shortcut can get me to XYZ the fastest?” The idea is simple, press the spacebar and press 2 keys to get everywhere. I also suggest to set the motion keys to the most easily reachable keys.
" Easymotion
" space in normal mode activates jump between words
nmap <Space> <Plug>(easymotion-overwin-w)
" target keys are uppercase but lowercase input is fine
let g:EasyMotion_use_upper = 1
let g:EasyMotion_keys = 'ASDFGHJKLWERIOVN'
Another handy plugin is supertab (used along with the built-in autocomplete) There’s not much to say, it’s just to trigger the autocomplete with the tab key instead of ctrl+x ctrl+whatever.
" omni completion
filetype plugin on
set omnifunc=syntaxcomplete#Complete
set completefunc=syntaxcomplete#Complete
" supertab
let g:SuperTabDefaultCompletionType = "<c-x><c-n>"
" auto close preview window
let g:SuperTabClosePreviewOnPopupClose = 1
I also use Neotex to automatically compile .tex files after saving changes, Auto-pairs to automatically generate closing parenthesis and also move past them wihtout escaping insert mode, moving right, re-entering insert mode.
Always remember to use the right tool for the right job. Since i write small scripts, i don’t need a complex autocompleter, nor a full fledged git plugin. If I ever need to work on complex projects (especially when I need to coordinate with a dev team), I gladly use an IDE and install a vi plugin; that’s less time consuming and more resonable than using Vim and installing IDE like plugins.