Shell

Shell is the interface between the user and the operating system. It acts as a keyboard interpreter, taking the keyboard input from the user and delivering it to the operating system. You can think of the shell as being the part of the operating system that allows you to interact with the kernel.

There are numerous shells available for Unix-like operating systems, each with its own features and capabilities. Some of the most commonly used shells are bash, zsh and sh. If you want to see which shell you're using run the following command:

echo $SHELL

Prompt

The prompt in a shell is the text that appears in the terminal to indicate that the shell is ready to accept commands. It typically consists of some information about the current environment or status, followed by a symbol (often a dollar sign $ for regular users or a hash symbol # for root/administrator users) to indicate that the shell is ready to accept input. I'll add the following line to my shell config file (in my case ~/.zshrc) to customise my shell prompt:

PROMPT='%F{240}%1~%f '

%F{240} changes the foreground color of the prompt to dark gray. Note the there is a closing tag %f to prevent this color to leak into command part after the prompt is finished. %1~ displays the current directory name instead of default prompt host and username.

Another customisation I always make is adding an auto complete plugin. I use auto suggestion that suggests commands as I type based on my history and completions. Install it via homebrew:

brew install zsh-autosuggestions

And then add it to your ~/.zshrc to run it everytime you open a new terminal:

source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh

Keyboard Shotrcuts

Ctrl + A: Moves the cursor to the beginning of the line.
Ctrl + E: Moves the cursor to the end of the line.
Ctrl + K: Clears the line after the cursor position.
Ctrl + W: Deletes the word before the cursor.
Ctrl + Y: Pastes the most recently deleted text.
Ctrl + L: Clears the screen and places the cursor at the top.
Ctrl + R: Initiates a reverse search through command history.
Ctrl + C: Interrupts the current foreground process (sends SIGINT signal).
Ctrl + Z: Suspends the current foreground process (sends SIGTSTP signal).

PowerShell

in PowerShell, edit $PROFILE by:

code $PROFILE

Add following function to the file:

function prompt {
    $currentDir = (Get-Location).Path.Split("\") | Select-Object -Last 1
    $ESC = [char]27
    "$ESC[38;2;169;169;169m$currentDir "
}

169;169;169 is the RGB code for foreground color.