【linux命令讲解大全】192.dircolors 和 bind 命令:优化命令行操作的工具

dircolors

dircolors 命令用于设置 ls 命令在显示目录或文件时所使用的颜色。可以根据 [颜色配置文件] 来设置 LS_COLORS 环境变量或将其导出到环境中。

语法

dircolors [选项] [文件]

选项

  • -b, --bourne-shell: 将 LS_COLORS 设为 Bourne shell 中当前预设的 shell 指令。
  • -c, --c-shell: 将 LS_COLORS 设为 C shell 中当前预设的 shell 指令。
  • -p, --print-database: 显示预设。
  • --help: 显示帮助。
  • --version: 显示版本信息。

参数

  • 文件: 指定用来设置颜色的文件。

实例

[root@localhost ~]# dircolors -p
# Configuration file for dircolors, a utility to help you set the
# LS_COLORS environment variable used by GNU ls with the --color option.
# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
# slackware version of dircolors) are recognized but ignored.
# Below, there should be one TERM entry for each termtype that is colorizable
TERM linux
TERM linux-c
TERM mach-color
TERM console
TERM con132x25
TERM con132x30
TERM con132x43
TERM con132x60
TERM con80x25
TERM con80x28
TERM con80x30
TERM con80x43
TERM con80x50
TERM con80x60
TERM cygwin
TERM dtterm
TERM putty
TERM xterm
TERM xterm-color
TERM xterm-debian
TERM rxvt
TERM screen
TERM screen-bce
TERM screen-w
TERM vt100
TERM Eterm
# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
NORMAL 00 # global default, although everything should be something.
FILE 00 # normal file
DIR 01;34 # directory
LINK 01;36 # symbolic link. (If you set this to 'target' instead of a
 # numerical value, the color is as for the file pointed to.)
FIFO 40;33 # pipe
SOCK 01;35 # socket
DOOR 01;35 # door
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver
ORPHAN 40;31;01 # symlink to nonexistent file
SETUID 37;41 # file that is setuid (u+s)
SETGID 30;43 # file that is setgid (g+s)
STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable
# This is for files with execute permission:
exec 01;32
# List any file extensions like '.gz' or '.tar' that you would like ls
# to colorize below. Put the extension, a space, and the color init string.
# (and any comments you want to add after a '#')
# If you use DOS-style suffixes, you may want to uncomment the following:
#.cmd 01;32 # executables (bright green)
#.exe 01;32
#.com 01;32
#.btm 01;32
#.bat 01;32
.tar 01;31 # archives or compressed (bright red)
.tgz 01;31
.arj 01;31
.taz 01;31
.lzh 01;31
.zip 01;31
.z 01;31
.Z 01;31
.gz 01;31
.bz2 01;31
.deb 01;31
.rpm 01;31
.jar 01;31
# image formats
.jpg 01;35
.jpeg 01;35
.gif 01;35
.bmp 01;35
.pbm 01;35
.pgm 01;35
.ppm 01;35
.tga 01;35
.xbm 01;35
.xpm 01;35
.tif 01;35
.tiff 01;35
.png 01;35
.mov 01;35
.mpg 01;35
.mpeg 01;35
.avi 01;35
.fli 01;35
.gl 01;35
.dl 01;35
.xcf 01;35
.xwd 01;35
# audio formats
.flac 01;35
.mp3 01;35
.mpc 01;35
.ogg 01;35
.wav 01;35 

bind

bind 命令用于显示和设置命令行的键盘序列绑定功能。通过这一命令,可以提高命令行中操作效率。可以利用 bind 命令了解有哪些按键组合与其功能,也可以自行指定要用哪些按键组合。

语法

bind [选项]

选项

  • -d: 显示按键配置的内容。
  • -f <按键配置文件>: 载入指定的按键配置文件。
  • -l: 列出所有的功能。
  • -m <按键配置>: 指定按键配置。
  • -q <功能>: 显示指定功能的按键。
  • -v: 列出目前的按键配置与其功能。

实例

bind -x '"\C-l":ls -l' # 直接按 CTRL+L 就列出目录。

其中 keyseq 可以使用 showkey -a 命令来获取:

showkey -a

Press any keys - Ctrl-D will terminate this program

