• Linux命令行增强版


    0. 前言

      周末大早上的,没事做,了解下这几个命令了,哎~~~。

      正常情况下,Linux下的命令行,界面比较丑,命令行命令有时候也不是很友好,下面就通过这几个命令或工具,美化一下命令行。

    1. oh-my-zsh

      这个就没有什么可以讲的了,直接从github上clone下来,安装github上的readme文档进行安装。https://github.com/robbyrussell/oh-my-zsh

    2. cat 命令

      可以使用bat命令,代替默认的cat命令,打印文本内容,可以进行高亮显示,比较好用。github地址:https://github.com/sharkdp/bat
      我是在debian系统,直接在 https://github.com/sharkdp/bat/releases 下载,然后dpkg -i *.deb 即可
      在 ~/.zshrc 加上 alias cat = 'bat'


    3. ping 命令

      可以使用prettyping 命令来代替ping命令。这个prettyping命令,看名字就知道,比默认的ping 命令会好看很多。哈哈。

    1 curl -O https://raw.githubusercontent.com/denilsonsa/prettyping/master/prettyping
    2 chmod +x prettyping
    3 mv prettyping /usr/local/bin/

      在 ~/.zshrc alias ping = 'prettyping'

    4. autojump 命令

      用于快速切换历史进入过的目录

    apt-get install autojump

      然后在 ~/.zshrc 中的 plugins 增加 autojump, 以后就可以通过 j 命令 tab tab 快速切换目录,不过这个好像没有下面要介绍的这个好用。

    5. ctrl+r命令

      在终端里,使用fzf命令代替ctrl+r命令反向搜索。具体安装参考 https://github.com/junegunn/fzf

    1 git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
    2 ~/.fzf/install
    3 source ~/.zshrc

      使用方法
      COMMAND [DIR]/**<TAB>
      kill -9 <TAB>

      扩展一个预览的功能,在 ~/.zshrc 中增加

    alias preview="fzf --preview 'bat --color "always" {}"

    6. top命令

      这个就是美化top命令,通过 apt-get install htop

    7. diff 命令

      可以通过 diff-so-fancy 命令来代替默认的diff命令,来对比两个文件。 参考 https://github.com/so-fancy/diff-so-fancy

    8. find 命令

      使用fd命令来代替find命令,默认的find命令性能比较差,没有建立数据库及缓存,每次都是读取磁盘文件。https://github.com/sharkdp/fd/ 直接在  https://github.com/sharkdp/fd/releases 下载 deb包安装
      fd -e zip -x unzip
      fd [模糊文件名] [-e 后缀] [-x 找到后执行命令]

    9. du 命令

      有时候我们需要用du查看当前文件的磁盘占用。并以友好界面展现。

    apt-get install ncdu
    alias du="ncdu --color dark -rr -x --exclude .git --exclude node_modules"

    10. man 命令

      平时我们遇到不会的命令,都会用到man查一下文档(其实是百度一下啦),而往往我们只是忘记了这个命令需要加什么参数。不需要了解太多的文档的内容和技术细节,这个时候就有一个工具 tldr工具。 TL;DR Too Long; Didn't Read
      有很多种安装方式,应该比较符合大众的就是 pip 或 npm 方式了。

    1 pip install tldr
    2 pip install tldr.py
    3 npm install -g tldr
    4 alias help='tldr'

    11. grep 命令

      经常用grep进行文本内容过滤,平时的命令组合 netstat -anop | grep 8080 之类的,就没有太大关系,但是如果是多文件目录,需要查找目录下,哪个文件包含了某些内容,只用grep就有点麻烦了,这个时候可以使用 ack 命令。

    1 apt-get install ack-grep
    2 ack foo --js -A 2 -B 2 #在当前目录下,查找js文件中包含foo文本,并打印与其相关的上下2行

    参考资料:https://zhuanlan.zhihu.com/p/48076652

    本文地址:  https://www.cnblogs.com/wunaozai/p/10014954.html

  • 相关阅读:
    hadoop集群配置和测试
    ubuntu 12.04安装jdk
    springboot集成mybatis
    redis连接数据库
    生产随机数
    关于字符串统计次数
    闲的无聊写了一个房租的后台
    简单的死锁
    java集合类总结(转)
    mybatis框架的搭建
  • 原文地址:https://www.cnblogs.com/wunaozai/p/10014954.html
Copyright © 2020-2023  润新知