首页 > 系统相关 >linux_命令行助手:(manpages supplement)/获取linux命令用法示例的若干辅助命令行工具(cheat/tldr)

linux_命令行助手:(manpages supplement)/获取linux命令用法示例的若干辅助命令行工具(cheat/tldr)

时间:2022-11-15 13:32:52浏览次数:76  
标签:cheatsheets 示例 cheat community python 命令行 linux config


文章目录

  • ​​linux_命令行助手:(manpages supplement)/获取linux命令用法示例的若干辅助命令行工具(cheat/tldr)​​
  • ​​references​​
  • ​​我的推荐​​
  • ​​ltdr(python pip/nodejs based)​​
  • ​​ltdr工具介绍​​
  • ​​获取帮助​​
  • ​​在线版tldr​​
  • ​​安装一个本地版本​​
  • ​​manly(python based)​​
  • ​​bropages(gem&ruby based)​​
  • ​​#ruby 环境安装​​
  • ​​#安装gem+bropages​​
  • ​​使用​​
  • ​​获取帮助​​
  • ​​查询某个命令​​
  • ​​示例:bro top​​
  • ​​cheat(dependent/go based/python pip based)​​
  • ​​install from github release​​
  • ​​cheat 脚本化安装(预备:获取cheat包)​​
  • ​​reference(optional)​​
  • ​​正式安装​​
  • ​​目录结构(~/.config/cheat为树的根节点)​​
  • ​​cheat 原生安装​​
  • ​​eg(by python)​​

linux_命令行助手:(manpages supplement)/获取linux命令用法示例的若干辅助命令行工具(cheat/tldr)

references

  • linux下如果有多个版本的python3,容易出现各种,问题,可以通过这个链接排查/解决问题

本文介绍的工具有些需要使用python pip 来安装,故在此一提.

我的推荐

  • tldr
  • 该工具有许多版本的实现
  • npm版的安装简单,反应速度稍慢
  • 自动更新缓存
  • Rust版,安装时占用许多资源,但是使用的时候性能好,有色彩
  • 又叫​​tealdeer​
  • 需要手动更新缓存
  • 可以取别名简化命令(下方查询双中括号的用法)
  • 其中python版的不太稳定
  • ​eg​​(by python)

ltdr(python pip/nodejs based)

ltdr工具介绍

  • too long don’t read(tldr)

Simplified and community-driven man pages

获取帮助

┌─[cxxu@cxxuAli] - [~] - [2022-04-11 02:08:13]
└─[0] <> tldr -h
- Usage: tldr command [options]
Simplified and community-driven man pages...

在线版tldr

安装一个本地版本

  • 环境预备:安装/配置nodejs&npm
  • ​npm -g install tldr​
  • python 下也有相应的tldr

manly(python based)

  • 解释您的命令所带的选项
  • 类似工具还有​​explainshells​
  • 还有在线网站
┌─[cxxu@cxxuAli] - [~/.local/lib/python3.8/site-packages] - [2022-04-11 02:27:24]
└─[0] <> manly -h
usage: manly [-h] [-v] ...

Explain how FLAGS modify a COMMAND's behaviour.

positional arguments:
command

optional arguments:
-h, --help show this help message and exit
-v, --version display version information and exit.
# 例子
example:
$ manly rm --preserve-root -rf

rm - remove files or directories
================================

-f, --force
ignore nonexistent files and arguments, never prompt

--preserve-root
do not remove '/' (default)

-r, -R, --recursive
remove directories and their contents recursively

bropages(gem&ruby based)

  • 使用体验:一般

#ruby 环境安装

sudo apt install ruby-full
# 检查版本
ruby --version

#安装gem+bropages

# gem可以安装bropages
sudo apt install gem
#环境准备完毕,开始下载build bropages
sudo gem install bropages

使用

获取帮助

​bro -h​

查询某个命令

​bro <commandName>​

示例:bro top

┌─[cxxu@cxxuAli] - [~] - [2022-04-11 11:44:19]
└─[0] <> bro top
/var/lib/gems/2.5.0/gems/commander-4.1.5/lib/commander/user_interaction.rb:328: warning: constant ::NIL is deprecated
commander-4.1.5/lib/commander/user_interaction.rb:328: warning: constant ::Bignum is deprecated
4 entries for top -- submit your own example with "bro add top"

# order by memory
top -o %MEM

bro thanks to upvote (4)
bro ...no to downvote (0)

......................................................................................................................................................................................

# monitor the process with pid 1, 2, and 3
top -p 1, 2, 3

bro thanks 2 to upvote (5)
bro ...no 2 to downvote (2)

......................................................................................................................................................................................

