Play around with your command shell, and you’ll be surprised at how much more productive it makes you, The Pragmatic Programmer
Unix shells are interactive interfaces that allow users to interact with the Operating System by executing commands and utilities. There are three main shells: bash, Zsh, and fish.
Some features: If you want to change directory, it is not necessary to enter the cd command (automatic cd), i.e. Documents instead of cd Documents and you don’t have to type whole directory names either, ls Dro/do/Ba(<Tab>) becomes Dropbox/docs/Basic. tree -<Tab> suggest a list of options for tree, with short descriptions, ls **/Linux.md performs a recursive search and returns Dropbox/docs/Linux.md
autoload -Uz compinit
compinit
`` `
- **Oh My Zsh**. It is a **delightful, open source, community-driven -somehow bloated- framework for managing your Zsh configuration**. It comes bundled with thousands of helpful functions, helpers, plugins, and themes:
``` bash
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
zsh-autosuggestions, is a fish-like fast and unobtrusive autosuggestions for zsh, a real time saver! Installation with Oh-my-zsh: Clone its repository into ~/.oh-my-zsh/custom/plugins…
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
… and add the plugin to the list of plugins for Oh My Zsh to load, nvim ~/.zshrc: plugins=(zsh-autosuggestions).
From now on, as you type a command, Zsh will make suggestions. If the suggestion is the one you are looking for, just press the → (arrow right) key to accept it.
zsh-syntax-highlighting. It provides syntax highlighting for the shell zsh.
Installation with a plugin manager (Oh-my-zsh). Clone its repository…
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
… and activate the plugin in ~/.zshrc:
plugins=( [plugins...] zsh-syntax-highlighting)
Search through history. Typically, you may want to use the history command or some variations, e.g., history | grep ssh, history | less, etc.
If you press the ↑ key, you could browse for any particular command you have used recently. Now, if you entered a command, e.g., grep, mkdir or ls, and then press the ↑ key, you could browse for the recent history where this particular order was used.
Navigate super fast using z. It tracks your most used and recently visited directories. It allows you to jump quickly to them by typing z followed by any word (fuzzy search) that is in your desired path, e.g., z Dropbox(<Tab>) becomes /home/nmaximo7/Dropbox, or z content(<Tab>) becomes /home/nmaximo7/JustToThePoint/content/.
Powerlevel10k is a theme for Zsh. It emphasizes speed, flexibility and out-of-the-box experience. Installation: (clone the repository, Powerlevel10k 1a). Check 1b ‼️. Set the name of the theme to load in .zshrc.
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
# The MANPAGER is the program that is used to read man pages. We can change it to be whatever we like so we can see colorful man pages.
# Set the zsh history file and size
HISTFILE="$HOME/.zsh_history"
HISTSIZE=10000
SAVEHIST=1000000
setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again.
HISTORY_IGNORE="(ls|cd|pwd|exit|history)" # Ignore some commands
export PATH=$HOME/bin:/usr/local/bin:$PATH
# Setting the default text editor
export EDITOR=/usr/bin/nvim
export VISUAL=/usr/bin/nvim
# Path to your oh-my-zsh installation.
export ZSH="/home/nmaximo7/.oh-my-zsh"
$PATH tells the shell which directories to search for executable files. We are going to add ~/local/bin (a good place to keep your shell scripts) and ~/AppImages (a good place where to keep you AppImages, linux apps that run anywhere) to our PATH.
if [ -d "$HOME/.local/bin" ] ;
# If the directory $HOME/.local/bin exists, add it to the path
then PATH="$HOME/.local/bin:$PATH"
fi
if [ -d "$HOME/AppImages" ] ;
# If the directory $HOME/AppImages exists, add it to the path.
then PATH="$HOME/AppImages:$PATH"
fi
# Set name of the theme to load, Powerlevel10k 1b ‼️
ZSH_THEME="powerlevel10k/powerlevel10k"
# Uncomment the following line to enable command auto-correction.
ENABLE_CORRECTION="true"
plugins=(git)
# chucknorris: Chuck Norris fortunes plugin for oh-my-zsh. It adds two commands: chuck and chuck_cow.
# colorize: it will syntax-highlight the content of a file based on the filename extension. Requirements: pip install Pygments. Use: ccat file, cless file
# emoji: Support for Unicode emoji. Use: echo $emoji[mouse_face]
# web-search. This plugin adds aliases for searching with Google, Wiki, Bing, YouTube and other popular services, e.g., google, bing, y ddg.
plugins=(git zsh-autosuggestions chucknorris colorize emoji z zsh-syntax-highlighting web-search)
# If you have themes like Powerlevel10k, then you need to source the oh-my-zsh config file after the theme variable assignment
source $ZSH/oh-my-zsh.sh
# .zsh_aliases is where all our aliases are going to be.
source ~/.zsh_aliases
# gpg-agent is a daemon to manage secret (private) keys independently from any protocol. It stores the GPG secret keys in memory, so you don't have to type your passphrase every single time you use your key.
export GPG_TTY=$(tty)
# https://github.com/hkbakke/bash-insulter, Bash and Zsh insulter. It randomly insults you when you type a wrong command. I know, I know, an absolute, no questions asked, must-have! Installation: 1. git clone https://github.com/hkbakke/bash-insulter.git bash-insulter, 2. sudo cp bash-insulter/src/bash.command-not-found /etc/
if [ -f /etc/bash.command-not-found ]; then
. /etc/bash.command-not-found
fi
# This is added by Powerlevel10k. To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
After editing the configuration file for Z shell, you need to either start a new shell instance or type: source ~/.zshrc to apply the changes you have just made. Next time, you could use the alias “szsh”.
Aliases are essentially shortcuts, a means of avoiding typing or remembering a long command sequence that you use often.
# My aliases
# Edit Zsh's configure file
alias ezsh="atom $HOME/.zshrc"
# Reload Zsh
alias reload='source ~/.zshrc'
# Find my IP address
alias myip='curl http://ipecho.net/plain; echo'
# Atom crashes upon launch, it works with --no-sandbox
alias atom='atom --no-sandbox'
# It selects a random fortune from my quotes collection.
alias fortune='fortune ~/.config/myquotes/quotes'
alias ll='ls -alF'
# Replace ls with exa
alias ls='exa --long --header --git'
# Replace cat with bat
alias cat='bat --style=plain'
If you want to know more about cat, exa, fzf, youtube-dl, and ripgrep, read our article Awesome command linux tools: bat, fzf, exa, ripgrep, youtube-dl.
# df -h reports file system disk usage with human-readable sizes.
alias df='df -h'
# free displays the total amount of free and used memory in the system in MB
alias free='free -m'
# This aliases help you to switch between shells
alias tobash="sudo chsh $USER -s /bin/bash && echo 'Now log out.'"
alias tozsh="sudo chsh $USER -s /bin/zsh && echo 'Now log out.'"
# Use: ytmp3 url. It downloads a YouTube video to the ~/Music folder.
ytmp3() { cd ~/Music; youtube-dl --extract-audio --audio-format mp3 "$@"; }
# Edit i3's configuration file
alias ei3='atom ~/.config/i3/config'
# Launch ferdi
alias ferdi='./AppImages/Ferdi-5.8.0.AppImage'
alias radio='curseradio'
# Preview and edit files using [fzf](/software/fzf-bat/)
alias preview="fzf --preview 'bat --style=numbers --color=always {}'"
searchEdit() { du -a ~/Dropbox/ ~/.config/ ~/.local/bin/ | awk '{print $2}' | fzf | xargs -r $EDITOR ; }
# Create a folder and move into it in one command
mkcd() { mkdir -p "$@" && cd "$_"; }
# Search quickly: googleit "What is the capital of France"
googleit() { xdg-open "http://google.com/search?q=$@"}
# Command-line calculations: calc "3*4"
calc() { bc -l <<< "$@" }
# Search inside files recursively in my Hugo's content folder
myripgrep() { rg "$@" ~/JustToThePoint/content/}
# Search inside files in my Hugo's content folder and in Google: myripgrep "ripgrep"
mysearch() { rg "$@" ~/JustToThePoint/content/; xdg-open "http://google.com/search?q=$@"}
# It converts the video (url specified as a parameter) to mp3 and saves it in the Music folder.
ytmp3() { cd ~/Music; youtube-dl --extract-audio --audio-format mp3 "$@"; }
# Play all music files from the Music directory
alias playmp3='cd ~/Music; nvlc *.mp3'
alias server="ssh -p '2222' 'yourUser@yourIpServer'"
# Convenient aliases for xclip, a command line clipboard manager
alias copy='xclip -selection clipboard'
alias paste='xclip -selection clipboard -o'
fish is a smart and user-friendly command line shell.
neofetch
# Aliases
alias efish 'vim ~/.config/fish/config.fish'
alias evim 'vim ~/.vimrc'
alias cat 'bat'
alias rfish 'source ~/.config/fish/config.fish'
alias tobash="sudo chsh $USER -s /bin/bash && echo 'Now log out.'"
function fish_greeting
fortune | cowsay
end
# PROMPT: https://fishshell.com/docs/current/cmds/fish_prompt.html
function fish_prompt -d "Write out the prompt"
# This shows up as USER@HOST /home/user/ >, with the directory colored
# $USER and $hostname are set by fish, so you can just use them
# instead of using `whoami` and `hostname`
printf '%s@%s %s%s%s > ' $USER $hostname \
(set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
end