failed to load config: failed to resolve symlink: root/.dotfiles/cheat/cheatsheets/comm
而安装cheat 需要使用到python 和 python-pip工具及其相关的python库其为 docopt, pygments,且安装 pyton-pip又需要 setuptools 工具,如果没有安装过还是有些麻烦找这些的,所以记录本次安装过程,为了方便后面想安装cheat工具的童鞋。
下载 python-pip #说明,本次使用的是centos7.6 系统,自带python 2.7 且能上外网,但是python2.7安装的pip工具在下载docopt pygments 两个依赖是一直报错,所有必须安装python更高的版本,这个python-pip 也就是最新的pip3 了
1.这里默认安装好了python37版本了 如果没有安装好开源参考centos7 安装 python37_学习者007的博客-CSDN博客
[root@localhost ~]# python -V
Python 3.7.0
2.安装好了pip3后就可以直接来安装cheat了
cd /tmp \
&& wget https://github.com/cheat/cheat/releases/download/4.2.7/cheat-linux-amd64.gz \
&& gunzip cheat-linux-amd64.gz \
&& chmod +x cheat-linux-amd64 \
&& sudo mv cheat-linux-amd64 /usr/local/bin/cheat
3.安装了试着运行cheat
[root@localhost cheat]# cheat tar
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 community cheatsheets to /root/.dotfiles/cheat/cheatsheets/community.
Cloning into '/root/.dotfiles/cheat/cheatsheets/community'...
remote: Enumerating objects: 2058, done.
remote: Counting objects: 100% (845/845), done.
remote: Compressing objects: 100% (147/147), done.
remote: Total 2058 (delta 743), reused 698 (delta 698), pack-reused 1213
Receiving objects: 100% (2058/2058), 474.93 KiB | 45.00 KiB/s, done.
Resolving deltas: 100% (1009/1009), done.
Cloning personal cheatsheets to /root/.dotfiles/cheat/cheatsheets/personal.
Created config file: /root/.dotfiles/cheat/conf.yml
Please read this file for advanced configuration information.
4.设置 cheat 配置文件,先要编辑下这个conf.yml,因为cheat有 -e (editor)所有在配置conf.yml时还要设置它的默认编辑器
cd ~/.dotfiles/cheat/
vim conf.yml
===================================================================================
# The editor to use with 'cheat -e <sheet>'. Defaults to $EDITOR or $VISUAL.
editor: vim
# Should 'cheat' always colorize output?
colorize: false
# 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: terminal
# Through which pager should output be piped?
# pager: less -FRX # <- recommended where available
# 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: ~/.dotfiles/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: ~/.dotfiles/cheat/cheatsheets/personal
tags: [ personal ]
readonly: false
#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').
5.再添加cheat配置文件的环境变量后就可以使用了,当然可以加到用户变量中
export CHEAT_CONFIG_PATH="~/.dotfiles/cheat/conf.yml"
===============================================
cd ~&&vim .bashrc
export CHEAT_CONFIG_PATH="~/.dotfiles/cheat/conf.yml"
补充!安装这个看似简单,但是一直试错好几个小时才试出来了,在配置问题里面的 有个路径一定不要写死 会报错
- name: personal
path: ~/.dotfiles/cheat/cheatsheets/personal #这里要特别注意 这才是正确的写法
tags: [ personal ]
readonly: false
就这个path 这:之前写成 /root/.dotfiles//cheat/cheatsheets/personal
一直报错如下:failed to load config: failed to resolve symlink: root/.dotfiles/cheat/cheatsheets/community: lstat root: no such file or directory
[root@localhost ~]# cheat ls
failed to load config: failed to resolve symlink: root/.dotfiles/cheat/cheatsheets/community: lstat root: no such file or directory
至此已经安装好了如下图
[root@localhost ~]# cheat tar
# To extract an uncompressed archive:
tar -xvf /path/to/foo.tar
# To extract a .tar in specified directory:
tar -xvf /path/to/foo.tar -C /path/to/destination/
# To create an uncompressed archive:
tar -cvf /path/to/foo.tar /path/to/foo/
# To extract a .tgz or .tar.gz archive:
tar -xzvf /path/to/foo.tgz
tar -xzvf /path/to/foo.tar.gz
# To create a .tgz or .tar.gz archive:
tar -czvf /path/to/foo.tgz /path/to/foo/
tar -czvf /path/to/foo.tar.gz /path/to/foo/
# To list the content of an .tgz or .tar.gz archive:
tar -tzvf /path/to/foo.tgz
tar -tzvf /path/to/foo.tar.gz
# To extract a .tar.bz2 archive:
tar -xjvf /path/to/foo.tar.bz2
# To create a .tar.bz2 archive:
tar -cjvf /path/to/foo.tar.bz2 /path/to/foo/
# To list the content of an .tar.bz2 archive:
tar -tjvf /path/to/foo.tar.bz2
# To create a .tgz archive and exclude all jpg,gif,... from the tgz:
tar -czvf /path/to/foo.tgz --exclude=\*.{jpg,gif,png,wmv,flv,tar.gz,zip} /path/to/foo/
# To use parallel (multi-threaded) implementation of compression algorithms:
tar -z ... -> tar -Ipigz ...
tar -j ... -> tar -Ipbzip2 ...
tar -J ... -> tar -Ipixz ...
# To append a new file to an old tar archive:
tar -rf <archive.tar> <new-file-to-append>
(END)