# Run the top command once, and only show the header and first 8 processes
# Can be further parsed with '| awk ...' in various scripts
top -n 1 | head -n 15

bro thanks 3 to upvote (3)
bro ...no 3 to downvote (1)

cheat(dependent/go based/python pip based)

install from github release

cheat 脚本化安装(预备:获取cheat包)

  • 可以安装到最新版本
  • 分为两部分
  • cheat 程序工具
  • cheatsheet/管理工具+ 数据字典(可以手动下载,也可以由cheat自动clone)
  • 手动选择下载包
  • 可以使用wget 下载合适自己版本的包
  • 如果下不下来,可以在windows浏览器下载,然后用​​scp​​等方式发送的linux
  • 国内镜像(可以clone,但似乎没有release可以下载)
reference(optional)
  • 包的解压与权限修改+使用

正式安装

获取到合适自己系统的包后
我整合了安装脚本,可以复制粘贴直接运行

  • 下例子中以​​cheat-linux-amd64.gz​​为例进行安装(最主流的包)

目录结构(~/.config/cheat为树的根节点)

linux_命令行助手:(manpages supplement)/获取linux命令用法示例的若干辅助命令行工具(cheat/tldr)_linux


linux_命令行助手:(manpages supplement)/获取linux命令用法示例的若干辅助命令行工具(cheat/tldr)_sed_02

gzip -dk cheat-linux-amd64.gz
sudo mv cheat-linux-amd64 /usr/local/bin/cheat
sudo chmod +x /usr/local/bin/cheat
cheat --version
# 随便让cheat 搜索一个命令的示例,激活该工具
cheat ls
# 将会遇到如下创建&clone提示

┌─[cxxu@CxxuWin11] - [/mnt/c/Users/cxxu] - [2022-05-01 06:42:00]
└─[0] <> cheat ls
A config file was not found. Would you like to create one now? [Y/n]: y
Would you like to download the community cheatsheets? [Y/n]: y
Cloning into ‘/home/cxxu/.config/cheat/cheatsheets/community’…

  • 建议稍等片刻,尝试能否克隆下来
# 准备cheatsheet 数据源以及配置
#mkdir -p ~/.config/cheat #如果报错,请删除掉这一行
git clone https://gitee.com/mirrors_cheat/cheatsheets ~/.config/cheat/cheatsheets/community

mkdir -p ~/.config/cheat/cheatsheets/personal
cd ~/.config/cheat
# 创建config.yml文件
> conf.yml <<eof
---
# The editor to use with 'cheat -e <sheet>'. Defaults to $EDITOR or $VISUAL.
editor: vim

# Should 'cheat' always colorize output?
colorize: true

# Which 'chroma' colorscheme should be applied to the output?
# Options are available here:
# https://github.com/alecthomas/chroma/tree/master/styles
style: monokai

# Which 'chroma' "formatter" should be applied?
# One of: "terminal", "terminal256", "terminal16m"
formatter: terminal16m

# Through which pager should output be piped? (Unset this key for no pager.)
pager: less -FRX

# The paths at which cheatsheets are available. Tags associated with a cheatpath
# are automatically attached to all cheatsheets residing on that path.
#
# Whenever cheatsheets share the same title (like 'tar'), the most local
# cheatsheets (those which come later in this file) take precedent over the
# less local sheets. This allows you to create your own "overides" for
# "upstream" cheatsheets.
#
# But what if you want to view the "upstream" cheatsheets instead of your own?
# Cheatsheets may be filtered via 'cheat -t <tag>' in combination with other
# commands. So, if you want to view the 'tar' cheatsheet that is tagged as
# 'community' rather than your own, you can use: cheat tar -t community
cheatpaths:

# Paths that come earlier are considered to be the most "global", and will
# thus be overridden by more local cheatsheets. That being the case, you
# should probably list community cheatsheets first.
#
# Note that the paths and tags listed below are placeholders. You may freely
# change them to suit your needs.
#
# Community cheatsheets must be installed separately, though you may have
# downloaded them automatically when installing 'cheat'. If not, you may
# download them here:
#
# https://github.com/cheat/cheatsheets
#
# Once downloaded, ensure that 'path' below points to the location at which
# you downloaded the community cheatsheets.
- name: community
path: /home/cxxu/.config/cheat/cheatsheets/community
tags: [ community ]
readonly: true

# If you have personalized cheatsheets, list them last. They will take
# precedence over the more global cheatsheets.
- name: personal
path: /home/cxxu/.config/cheat/cheatsheets/personal
tags: [ personal ]
readonly: false

