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.

3 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

1 Like

Using the terminal more recently, specifically to create some Plex folders with Youtube content…

It’s frustrating that we have to both make a directory AND move into it.
So I added a line (with zsh using zshconfig, can do it in .bashrc).

alias mkcd='mkdircd(){ mkdir "$1" && cd "$1" ; }'

mkcd-magic

Zsh with heavy custom e.g. Powerlevel10k or oh-my-zsh has the issue when resizing a window e.g. Konsole.
image

Fish Shell with tide has no issue and looks like Zsh Powerlevel10k, but it is faster because of Asynchronous Rendering

Maybe - that’d be nice in the Dolphin terminal, but interestingly doesn’t happen with KiTTY.

I just figured out how to get the global alias’s to expand when I hit space (i.e. instead of alias ‘la’ showing ‘la’ when I type ‘la_’ I get ❯ exa --icons -a --group-directories-first ─╯
However, I will have a look at Fish.

Short info:

Fish shell is not fully POSIX compliant, but Bash and Zsh are.

I like to use Fish shell for profile of terminal on DE. Set profile as /bin/fish for Konsole, Dolphin terminal etc.

I use Bash without heavy custom for TTY and an interactive shell. Do not use chsh -s /bin/fish

try using starship prompt with zsh
IMG_20220620_032729

2 Likes

I do not know about Starship, but it also supports Fish shell

https://en.linuxteaching.com/article/starship_opensource_customizable_prompt_for_any_shell

There are so many possible themes, but I don’t want to try them.

There is Oh-My-Fish

I’ve said it many times before, but I think it’s worth repeating here: if you are using Zsh, I recommend against using oh-my-zsh. It’s very slow and most of the stuff there is bloat.

It is much better to customise Zsh yourself – not only is it fun to learn about it, the end result is a super-fast shell without bloat you don’t need. A good thing about oh-my-zsh is that you can steal ideas from it, of course.

3 Likes