^[[A     27 0033 0x1b  上
         91 0133 0x5b
         65 0101 0x41
^[[B     27 0033 0x1b  下
         91 0133 0x5b
         66 0102 0x42
^[[D     27 0033 0x1b  左
         91 0133 0x5b
         68 0104 0x44
^[[C     27 0033 0x1b 右
         91 0133 0x5b
         67 0103 0x43
         32 0040 0x20
^M       13 0015 0x0d 字母M
^C        3 0003 0x03 Ctrl-C
^D        4 0004 0x04 Ctrl-D 退出 

从零学 python

【从零学习python 】92.使用Python的requests库发送HTTP请求和处理响应
【从零学习python 】91. 使用装饰器和字典管理请求路径的简洁Web应用
【从零学习python 】93.使用字典管理请求路径
【从零学习python 】89. 使用WSGI搭建简单高效的Web服务器
【从零学习python 】88. WSGI接口详解:实现简单高效的Web开发
【从零学习python 】87. 手动搭建HTTP服务器的Python实现及多线程并发处理
【从零学习python 】86. 深入了解HTTP协议及其在浏览器和服务器通信中的作用
【从零学习python 】85.Python进程池的并行计算技术应用
【从零学习python 】84.深入理解线程和进程
【从零学习python 】83. Python多进程编程与进程池的使用
【从零学习python 】82. 基于多线程的聊天程序实现
【从零学习python 】81.Python多线程通信与队列的应用
【从零学习python 】80.线程访问全局变量与线程安全问题
【从零学习python 】79. 线程访问全局变量与线程安全问题
【从零学习python 】78. 文件下载案例
【从零学习python 】77. TCP服务端编程及注意事项
【从零学习python 】76.服务器与客户端:网络通信的关键组成部分
【从零学习python 】75. TCP协议:可靠的面向连接的传输层通信协议
【从零学习python 】74. UDP网络程序:端口问题与绑定信息详解
【从零学习python 】73. UDP网络程序-发送数据
【从零学习python 】72. 深入理解Socket通信及创建套接字的方法
【从零学习python 】71. 网络端口及其作用
【从零学习python 】70.网络通信方式及其应用:从直接通信到路由器连接多个网络
【从零学习python 】69. 网络通信及IP地址分类解析
【从零学习python 】68. Python正则表达式中的贪婪和非贪婪模式
【从零学习python 】67.Python中的re模块:正则替换与高级匹配技术
【从零学习python 】66.深入了解正则表达式:模式匹配与文本处理的利器
【从零学习python 】65. Python正则表达式修饰符及其应用详解
【从零学习python 】64. Python正则表达式中re.compile方法的使用详解
【从零学习python 】63.正则表达式中的re.Match类及其属性和方法介绍
【从零学习python 】62. Python正则表达式:强大的字符串匹配工具
【从零学习python 】61.Python中的property属性详解和应用示例
【从零学习python 】60.探索生成器:迭代的灵活利器
【从零学习python 】59.迭代器:优化数据遍历的高效工具
【从零学习python 】58.Python中的自定义异常及引发异常的方法
【从零学习python 】57.Python中使用with关键字正确关闭资源
【从零学习python 】56. 异常处理在程序设计中的重要性与应用
【从零学习python 】55.Python中的序列化和反序列化,JSON与pickle模块的应用
【从零学习python 】54. 内存中写入数据
【从零学习python 】53. CSV文件和Python的CSV模块
【从零学习python 】52.文件的读写 - Python文件操作指南
【从零学习python 】51.文件的打开与关闭及其在Python中的应用
【从零学习python 】49. Python中对象相关的内置函数及其用法
【从零学习python 】48.Python中的继承与多继承详解
【从零学习python 】47. 面向对象编程中的继承概念及基本使用
【从零学习python 】46. Python中的__new__和__init__方法解析及单例设计模式
【从零学习python 】45.Python中的类方法和静态方法
【从零学习python 】44.面向对象编程中的私有属性和方法
【从零学习python 】43. Python面向对象编程中的实例属性和类属性
【从零学习python 】42.Python中的内置属性和方法
【从零学习python 】41.python魔法方法(二)
【从零学习python 】40.python魔法方法(一)
【从零学习python 】39.面向对象基本语法及应用示例
【从零学习python 】38.Python包的使用及导入方式
【从零学习python 】37.Python自定义模块的使用和注意事项
【从零学习python 】36.Python中使用pip进行第三方包管理的方法与技巧
【从零学习python 】35. Python常见系统模块及其用法
【从零学习python 】34.Python模块的导入和使用方法详解
【从零学习python 】33.装饰器的作用(二)
【从零学习python 】32.装饰器的作用(一)
【从零学习python 】31.深入理解Python中的高阶函数和闭包
【从零学习python 】30.深入理解递归函数和匿名函数
【从零学习python 】29. 「函数参数详解」——了解Python函数参数的不同用法
【从零学习python 】28. Python中的局部变量和全局变量
【从零学习python 】27. Python 函数的使用及嵌套调用
【从零学习python 】25.函数:提高代码编写效率的利器
【从零学习python 】24. Python中的字符串操作与遍历方法
【从零学习python 】23. Python中集合(set)的使用方法和常见操作
【从零学习python 】22. Python中的字典的增删改查及字典的变量
【从零学习python 】21.Python中的元组与字典
【从零学习python 】20. Python列表操作技巧及实例
【从零学习python 】19. 循环遍历列表和列表嵌套的应用
【从零学习python 】18. Python列表的基本操作详解(一)
【从零学习python 】17. Python字符串的format方法(二)
【从零学习python 】16. Python字符串的format方法(一)
【从零学习python 】15.深入了解字符串及字符集编码
【从零学习python 】14.Python字符串常见操作(二)
【从零学习python 】13.Python字符串常见操作(一)
【从零学习python 】12.Python字符串操作与应用
【从零学习python 】11.Python循环语句和控制流程
【从零学习python 】10.Python条件语句和if嵌套详解
【从零学习python 】09.Python 中的条件判断语句
【从零学习python 】08.Python了解位运算符, 运算符优先级
【从零学习python 】07.Python运算符详解:赋值、比较和逻辑运算符
【从零学习python 】06. Python中运用算数运算符进行计算和字符串拼接
【从零学习python 】05. Python中的输出和输入
【从零学习python 】04. Python编程基础:变量、数据类型与标识符
【从零学习python 】03. Python交互式编程及注释详解
【从零学习python 】02. 开发工具介绍
【从零学习python 】01. 安装配置python

猜你喜欢

转载自blog.csdn.net/qq_33681891/article/details/133265850
今日推荐