# While it requires no configuration here, it's also worth noting that
# 'cheat' will automatically append directories named '.cheat' within the
# current working directory to the 'cheatpath'. This can be very useful if
# you'd like to closely associate cheatsheets with, for example, a directory
# containing source code.
#
# Such "directory-scoped" cheatsheets will be treated as the most "local"
# cheatsheets, and will override less "local" cheatsheets. Likewise,
# directory-scoped cheatsheets will always be editable ('readonly: false').%"

eof

cheat 原生安装

可能因为网络问题,导致clone失败,如果这样,可以多试几次,或者采用上述的脚本安装

  • 中途可能提示没有配置文件而需要从 github clone
# cxxu @ CxxuWin11 in ~ [20:04:13] C:130
$ cheat ls
A config file was not found. Would you like to create one now? [Y/n]: y
Would you like to download the community cheatsheets? [Y/n]: y

Cloning into '/home/cxxu/.config/cheat/cheatsheets/community'...
remote: Enumerating objects: 1118, done.
remote: Counting objects: 100% (278/278), done.
remote: Compressing objects: 100% (33/33), done.
remote: Total 1118 (delta 256), reused 245 (delta 245), pack-reused 840
Receiving objects: 100% (1118/1118), 284.04 KiB | 488.00 KiB/s, done.
Resolving deltas: 100% (491/491), done.
Created config file: /home/cxxu/.config/cheat/conf.yml
Please read this file for advanced configuration information.

# cxxu @ CxxuWin11 in ~ [20:08:59]
$ cheat -v
4.2.3
  • 简单使用
# cxxu @ CxxuWin11 in ~ [20:13:18]
$ cheat top

# To update every <interval> samples:
top -i <interval>

# To set the delay between updates to <delay> seconds:
top -s <delay>

# To set event counting to accumulative mode:
top -a

# To set event counting to delta mode:
top -d

eg(by python)

  • ​pip install eg​
  • 使用体验:较好


标签:cheatsheets,示例,cheat,community,python,命令行,linux,config
From: https://blog.51cto.com/u_15672212/5852391

相关文章

  • linux buildroot平台添加gzip
    linuxbuildroot平台添加gzip在ubuntu中通过tar-zcvfxxxxxx.tar.gzxxxxxx命令压缩的文件,在开发板上无法解压,弹出如下提示:待添加发现是buildroot默认没有gzip,需要打......
  • 初识Linux(九)------ 学习Shell Scripts
    基本上,shellscript有点像是早期的批处理文件,亦即是将一些指令汇整起来一次执行,但是Shellscript拥有更强大的功能,那就是他可以进行类似程序(program)的编写,并且不......
  • linux开放端口命令
    linux系统中控制端口的开启与关闭可以由命令来执行。linux下开放端口命令的相关知识:linux开放端口命令1打开指定端口:/sbin/iptables-IINPUT-ptcp--dport80-jACC......
  • linux部署java环境
    一、进入到下载目录cd/usr/local/src二、下载Java下载地址JavaDownloads|Oracle下载完后执行下面这个命令然后选择到下载的文件后通过xshell上传上去或者通过......
  • linux Buildroot的syslogd配置
    linuxBuildroot的syslogd配置1、简介syslogd可以负责记录系统运作中,kernel或应用程式产生的各种讯息。这些讯息被写入到系统的纪录档中,让管理人员,进行故障排除、追踪尝......
  • elasticsearch安装(Linux)
    1.下载安装包官网下载,下载地址:https://www.elastic.co/cn/downloads/past-releases#elasticsearch将安装包上传到服务器#创建文件mkdirelasticsearch  2.创建......
  • Linux启动流程rcN.d rcS.d rc.local等
    1环境当前系统环境为:Linuxmintmate17.1(基于ubuntu14.04的衍生版)备注:/etc/rc.d文件夹中的脚本文件的链接目标为:/etc/init.d文件夹下的脚本(为系统运行级别‘数字’......
  • Spring Boot CLI命令行工具
    SpringBootCLI是一个命令行工具,如果您想快速开发Spring应用程序,可以使用它。它允许您运行Groovy脚本,这意味着您拥有熟悉的类似Java的语法,而无需太多样板代码。您还......
  • Linux-终端命令格式-笔记
    目标了解终端命令格式知道如何查阅终端命令帮助信息01.终端命令格式command[-options][parameter]说明:​​command​​:命令名,相应功能的英文单词或单词的缩写​​[-optio......
  • Linux-文件和目录常用命令-笔记
    目标查看目录内容​​ls​​切换目录​​cd​​创建和删除操作​​touch​​​​rm​​​​mkdir​​拷贝和移动文件​​cp​​​​mv​​查看文件内容​​cat​​​​more......