zoukankan      html  css  js  c++  java
  • linux环境前缀太长 屏幕占满

    image.png
    如图所示,用户名+主机名+地址,当进入的目录比较多时,几乎占满了整个屏幕
    实际上可以通过修改环境变量让这个变短

    • 修改用户目录下的 .bashrc文件 vi ~/.bashrc
    • 通过搜索找到 PS1这个变量,这时候可以发现如下所示:
    if [ "$color_prompt" = yes ]; then
        PS1='${debian_chroot:+($debian_chroot)}[33[01;32m]u@h[33[00m]:[33[01;34m]w[33[00m]$ '
    else
        PS1='${debian_chroot:+($debian_chroot)}u@h:w$ '
    

    重点找到PS1的值 u@h:w$
    其中 u表示用户名username 后面的@就是@符号
    h表示主机名hostname 然后是冒号:
    最后是w表示当前路径 后面跟着$

    • 一般来说,主机名是没什么用的,因此可以直接把 h给删掉
      同时当前路径也不是非常需要,主要是太长了,因此可以只显示当前文件夹名,将小写的w更换成大写的W
      当需要当前路径时可以通过pwd命令(print working directory)进行输出
    if [ "$color_prompt" = yes ]; then
        #PS1='${debian_chroot:+($debian_chroot)}[33[01;32m]u@h[33[00m]:[33[01;34m]w[33[00m]$ '
        PS1='${debian_chroot:+($debian_chroot)}[33[01;32m]u:[33[01;34m]W[33[00m]$ '
    else
        #PS1='${debian_chroot:+($debian_chroot)}u@h:w$ '
        PS1='${debian_chroot:+($debian_chroot)}u:W$ '
    
  • 相关阅读:
    C艹目录
    C艹重复输入小方法,for循环+while
    python with 语句妙用
    python with妙用
    Kali配置网卡静态信息
    Spring 之 注解详解
    html基础之 表单提交方法
    html 基础之 <link>标签
    android:padding和android:margin的区别
    css基础之 font的简写规则 以及 自定义 CSS3 @font-face详细用法
  • 原文地址:https://www.cnblogs.com/qiulinzhang/p/11004058.html
Copyright © 2011-2022 走看看