Skip to content

Instantly share code, notes, and snippets.

@Starraider
Last active July 30, 2022 03:27
Show Gist options
  • Save Starraider/91454d8c728fbd2bdc12c901153e92d7 to your computer and use it in GitHub Desktop.
Save Starraider/91454d8c728fbd2bdc12c901153e92d7 to your computer and use it in GitHub Desktop.
Best Command-Line Tools

Modern Command-Line Tools

micro

micro is an editor for the command line, which is less complicated then vi(m)/emacs, but has more features then nano. It's somewhere in between.

Homepage

nnn

nnn is very good terminal file manager.

nnn on GitHub

fd

fd is a fast and user-friendly alternative to find, with colorized output and easy syntax. By default it searches case insensitive, unless you use capital letters in your PATTERN.

USAGE:

fd [FLAGS/OPTIONS] [<pattern>] [<path>...]

FLAGS:

-H, --hidden            Search hidden files and directories
-I, --no-ignore         Do not respect .(git|fd)ignore files
-s, --case-sensitive    Case-sensitive search (default: smart case)
-i, --ignore-case       Case-insensitive search (default: smart case)
-g, --glob              Glob-based search with * and ? Use '' (default: regular expression)
-a, --absolute-path     Show absolute instead of relative paths
-l, --list-details      Use a long listing format with file metadata
-L, --follow            Follow symbolic links  
-p, --full-path         Search full path (default: file-/dirname only)  
-h, --help              Prints help information  
-V, --version           Prints version information  

OPTIONS:

-d, --max-depth <depth>            Set maximum search depth (default: none)  
-t, --type <filetype>...           Filter by type: file (f), directory (d), symlink (l),  
                                   executable (x), empty (e), socket (s), pipe (p)  
-e, --extension <ext>...           Filter by file extension  
-x, --exec <cmd>                   Execute a command for each search result  
-X, --exec-batch <cmd>             Execute a command with all search results at once  
-S, --size <size>...               Limit results based on the size of files.  
    --changed-within <date|dur>    Filter by file modification time (newer than)  
    --changed-before <date|dur>    Filter by file modification time (older than)  

ARGS:

<pattern>    the search pattern - a regular expression unless '--glob' is used (optional)
<path>...    the root directory for the filesystem search (optional)

TIPPS:

If fd is used with no arguments, it will show all files/folders in the current folder.

You can delete files that matches the PATTERN by using -X rm

fd -e jpg -X rm     (deletes all jpg files)
fd -HI -g "* 2.php" -X rm

fd on GitHub

exa

exa is a modern replacement for ls or dir.

OPTIONS:

-R, --recurse:              recurse into directories
-T, --tree:                 recurse into directories as a tree
-L, --level=(depth):        limit the depth of recursion
-r, --reverse:              reverse the sort order
-D, --only-dirs:            list only directories
--git-ignore:               ignore files mentioned in .gitignore
-I, --ignore-glob=(globs):  glob patterns (*,?) (pipe-separated) of files to ignore

bash integration

I created an alias for dir as exa list view and for ls as exa grid view in my '~/.zshrc' file:

alias dir="exa --header --long --all --git --group --icons -F --group-directories-first --color-scale -I .git"  
alias ls="exa --all --icons -F --group-directories-first -I .git"

exa on GitHub

zoxide (z)

zoxide on GitHub

rclone

rclone syncs your files to cloud storage.

rclone Website

dust

dust is a modern version of du for showing disk usage.

USAGE:

dust
dust <dir>
dust -d 3  <dir>        (shows 3 levels of subdirectories)
dust -p <dir>           (full-path - does not shorten the path of the subdirectories)
dust -s <dir>           (apparent-size - shows the length of the file as opposed to the amount of disk space it uses)
dust -n 30  <dir>       (shows 30 directories instead of the default)
dust -r  <dir>          (reverse order of output, with root at the lowest)
dust -X ignore  <dir>   (ignore all files and directories with the name 'ignore')
dust -b <dir>           (do not show percentages or draw ASCII bars)

dust on GitHub

ncdu

ncdu is a modern and interactive version of du for showing disk usage.

ncdu Website

procs

procs is a modern replacement for ps

OPTIONS:

--watch        Watch mode
--tree          Tree view
--sortd cpu     Sort column

Press Q to quit.

procs on GitHub

htop

htop is an alternative to top for displaying information about processes.

Installation:

brew install htop

htop

lf

lf (as in "list files") is a terminal file manager.

Key bindings:

<arrow keys>            Move around  
<q>                     Quit  
<h>                     Move to parent folder  
<l>                     Open file or folder  
<fn + arrow up/down>    Move one page up/down  
<gg>                    Go to top of the list  
<G>                     Go to bottom of the list  
<space>                 Toggle selection  
<y>                     Copy current file or selections  
<d>                     Cut current file or selections  
<p>                     Paste current file or selections  
<c>                     clears copied or cut files  
<r>                     Rename file or folder
<:>                     Start a builtin or custom command  
<$>                     Runs a command in the shell  
<%>                     Runs a command in the shell while piping the input from the ui and output to the ui  
<&>                     Runs a command in the background  
</>                     Search a pattern  
<?>                     Search in the opposite direction  
<n>                     Search next  
<N>                     Search previous
<z..>                   Toggle some settings
<zh>                    Toggle showing of hidden files
<s..>                   Toggle sorting
<e>                     Launch an editor with the selected file
<i>                     Launch an pager with the selected file
<w>                     Launch a shell at the current folder (leave with exit)

Video about lf

lf on GitHub

broot (br)

br offers a better way to navigate directories.

broot on GitHub

fzf

fzf is a command-line fuzzy finder.

SEARCH SYNTAX:

fzf blabla              Fuzzy search
fzf blabla jpg$         And search
fzf 'blabla             Exact-match 
fzf ^blabla             Prefix-exact-match
fzf blabla$             Suffix-exact-match
fzf !(')blabla($)       Negation

OPTIONS:

-e                      Exact-match all search words
+i                      Case-sensitive match (default Smart)
-m                      Enable multi select (with Tab / Shift+Tab)

COMMANDS:

<ctrl>c or <esc>    Abort search
<enter>             Accept
<cmd>R              Open search history

INTEGRATIONS:

cd <tab>
ssh **<tab>
nvim **<tab>

Integrate fzf into cd

fzf on GitHub

bat

bat is a cat clone with syntax highlighting and Git integration.

bat on GitHub

grex

grex is a tool for generating regular expressions from user-provided test cases.

grex on GitHub

m-cli

Control your MacOS on the command line.

COMMANDS:

m : Display all commands
m <COMMAND> : Display all Options for the command

EXAMPLES:

m finder
m finder showhiddenfiles YES

m-cli on GitHub

shallow-backup

shallow-backup lets you easily create lightweight backups of installed packages, applications, fonts and dotfiles, and automatically push them to a remote Git repository.

shallow-backup on GitHub

rmlint

rmlint lets you find dublicate files and empty folders, so you can delete them.

rmlint on GitHub

More great Apps you can find here: awesome-mac

lf

lf is a terminal file manager.

GitHub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment