Linux-Bash-Commands/alternatives for history|find|cd.md

6.2 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-get install hstr -y && hstr --show-configuration >> ~/.bashrc

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-get install fd-find -y && sudo apt-get 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

A faster way to move around directories

commacd

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

There are many more alternative tools available that may fit your needs