# Linux
wget https://github.com/sharkdp/bat/releases/download/v0.6.1/bat-v0.6.1-x86_64-unknown-linux-gnu.tar.gz
make install
# Mac
brew install bat
#
alias cat='bat'
在终端中使用 ctrl + r 组合键可以向后搜索历史操作记录( 尽管有点繁琐 )。fzf 工具是对 ctrl + r 的增强。支持对终端操作历史的模糊搜索, 预览可能的匹配结果。除了历史搜索之外, fzf 还可以预览和打开文件。 更多信息:https://github.com/junegunn/fzf
# Linux
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
# Mac
brew install fzf
# alias
alias preview="fzf --preview 'bat --color \"always\" {}'"
# add support for ctrl+o to open selected file in VS Code
export FZF_DEFAULT_OPTS="--bind='ctrl-o:execute(code {})+abor
htop > top
top 是一个快速诊断系统性能的工具。值得一提的是 top for Mac 与 Linux 上的输出不太一样。htop 优化了顶部输出格式,并支持大量的颜色, 键盘快键键和视图, 帮助我们洞察进程行为。更多信息:http://hisham.hm/htop/
了解磁盘空间占用情况是一项非常重要的工作。常用的命令是 du -sh (-sh 表示摘要、便于人工阅读), 但我们经常需要挖掘目录的空间占用。ncdu 是一个替代选择(完全基于 C 语言编写,MIT 许可证)。ncdu 提供了一个交互式界面, 支持快速扫描哪些文件夹或文件占用空间, 并且导航非常方便。更多信息:https://dev.yorhel.nl/ncdu
git clone git://g.blicky.net/ncdu.git/
# release
wget https://dev.yorhel.nl/download/ncdu-1.13.tar.gz
tar -xvf ncdu-1.13.tar.gz
./configure
make
make install
# Usage
ncdu path
alias du="ncdu --color dark -rr -x --exclude .git --exclude node_modules"
# 扩展选项
--color dark - use a colour scheme
-rr - read-only mode (prevents delete and spawn shell)
--exclude ignore directories I won't do anything about
tldr > man
几乎每一个命令行工具都可以通过手工输入 man 命令获得帮助信息。TL;DR 项目("too long; didn't read")是一个由社区驱动的命令行文档系统,以非常简洁的方式提供命令行参数列表、使用说明和示例。更多信息:https://tldr.sh/
# Install
npm install -g tldr
alias help='tldr'
# Usage
Options:
-V, --version output the version number
-l, --list List all commands for the chosen platform in the cache
-a, --list-all List all commands in the cache
-1, --single-column List single command per line (use with options -l or -a)
-r, --random Show a random command
-e, --random-example Show a random example
-f, --render [file] Render a specific markdown [file]
-m, --markdown Output in markdown format
-o, --os [type] Override the operating system [linux, osx, sunos]
--linux Override the operating system with Linux
--osx Override the operating system with OSX
--sunos Override the operating system with SunOS
-t, --theme [theme] Color theme (simple, base16, ocean)
-s, --search [keywords] Search pages using keywords
-u, --update Update the local cache
-c, --clear-cache Clear the local cache
-h, --help output usage information
# Example
bash-3.2$ tldr tar
✔ Page not found. Updating cache
✔ Creating index
tar
Archiving utility.
Often combined with a compression method, such as gzip or bzip.
- Create an archive from files:
tar cf target.tar file1 file2 file3
- Create a gzipped archive:
tar czf target.tar.gz file1 file2 file3
- Extract an archive in a target folder:
tar xf source.tar -C folder