Author: JackTian
Source: Public Account "Jake's IT Journey"
ID: Jake_Internet
Reprint please contact authorization (WeChat ID: Hc220088)
Original address: 14 alternatives to common command line tools!
Hello everyone, my name is Jack.
Under the Linux operating system, ls (list) can be said to be a command with high daily usage rate. It is mainly used to display the target list. The output information can be highlighted in color to partition different types of files. The syntax, options, examples, and extended knowledge of ls[^1] will not be introduced in detail here.
1. lsd
lsd[^2] is a Rust-based replacement for the ls command that adds colors, icons, tree views, more formatting options, and more. It can be installed on various operating systems such as Archlinux, Fedora, macOS, FreeBSD, Windows, Android, Ubuntu, Debian, etc.
# curl -LO https://github.com/Peltoche/lsd/releases/download/0.21.0/lsd_0.21.0_amd64.deb
# dpkg -i lsd_0.21.0_amd64.deb
2. broot
broot[^3] is also a Rust-based replacement for the ls command. Compared to lsd, it is a new way of viewing and navigating directory trees. It can also be understood that broot is the file manager in the terminal.
When it comes to terminal file managers, you can refer to: 4 super easy-to-use terminal file managers to improve your efficiency!
Features of broot:
- Get an overview of a directory, even a large one
- find a directory and cd
- The structure of the file hierarchy is never lost when searching
- Manipulate files, manage files, preview files
- Apply standard or personal shortcuts to files
- alternative to ls
- Sort to see space occupied
- Check Git status
Use of broot:
When using broot, you can first list the file information in the current directory.
# br -sdph
-s
: Display file size-d
: Display file time-p
: show file permissions-h
: show hidden files
As can be seen from the above results, broot expands subdirectories in a tree structure by default. In this interface, you can complete 搜索
(input search term), 复制
(cp <copy file name>), 删除 rm
, 更改文件名
(mv <new file name> ), 退出 q
basic file operations.
In addition, there is exa[^4] for the replacement of ls for reference: an open source replacement tool for ls you deserve!
3. Zoxide
zoxide[^5] is an alternative to the cd command, mainly used to switch the user's current working directory, zoxide is smarter than the cd command, it remembers the directory you use most often, so you only need to press a few Press the down button to "jump" to the specified directory.
zoxide can run on Linux, macOS, Windows, BSD, Android and other operating systems, and the usage is the same as cd.
# zoxide /etc
If you frequently use zoxide to go into the /etc directory, you can just write part of the path and it will automatically find a match you use frequently, just enter the command: z e
, and it will automatically e
match as /etc into that directory.
# z e
Four, fzf
fzf[^6] is a general-purpose interactive command-line fuzzy finder, convenient, dependency-free, and extremely fast for any list, file, command history, process, hostname, bookmark, git commit, etc. It can be installed on various Linux distributions such as Debian 9+, Ubuntu 19.10+, Fedora, Arch Linux, FreeBSD, OpenBSD, openSUSE, etc.
# curl -LO http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/fzf/fzf_0.24.3-1_amd64.deb
# dpkg -i fzf_0.24.3-1_amd64.deb
Using fzf can be combined with the alternative fd[^7] tool of find. About fd, we will not introduce it in detail here. You can refer to: 10 Alternative Tools in Linux Environment You Don't Know!
If you use fuzzy search to find out the file name containing debug, you can execute the following command and enter it debug
.
# find . -type f | fzf
5. ripgrep (rg)
ripgrep (rg)[^8] is a replacement for the grep command, it is a line-oriented search tool that recursively searches the current directory for regular expression patterns, supported on Windows, Linux and macOS.
The ripgrep GitHub repository also does stark benchmarking comparisons of the same files, single large files via ripgrep, git grep, ugrep, The Silver Searcher, ack, GNU grep. In terms of time, ripgrep's search time is the fastest.
Other than that, ripgrep has default filtering, fewer errors, Unicode support, with line numbers and search term highlighting.
# apt install ripgrep
ripgrep is similar to grep usage, for example: if I want to search for all sh files that contain the string yum, I can execute the following command:
# rg yum *.sh
9:cd /etc/yum.repos.d/
22:yum clean all
23:yum makecache
25:echo "本地yum仓库已经创建完成!"
In addition to grep and ripgrep, there are also ack and ag[^9] About ack and ag, we will not introduce them in detail here, but you can refer to: 10 Alternative Tools in Linux Environment You Don't Know!
6. procs
procs[^10] is a replacement for the ps command written in Rust language. It supports color highlighting, multi-column keyword search and other features to display process-related information. It can be installed on Linux, macOS, and Windows operating systems.
Installation of procs:
Arch Linux
# sudo pacman -S procs
Fedora
# sudo dnf install procs
RPM
# sudo rpm -i https://github.com/dalance/procs/releases/download/v0.12.1/procs-0.12.1-1.x86_64.rpm
Use procs to execute the following command, which will display information about all processes.
# procs
Use non-numeric/keywords to search, add any keyword as parameter option, it will automatically match USER to COMMAND by default, add columns that match non-numeric keywords, nonnumeric_search
you can use options in the configuration file.
Search using numbers as keywords, default matches PID
, by default, numeric values are treated as exact matches, non-numeric values are treated as partial matches, add a column that matches numeric keywords, numeric_search
options can be used in the configuration file.
If there are some keywords, logical operations between keywords can be specified through command line options.
--and
: show processes matching all keywords--or
: show processes matching any keyword--nand
: These procedures will be displayed unless they match all keywords--nor
: Processes will be displayed unless they match any keyword
More can refer to: 7 tools that can replace the top command! and 11 alternatives to the top command!
七、diff-so-fancy
diff-so-fancy[^11] is an alternative to git diff, it is a command line tool based on node, which can present beautiful diffs to your terminal, help improve code quality and help find bugs faster .
Installation of diff-so-fancy:
# npm install -g diff-so-fancy
Use of diff-so-fancy:
Can be called directly from the command line
# git diff --color | diff-so-fancy
Using diff-so-fancy in the above way is simple, but it will output all the results without any difference. We can configure git to diff-so-fancy for all diff output by setting the pager to paginate the results:
# git config --global core.pager " diff-so-fancy | less --tabs=4 -RFX "
# git config --global interactive.diffFilter " diff-so-fancy --patch "
Just configure diff-so-fancy as Git's default diff tool. Every time you execute git diff, its execution result will be output.
Eight, delta
delta[^12] is a syntax highlighting pager for git, diff, and grep output, which allows numerous changes to the layout and styling of diffs.
Characteristics of delta:
- Use color themes to highlight language syntax
- Syntax highlighting grep output from rg, git grep, grep, etc.
- Side by side view with wrapping
- Support display line number
- Support merge conflict display
- Support for Git's --color-moved feature
- n and N keybindings to move between files in large diffs
- Code can be copied directly from the diff
Installation of delta:
delta supports installation on Arch Linux, Fedora, FreeBSD, OpenSUSE, Debian / Ubuntu, Windows and other operating systems. For details, please refer to the installation section of the delta[^13] user manual.
9. mcfly
Mcfly[^14] is ctrl+r
a replacement, mainly used to search shell operation records.
Features of mcfly:
- Bind
ctrl+r
to start full screen reverse history search - Written in Rust, fast and safe
- Type
%
to match any number of characters when searching - Maintain normal shell history files so that McFly can be discontinued at any time
- Support for clearing any historical items from the McFly database and Shell history files
Ten, choose
choose[^15] is an alternative to the cut[^16] command, which is used to display the specified part of the line and delete the specified field in the file. cut is often used to display the contents of a file, similar to the type command.
Features of choose:
- Concise fields, simple syntax, Python-like list slicing
- Negative indices start at the end of the line
- optional start/end index
- zero index
- reverse range
- For long enough input, slightly faster than
cut
, much faster thanawk
- Regular expression field separator using Rust's regular expression syntax
Case writing of cut:
# cat 2022.txt | cut -d " " -f 1
or
# cut -d " " -f 1 2022.txt
The case of choose is written:
# cat 2022.txt | choose 1
or
# choose 1 -i 2022.txt
Eleven, httpie
httpie[^17] is an alternative to curl, a command-line HTTP client. The goal of httpie is to make CLI interaction with web services as user-friendly as possible, for testing, debugging, and generally interacting with APIs and HTTP servers, allowing http and https commands to create and send arbitrary HTTP requests, using a simple syntax, and Ability to provide formatted and colored output.
Curl PUT request case writing:
# curl -X PUT -d hello=world example.com
httpie PUT request case writing:
# http PUT example.com hello=world
Custom HTTP methods, HTTP headers and JSON data:
# http PUT pie.dev/put X-API-Token:123 name=John
Build and print requests without sending in offline mode:
# http --offline pie.dev/post hello=offline
12. curlie
curlie[^18] is the same project as httpie. curlie increases the ease of use of httpie without affecting its features and performance. The syntax and output format of all curl options come from httpie. Like the characteristics of curl, that curlie is the best choice.
The difference between curlie and httpie:
- curlie is like curl, but unlike httpie, the file header is written to stderr, not stdout;
- The output is not buffered, all formatting is done dynamically, and the streaming data can be easily debugged;
- Use the curl option to print the executed curl command;
Syntax of curlie:
# curlie [CURL_OPTIONS...] [METHOD] URL [ITEM [ITEM]]
Simple acquisition of curlie:
# curlie httpbin.org/headers
Custom methods, headers and JSON data:
# curlie -v PUT httpbin.org/status/201 X-API-Token:123 name=John
Thirteen, xh
xh[^19] is a friendly and fast tool for sending HTTP requests, mainly improved performance compared to httpie, available as a single statically linked binary, easy to install, supports HTTP/2, uses curl Flags built-in conversions to curl commands, short help messages can be output in cheat sheet style.
Syntax of xh:
# xh [OPTIONS] <[METHOD] URL> [--] [REQUEST_ITEM]...
Example of xh:
# 发送 GET 请求
xh httpbin.org/json
# 发送一个 POST 请求,请求体{"name": "ahmed", "age": 24}
xh httpbin.org/post name=ahmed age:=24
# 发送一个 querystring id=5 & sort=true 的 GET 请求
xh get httpbin.org/json id==5 sort==true
# 发送一个 GET 请求,并包含一个名为 x-api-key 的头,值为:66666
xh get httpbin.org/json x-api-key:66666
# 发送一个 PUT 请求,并将结果管道到 less
xh put httpbin.org/put id:=49 age:=24 | less
# 下载并保存到 test.json
xh -d httpbin.org/json -o test.json
# 请求与自定义用户代理
xh httpbin.org/get user-agent:foobar
Fourteen, dog
dog[^20] is a command-line open source DNS client, a replacement for the dig command, with colorful output, understands command-line parameter syntax, supports UDP, TCP, DNS-over-TLS and DNS-over-HTTPS protocols network transport and can issue DNS queries.
dog can run on Windows, MacOS and Linux operating systems and supports 16 record types including: A, AAAA, CAA, CNAME, HINFO, LOC, MX, NAPTR, NS, OPT, PTR, SOA, SRV, SSHFP, TLSA and TXT.
Example of dog:
# 使用默认设置查询域
dog example.net
# 查看 MX 记录
dog example.net MX
# 使用特定的命名服务器
dog example.net MX @IP地址 x.x.x.x
# 使用 TCP 而不是 UDP
dog example.net MX @IP地址 x.x.x.x -T
For more information on dog installation, query options, sending options, protocol options, and output options, please refer to the dog documentation.
References
[1] ls:https://wangchujiang.com/linux-command/c/ls.html
[2] lsd:https://github.com/Peltoche/lsd
[3] broot:https://github.com/Canop/broot
[4] exa:https://github.com/ogham/exa
[5] zoxide:https://github.com/ajeetdsouza/zoxide
[6] fzf:https://github.com/junegunn/fzf
[7] fd:https://github.com/sharkdp/fd/
[8] ripgrep (rg):https://github.com/BurntSushi/ripgrep
[9] ag:https://github.com/ggreer/the_silver_searcher
[10] procs:https://github.com/dalance/procs
[11] diff-so-fancy:https://github.com/so-fancy/diff-so-fancy
[12] delta:https://github.com/dandavison/delta
[13] delta:https://dandavison.github.io/delta/installation.html
[14] mcfly:https://github.com/cantino/mcfly
[15] choose:https://github.com/theryangeary/choose
[16] cut:https://wangchujiang.com/linux-command/c/cut.html
[17] httpie:https://github.com/httpie/httpie
[18] curlie:https://github.com/rs/curlie
[19] xh:https://github.com/ducaale/xh
[20] dog:https://github.com/ogham/dog
Recommended reading:
- 10 Linux alternatives you didn't know about
- 5 Alternatives to the du Command
- Running Linux online is really cool.
- 11 Alternatives to the top Command
- 7 Alternatives to the top Command
That's all for today.
If you think this article is useful to you , please let more friends see it for this article 点个赞
, 留个言
or read it, because this will be the strongest motivation for me to continue to output more high-quality articles!转发