A quick question on Gnome terminal and different shells

HI there,

I noticed on Ultramarine and RisiOS they run zsh. They seem to have a way of providing predictable commands, perhaps as a built in package or script.

Is there a way to achieve this with BASH.

If not I have currently installed zsh and wondering if anyone has implemented this on gnome terminal. Perhaps there is a neat way to switch between the different shell languages.

Currently I am at this stage

This is the Z Shell configuration function for new users,
zsh-newuser-install.
You are seeing this message because you have no zsh startup files
(the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
~).  This function can help you with a few settings that should
make your use of the shell easier.

You can:

(q)  Quit and do nothing.  The function will be run again next time.

(0)  Exit, creating the file ~/.zshrc containing just a comment.
     That will prevent this function being run again.

(1)  Continue to the main menu.

--- Type one of the keys in parentheses ---

Bash has this, too, via the bash-completion package.

4 Likes

Many of my colleagues used macOS where zsh is the default. I have a short list of customizations I do for every new linux install. One is to change my login shell to zsh using chsh (in a terminal) , then start a new terminal to do the Z Shell configuration function for new users.

1 Like

As noted, each shell has different features, and completion is usually one of them. Bash has bash-completion—packages provide completion files that tell bash how to predict the next tokens. Other shells also have this. There are also other customisations but perhaps they’re beyond the scope of this forum here—if you search for specific things you want to do, you’ll find lots of posts on how to do them.

For zsh, there’s also this:

(I still use bash so I’ve not used it, but I’ve run into it in lots of places)

None of this is gnome-terminal specific. That’s just a terminal emulator. You can run whatever shell you wish in any terminal emulator.

2 Likes

yes I have that package installed but i beleive it requires me to push tab each time.

I really like the way the zsh shell auto-types it and impliments it.

I could be wrong but bash doesn’t have that capability AFAIK.

great ! is there any documentation on that.

I wouldnt want to overide the ability to use bash, rather switch between them if there is such a way…

I dont seem to be able to find the packages/process to faciliate this and also have the predictive commands like in risios or ultramarine…

Shell scripts should start with a “shebang” line (most commonly #! /usr/bin/bash, #! /usr/bin/zsh, or #! /usr/bin/sh now that the legacy /bin/bash etc are just symbolic links to the actual programs in /usr/bin. You can stick with zsh when entering commands directly in a terminal, but write scripts that will run under other shells. For script I like to use dash, a much smaller shell:

% ls -l /usr/bin/dash /usr/bin/bash /usr/bin/zsh
-rwxr-xr-x. 1 root root 1443376 Jan 21 20:00 /usr/bin/bash
-rwxr-xr-x. 1 root root  133168 Aug  1  2023 /usr/bin/dash
-rwxr-xr-x. 1 root root  963944 Jan 16 20:00 /usr/bin/zsh

If you are interested in command-line tools, I recommend Linux Command because it has been around long enough that mistakes have been corrected (and not some AI generated fiction that has become to common). There you will find Other Shells.

2 Likes

Wanna give fish shell a try? (It’s in the repos). I am using it since many years and absolutely love the autocompletion. It feels as if it reads my mind…

See https://fishshell.com/

4 Likes

Yes, I’m not aware of bash having this particular capability. I see this post that refers to something that allows it in bash, but i think it replaces system bash with another built version (so I wouldnt suggest it unless you know what you’re doing in detail)

As also noted, this “suggestion” feature is actually from fish, and zsh users can enable it by using things like this:

You can’t switch between “different shell languages”, but you can just switch shells whenever you want. If you’re in bash and want to use zsh, just type zsh and that’ll start. To switch defaults, use chsh (man chsh for more information, or use your favourite search engine).

1 Like

There is an oh-my-zsh port to bash, FWIW:

Here’s the completions sections:

1 Like

If you look for something fast just do not forget fzf:

2 Likes

this is great thanks @ankursinha . I use a lot of macos unfortunaly so i wanted to try zsh on fedora to see if i can make my workflow faster with it…

BASH is really great though, just wish it had a bit more features.

its not quite clear to me how this works, is this a library to draw on, looks facinating. thanks @ilikelinux

I notice when I ran zsh, the command line changes it to a % symbol. doe that indicate it is running zsh and a $ indicate its running bash?

isaiah@fedora-office:~$ zsh
[isaiah@fedora-office]~% chsh
Changing shell for isaiah.
Password: 
New shell [/bin/bash]: 

On bash, you can change your “PS1”—the isaiah@fedora-office:~$ bit. I’m assuming it can be done on zsh too. So it’s possible the defaults are just different.

Try echo "$PS1" to see what you get. To see what shell you’re on, I think you can look at the $SHELL environment variable:

$ echo $SHELL
/bin/bash
1 Like

Normally $ indicates you are not root, # indicates you are root.

Btw there is a command to change your shell for Gnome Console/Terminal (whatever is the one actually used, GNOME…) and also a GUI way afaik, you change your default profile to launch /usr/bin/fish for example.

bash with completions should be the easiest, fish has its fancy own syntax that only works in fish, which is annoying, zsh is a mix and very customizable.

1 Like
What is fzf, asmal summary...

What is fzf?

In its most basic form, fzf works as a filter, processing text from standard input (stdin), then outputting a matching selection to standard output (stdout). In a way, fzf is similar to grep but it adds features that make it more suitable for interactive searches, including:

  • Fuzzy finding capabilities allow approximate searches by any part of the match in any order.
  • Super-fast processing speed
  • Interactive match selection lets the user select the desired match after initial filtering.
  • Single- or multi-text selection
  • File content previews
  • A comprehensive set of features and customization options

Due to these features, fzf is a fantastic option when you’re searching anything on the terminal, for scripts, and to develop pseudo user interfaces for command-line programs.

When I think about it, I am still in awe that I have access to such a fantastic tool from the open source community. I am grateful that Junegunn Choi and other contributors made it available for others to benefit.

2 Likes

In fairness, zsh is also not fully bash-compliant, either. It’s just closer than fish. While most very simple bash scripts should work in zsh, not all operations will, and there are also some zsh specific things that won’t work in bash (Such as =() for fd input redirection). Things should mostly work in zsh, but don’t be surprised if you’ll need to finesse a few things here and there from installer scripts, etc.

1 Like

@ilikelinux fzf Such a “POWERFUL” tool. :clap:t5:

2 Likes