This article shows you how to set up some powerful tools in your command line interpreter (CLI) shell on Fedora. If you use bash (the default) or zsh, Fedora lets you easily setup these tools.
Requirements
Some installed packages are required. On Workstation, run the following command:
sudo dnf install git wget curl ruby ruby-devel zsh util-linux-user redhat-rpm-config gcc gcc-c++ make
On Silverblue run:
sudo rpm-ostree install git wget curl ruby ruby-devel zsh util-linux-user redhat-rpm-config gcc gcc-c++ make
Note: On Silverblue you need to restart before proceeding.
Fonts
You can give your terminal a new look by installing new fonts. Why not fonts that display characters and icons together?
Nerd-Fonts
Open a new terminal and type the following commands:
git clone --depth=1 https://github.com/ryanoasis/nerd-fonts ~/.nerd-fonts cd .nerd-fonts sudo ./install.sh
Awesome-Fonts
On Workstation, install using the following command:
sudo dnf install fontawesome-fonts
On Silverblue, type:
sudo rpm-ostree install fontawesome-fonts
Powerline
Powerline is a statusline plugin for vim, and provides statuslines and prompts for several other applications, including bash, zsh, tmus, i3, Awesome, IPython and Qtile. You can find more information about powerline on the official documentation site.
Installation
To install powerline utility on Fedora Workstation, open a new terminal and run:
sudo dnf install powerline vim-powerline tmux-powerline powerline-fonts
On Silverblue, the command changes to:
sudo rpm-ostree install powerline vim-powerline tmux-powerline powerline-fonts
Note: On Silverblue, before proceeding you need restart.
Activating powerline
To make the powerline active by default, place the code below at the end of your ~/.bashrc file
if [ -f `which powerline-daemon` ]; then powerline-daemon -q POWERLINE_BASH_CONTINUATION=1 POWERLINE_BASH_SELECT=1 . /usr/share/powerline/bash/powerline.sh fi
Finally, close the terminal and open a new one. It will look like this:
Oh-My-Zsh
Oh-My-Zsh is a framework for managing your Zsh configuration. It comes bundled with helpful functions, plugins, and themes. To learn how set Zsh as your default shell this article.
Installation
Type this in the terminal:
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
Alternatively, you can type this:
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
At the end, you see the terminal like this:
Congratulations, Oh-my-zsh is installed.
Themes
Once installed, you can select your theme. I prefer to use the Powerlevel10k. One advantage is that it is 100 times faster than powerlevel9k theme. To install run this line:
git clone https://github.com/romkatv/powerlevel10k.git ~/.oh-my-zsh/themes/powerlevel10k
And set ZSH_THEME in your ~/.zshrc file
ZSH_THEME=powerlevel10k/powerlevel10k
Close the terminal. When you open the terminal again, the Powerlevel10k configuration wizard will ask you a few questions to configure your prompt properly.
After finish Powerline10k configuration wizard, your prompt will look like this:
If you don’t like it. You can run the powerline10k wizard any time with the command p10k configure.
Enable plug-ins
Plug-ins are stored in .oh-my-zsh/plugins folder. You can visit this site for more information. To activate a plug-in, you need edit your ~/.zshrc file. Install plug-ins means that you are going create a series of aliases or shortcuts that execute a specific function.
For example, to enable the firewalld and git plugins, first edit ~/.zshrc:
plugins=(firewalld git)
Note: use a blank space to separate the plug-ins names list.
Then reload the configuration
source ~/.zshrc
To see the created aliases, use the command:
alias | grep firewall
Additional configuration
I suggest the install syntax-highlighting and syntax-autosuggestions plug-ins.
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
Add them to your plug-ins list in your file ~/.zshrc
plugins=( [plugins...] zsh-syntax-highlighting zsh-autosuggestions)
Reload the configuration
source ~/.zshrc
See the results:
Colored folders and icons
Colorls is a Ruby gem that beautifies the terminal’s ls command, with colors and font-awesome icons. You can visit the official site for more information.
Because it’s a ruby gem, just follow this simple step:
sudo gem install colorls
To keep up to date, just do:
sudo gem update colorls
To prevent type colorls everytime you can make aliases in your ~/.bashrc or ~/.zshrc.
alias ll='colorls -lA --sd --gs --group-directories-first' alias ls='colorls --group-directories-first'
Also, you can enable tab completion for colorls flags, just entering following line at end of your shell configuration:
source $(dirname $(gem which colorls))/tab_complete.sh
Reload it and see what it happens:
Richzendy
Oh, thanks, i’m trying Powerline, how sysadmin it’s time to move a new and powerfull shell because i use a lot of time the CLI.
You forget “install” on the:
sudo dnf fontawesome-fonts
Paul W. Frields
Thanks! Fixed.
anonymous
A faster alternative to colorls is lsd (ls deluxe).
https://github.com/Peltoche/lsd
https://src.fedoraproject.org/rpms/rust-lsd
https://crates.io/crates/lsd#benchmark
Daniel
A few suggestions for this article.
You don’t need to install git, wget or curl on SIlverblue, it ships with them.
Also, instead of util-linux-user, you can just use usermod
usermod -s /usr/bin/zsh $USER
ruby-devel will pull in ruby, so it doesn’t need to be explicitly mentioned, if you want to keep your installed packages list small on Silverblue.
Carlos
You should take a look at Starship
https://github.com/starship/starship
jugmac00
I ditched PowerLine for starship and it was a good decision 🙂
ensbro
Wow, a lot to cover on this weekend \o/ Thanks
P.S. i believe awesome fonts installation snippet is missing install, e.g.:
sudo dnf install fontawesome-fonts
Seirdy
ZSH users might appreciate powerlevel10k0 for its faster startup speed thanks in part to its new “instant prompt”1 feature and its ultrafast reimplementation of git status. A brand-new transient prompt feature was described in a Reddit post[2] that allows a persistent fancy prompt at the bottom of the terminal, underneath historical commands with minimal prompts.
Lyes Saadi
You dont need to use sudo to install something with rpm-ostree ;).
Skavoovie
Warning: The Nerd Fonts GitHub repo is more than 6 GiB in size. o_O
Alex
Yes, they say it loud in clearly on their github page:
”
* Important Notices
master branch file paths are not considered stable. Verify your repository URI references
cloning this repository is not recommended (due to Repo size) unless you are going to be contributing to development
”
So the advice given out here to thousands of users is in two ways fatally wrong. Please do some proof reading before publishing.
Paul W. Frields
I have yet to hear about anyone or their system dying from a large download. Whether you download the git branch or the collection of all fonts, it will be really large.
dmaphy
Hint: Adding a --depth=1 to the git clone command reduces the 6GiB to 1.06 GiB in size, which is still a lot for slow internet connections, but significantly less than 6…
I didn’t get why there doesn’t seem to be a release tarball though.
Paul W. Frields
@dmaphy: This is a great hint, adding to the article. There is a release tarball on the releases page, and it’s 2.1 GB in size.
Nano
this is write of this way,
source $(dirname ($gem which colorls))/tab_complete.sh
but the correct is
source $(dirname $(gem which colorls))/tab_complete.sh
Paul W. Frields
Fixed, thanks!
iysheng
when input sth like
$ ls *.c
 data_base.c
 gpsS1216F8.c
