Try   HackMD

How to set keybinding in linux (kali-wsl)

Author: Junner
Date: 1/19/2025

I want to make three things:

  1. Let ls as ls -la with color
  2. Let cls as clear 'cause I'm a windows user
  3. Set q as exit

1. Check the Shell Type

To asjust or add keybinds, we need to check what out shell is using first.

echo $SHELL

And if it is /usr/bin/zsh, then you're using Z shell (zsh). And if you see /bin/bash, that is the bash shell.

1-1. Switch to zsh

chsh -s $(which zsh)
exit
wsl --terminate kali-linux
wsl

2. Edit Configuration File

If you're using zsh:

nano ~/.zshrc

If you're using bash:

nano ~/.bashrc

3. Adjust and Create aliases

(1) ls as ls -la --color

Find the alias ls='ls --color=auto'.
Edit it to:

alias ls='ls -la --color=auto'

(2) cls as clear

Add this following line at the end of your file:

alias cls='clear'

(3) Set q as exit

Here we learned this syntax.

alias q='exit'

4. Save and Reload

After saving the file (usually a ctrl+x shortcut if using nano, and ESC>:wq for vim)

For zsh:

source ~/.zshrc

For bash

source ~/.bashrc

Tips:

There are two different shell setting files for root and User. One is at /root/.zshrc and another /home/<Username>/.zshrc. And you can edit /root/.zshrc after sudo -i.