:godmode: Ultimate list of Linux bash commands
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

7.6 KiB

The most commonly used commands when navigating are history, find, cd. Here are some examples of simple alternative tools that does a better job.

Easily view, navigate, search history commands

htsr
hts
Install :

sudo apt install hstr -y && hstr --show-configuration >> ~/.bashrc

Restart terminal

Note - Other installation info - github.com/dvorka/hstr/blob/master/INSTALLATION.md

Usage :

hstr keyword

Interactive searching🔎 : Ctrl+R

Note - More info on usage :

man hstr

A simple and userfriendly way to find files

fd and fzf

Install :

sudo apt install fd-find -y && sudo apt install fzf -y  

Add binary link(set correct bin directory location if error) :

ln -s $(which fdfind) ~/.local/bin/fd

Restart terminal

Note - Other installation info :
github.com/sharkdp/fd#installation
github.com/junegunn/fzf#installation)

Usage :

Command Description
fd foo Find in current directory, the string pattern name "foo", in parent|sub directories and files.
fd foo /FOO2 Find in "FOO2" directory, the string pattern name "foo", in parent|sub directories and files.
fd -g|--glob foo /FOO2 Find in "FOO2" directory, the glob pattern name matching "foo", in parent|sub directories and files.
fd /foo -p|--path /FOO2 Find in "FOO2" directory and view the files and directory paths and its contents that is or starts with the string pattern name "foo".
fd foo/ -p|--path /FOO2 Find in "FOO2" directory and view the directory paths and its contents that is or ends with the string pattern name "foo".
fd -t|--type -d foo Find for directory type only.
fd -t|--type -f foo Find for file type only.
fd -t|--type d -t|--type e foo Find for empty directories only.
fd -a|--absolute-path foo Find in current directory showing the full path, the string name "foo", in parent|sub directories and files.
fd -e|--extension txt Find for a particular file extension.
fd -H|--hidden foo Find for hidden and ignored files.

fzf interactive searching🔎 : Ctrl+T

Note - More info on usage :

man fd
man fzf

Smarter directory navigating

commacd

A faster way to move around

Install :

curl -sSL https://github.com/shyiko/commacd/raw/v1.0.0/commacd.sh -o ~/.commacd.sh && \
  echo "source ~/.commacd.sh" >> ~/.bashrc

commacd exports three commands: forward(,) │ backward(,,) │ backward+forward(,,,)

Usage :

Description commacd command
Enter directories using , des
abbreviations. └─> cd Desktop
Description commacd command
Move through multiple directories , u/l/ce
using abbreviations. └─> cd /usr/local/Cellar
Description commacd options
Choose directories with names , d
starting with same letter. 0 Desktop
(= multiple choices) 1 Documents
0, 1 or 2 2 Downloads
Description commacd command
Given two directories jdk7 and jdk8 , ~/d/j*8
on the Desktop, cd into jdk8 without hitting └─> cd ~/Desktop/jdk8
interactive mode (the one shown above).
Description commacd
Go back previous directory ,, ..

Tab = Autocomplete

Note - More info on usage :

shyiko.com/commacd

zoxide

It remembers which directories you use most frequently, so you can "jump" to them in just a few keystrokes.

Install :

sudo apt install zoxide

Open ~/.bashrc and add

eval "$(zoxide init bash)"

Restart terminal

Note - Other installation info - github.com/ajeetdsouza/zoxide#installation

Usage :

z foo              # cd into highest ranked directory matching foo
z foo bar          # cd into highest ranked directory matching foo and bar
z foo /            # cd into a subdirectory starting with foo

z ~/foo            # z also works like a regular cd command
z foo/             # cd into relative path
z ..               # cd one level up
z -                # cd into previous directory

zi foo             # cd with interactive selection (using fzf)

z foo<SPACE><TAB>  # show interactive completions (zoxide v0.8.0+, bash 4.4+/fish/zsh only)

Note - More info on usage :

Algorithm matching


[!NOTE] There are more alternative tools available out there that may better fit your needs.
Check out Modern Unix - A collection of modern/faster/saner alternatives to common unix commands.