i got some confused output?how could slove this matter?
P
In Silverblue you should keep rpm-ostree as a last resort. You can use the same commands you used for Workstation in a toolbox, so you don’t mess with the Silverblue image, don’t need to restart and make your life complicated ever time you install an OS update.
Mark
Is there a “gitstatusd-linux-ppc64le” available?
Mark Walker
I recently upgraded to Fedora 31, and then saw this article. After using dnf (and the git script) to install the nerd-fonts, fontawesome-fonts and powerline packages, I liked these enough to install them on my other Linux machines. The background contrast and full path current directory indication in the new Bash prompt are especially helpful for readability and awareness. Nicely done.
Harshal Purohit
Thanks a lot! Took me some time to get it working but looks great!
Two suggestions for the above article:
After doing this step:
ZSH_THEME=powerlevel10k/powerlevel10k
I needed to log out of my session & re-login to see the changes
Add a newline between the 2 commands below:
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
Thomas
For nerd-fonts they do not recommend cloning. There are severals alternative installation methods explained on their repo:
https://github.com/ryanoasis/nerd-fonts#font-installation
smeg
Are any of these compatible with Guake?
william
just a warning: Nerd-Fonts repository consumes 9.60 GB of disk.
Daniel
Please consider modifying the pattern
to $(command -v app).
1. $() is recommended by bash hackers wiki due to nesting issues with backticks.
https://wiki.bash-hackers.org/syntax/expansion/cmdsubst
3. ‘command -v’ is recommended over ‘which’ due to possible conflicts between what is on $PATH vs. any alias or builtins with the same name.
https://unix.stackexchange.com/questions/85249/why-not-use-which-what-to-use-then
xzj8b3 76
sudo gem install colorls
Building native extensions. This could take a while…
ERROR: Error installing colorls:
ERROR: Failed to build gem native extension.
/usr/bin/ruby -I /usr/share/rubygems -r ./siteconf20191112-13696-vliclc.rb extconf.rb
mkmf.rb can’t find header files for ruby at /usr/share/include/ruby.h