Terminal shell tweaks: zsh!

I have used a couple of standard terminal emulators on a regular basis including xfce terminal, gnome terminal and Konsole. However, I see many nice tweaks for example changing how the home displays, auto suggestions for commands or other nifty tweaks, which together make it look better or add functionality. I haven’t gone much beyond trying alacritty as alternative and installing neofetch.

What are your favorite tweaks? package name, instructions and/or screenshot are welcome :grin:

Edit: @Kresimir mentioned zsh, I think that is the shell to do this. What tweaks do you guys have for total newbie?!

Zsh

It’s not really a “terminal tweak”, but a shell. However, it makes all those things you mention possible within any terminal emulator. Though, to be fair, you can do most of these things with only Bash, at least on a rudimentary level.

3 Likes

I will have to try that one!

Just installed zsh. Looks like there are tons of options. How do you generally use it, typing zsh in terminal or load automatically to replace bash?

Total new universe opens to me. I also heard about fish but never had time to look all these things up.

Edit: found that sudo chsh s /bin/zsh could be used to replace bash. But not ready to commit yet, need to try first.

I also installed zsh-syntax-highlighting but need to figure out how to activate. :nerd_face:

Edit 2: ok changed the title, since zsh fits the bill and seems to narrow down a bit.

Add this to your .zshrc, somewhere towards the bottom (ideally, should be last, just before custom colours):

source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

Here is how you can customise colours:

Also, you don’t need to chsh to use Zsh, it’s enough to start the terminal emulator with it.

You can also install zsh-autosuggestions, zsh-completions and zsh-history-substring-search. You also have to source the appropriate scripts in your .zshrc. Just make sure zsh-syntax-highlighting is sourced last.

1 Like

I use zsh for all my users as standard. The command chsh is changing the login shell.

In addition to zsh I am a big fan of oh-my-zsh:

This is also installed on all my accounts.

2 Likes

I think the best start to tweak your shell (bash, zsh, or else) is to begin with aliases. Start to create some aliases for your most common commands. You can also begin to set some variables (like $EDITOR) and begin to use these variables to launch or config apps. No need to master this, just to know this and use it to get more speed and comfort in everyday usage of your system.

1 Like

I’ve been using Zsh for about two years. It’s pretty much the only shell I use in interactive sessions. At first I also used chsh to set it as the default shell for my user (but not for the root user, you shouldn’t do that on Arch). But recently (about a year ago), I stopped doing that. I keep Bash as the default shell for all users. Since all of my interactive shell sessions happen in Konsole, my terminal emulator of choice, it is sufficient to just start Konsole with Zsh in it. This gives me the benefit of having Bash as my user’s default shell, without ever actually using it in normal situations. If something goes wrong, and I have to use the TTY, then I all the fancy Zsh features just get in my way, and I prefer to have very plainly configured Bash. That is more than sufficient to fix whatever issue caused me to need to use the TTY.

2 Likes

I just want to make clear that I am only referring to my own users. Anybody else (e.g. family members) keep bash.

Thanks for the links. It takes a bit more time to learn but yesterday I managed to change my prompinit :sweat_smile: There are a lot of options.

The things you mentioned can be done with the default bash shell as well by editing .bashrc file. The things you have mentioned or trying to do are not terminal tweaks they are additional functions ported or sourced in via plugins (which are mainly .sh or .zsh files).

First of you need to understand that zsh is not a terminal tweak. It’s a command interpreter that sits behind a terminal program and executes the commands the user passes through the terminal.

Many shells can be used. A few are below.

  1. Bash Shell (Bourne Again Shell)
  2. Tcsh/Csh Shell
  3. Ksh Shell (Korn shell)
  4. Zsh Shell (Zsh is compatible with most of the above shells)
  5. Fish (friendly interactive shell)

etc…

You can read more about shells here

ZSH is a widely used and very versatile shell compared to most. It’s compatible with POSIX unlike fish shell (fish is good but it kind of breaks things if used as the main shell). ZSH can be used as the main shell without much issue (in my experience).

I saw that @mbod mentioning oh-my-zsh. You really don’t need that to run or use zsh or to have the functions. oh-my-zsh is a plugin manager that comes with a tone of unwanted stuff or scripts (in other words bloat). on-my-zsh tends to slow down zsh itself.

If you really need a plugin manager then you can use a non-bloated one.

etc…

But personally, I don’t think we need a plugin manager because these plugins don’t get updated that often.

If possible watch this video it’ll give you some more understanding of using the .zshrc to archive the similar functions without having to install oh-my-zsh. But it’s best to learn stuff with Bash get comfortable and then move to a shell-like zsh but it’s up to you.

If you want to see how .zshrc looks after configuring you can use mine but it’s better to create your own. I don’t have variables or aliases set because I like to type the commands.

# Lines configured by zsh-newuser-install

#Some eye candy
neofetch

#History in the cache directory and the lines remember
HISTFILE=~/.cache/zsh/history
HISTSIZE=10000
SAVEHIST=10000

#EMACS mode foe keymap
bindkey -e

#Keybinds
bindkey "^[[3~" delete-char #Delete key bind
bindkey "^[[H" beginning-of-line #Use home key to jump to beginning of line
bindkey "^[[F" end-of-line #Use home key to jump to end of line

#Prompt and colors
autoload -U colors && colors

#Simple auto/tab complete 
autoload -U compinit && compinit -u
zstyle ':completion:*' menu select

# Auto complete with case insenstivity
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'

zmodload zsh/complist
compinit
_comp_options+=(globdots)		# Include hidden files.

# Edit line in vim with ctrl-e
autoload edit-command-line; zle -N edit-command-line
bindkey '^e' edit-command-line

# Use lf to switch directories and bind it to ctrl-o
lfcd () {
    tmp="$(mktemp)"
    lf -last-dir-path="$tmp" "$@"
    if [ -f "$tmp" ]; then
        dir="$(cat "$tmp")"
        rm -f "$tmp"
        [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
    fi
}

#Key bind Ctrl + o open lf
bindkey -s '^o' 'lfcd\n'

#Using star ship prompt
autoload -U promptinit; promptinit
prompt spaceship

########################## Plugin Area Start ###################################

#Loding zsh-completions plugin
source ~/.config/zsh/plugins/zsh-completions/zsh-completions.plugin.zsh 2>/dev/null

#Loding zsh-autosuggestion plugin
source ~/.config/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh 2>/dev/null

#Loding zsh-syntax-highlighting plugin
source ~/.config/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 2>/dev/null

#Loading command-not-found plugin
source ~/.config/zsh/plugins/command-not-found/command-not-found.zsh 2>/dev/null

#Loading zsh-you-should-use plugin
source ~/.config/zsh/plugins/zsh-you-should-use/zsh-you-should-use.zsh 2>/dev/null

########################### Plugin Area End ####################################
1 Like

That’s why I called it a terminal shell tweaks and why I changed original title yesterday after the zsh post and digging more into terminal emulators, shells etc…

Thanks fo sharing your config, that is very helpful!

My tip for zsh is the sudo plugin - press esc esc and it adds sudo to the beginning of the line.

And essential reading:

https://project-awesome.org/unixorn/awesome-zsh-plugins