PS(Prompt Sign)指的是命令提示符,在日常运维工作中为了方面操作管理,有时会设定PS1环境变量。 废话不多说,下面开始记录下Linux中PS1设置 在/etc/.bashrc中,找到PS1变量的定义,如果没有,手动加上: 可以将显示输出到标题栏上: [root@elk-node1 ~]# vim /root/.bashrc ........... export PS1="\[\e]2;\u@\H \w\a\e[32;1m\]>\[\e[0m\]" [root@elk-node1 ~]# sour
PS1是Linux终端用户的一个环境变量,用来定义命令行提示符的参数。默认如下:
http://blog.csdn.net/pipisorry/article/details/39584489
为了区分生产环境和测试环境,强烈调整Linux的命令行颜色,避免误操作导致生产故障,很不起眼的一个操作,但是在犯蒙时刻能救命~
颜色值设置: PS1中设置字符颜色的格式为:[\e[F;Bm],其中“F“为字体颜色,编号为30-37,“B”为背景颜色,编号为40-47。
作为一个大公司的运维,手头管理了成百上千的服务器是家常便饭,甚至更多。而我们一般都是用跳板机登陆,由于这些机器一般都是克隆或者虚拟化出来的,所以登陆后的命令行提示符几乎是一个模子刻出来的,比如都是:[
PS1是主提示符变量,也是默认提示符变量。默认值[\u@\h \W]\$,显示用户主机名称工作目录。
众所周知, bash (the B ourne- A gain Sh ell)是目前绝大多数 Linux 发行版使用的默认 shell。本文将会介绍怎么通过添加颜色和样式来自定义 bash 命令提示符的显示。尽管很多插件或工具都可以很轻易地满足这一需求,但我们也可以不使用插件和工具,自己手动自定义一些基本的显示方式,例如添加或者修改某些元素、更改前景色、更改背景色等等。
在操作 Linux 系统时,我们最常接触的就是终端界面。其中,Shell 提示符(也称命令行提示符)作为用户与系统交互的第一道门户,拥有极高的可定制性。今天,我们就来探索如何设置并优化你的 Shell 提示符,让你的命令行界面更加符合你的个性和需求。
众所周知, bash (the B ourne- A gain Sh ell)是目前绝大多数 Linux 发行版使用的默认 shell。本文将会介绍如何通过添加颜色和样式来自定义 bash 命令提示符的显示。尽管很多插件或工具都可以很轻易地满足这一需求,但我们也可以不使用插件和工具,自己手动自定义一些基本的显示方式,例如添加或者修改某些元素、更改前景色、更改背景色等等。
In this chapter we will look at a seemingly trivial detail — our shell prompt. Thisexamination will reveal some of the inner workings of the shell and the terminal emulatorprogram itself.
有必要对里面的一些信息进行解释。例如[\033[01;32m]中,01为前景色,32为背景色,颜色代码如下:
由于 Linux 命令行没有图形化界面,因此,所有的设置都采用文本的方式来完成,而其中最重要的用户设置则为 bashrc 文件,bashrc 配置文件非常重要,相当于图形化界面的设置选项。很多时候,命令找不到,缺少 XXX,都可能与这个有关。如果 bashrc 修改错误,会造成严重的影响。下面系统来介绍一下 bashrc 文件。
本章将会讲解一个看似微不足道的细节:shell 提示符。通过学习 shell提示符,我们会发现 shell 和 终端仿真器程序的内部工作机制。 和Linux中的很多程序一样,shell 提示符的可配
所谓变量就是计算机中用于记录一个值(不一定是数值,也可以是字符或字符串)的符号,而这些符号将用于不同的运算处理中。通常变量与值是一对一的关系。
点击 Browse 按钮,弹出如下面板,选择 ANSI Colors on Black,然后点击右侧save as 按钮,命名为 zkl。
在平时使用Linux的时候,经常需要配置一些环境变量,这时候一般都是网上随便搜搜就有人介绍经验的。不过问题在于他们的方法各不相同,有人说配置在/etc/profile里,有人说配置在/etc/environment,有人说配置在~/.bash_profile里,有人说配置在~/.bashrc里,有人说配置在~/.bash_login里,还有人说配置在~/.profile里。。。这真是公说公有理。。。那么问题来了,Linux到底是怎么读取配置文件的呢,依据又是什么呢?
使用export把PS1输出,以使它可以在子shell中生效,这会造成ROOT用户的也采用此样式
环境变量配置文件目录概要 /etc/profile 用户环境变量,交互,登录才执行 /etc/bashrc 用户不能登录,执行shell就生效 ~/.bashrc ~/.bash_history ~/.bash_logout PS1='[\033[01;32m]\u@\h[\033[00m]:[\033[01;36m]\w[\033[00m]$ ' //带颜色显示命令行左边 系统的环境变量配置文件 两个纬度,一个是系统层次,一个是用户层次 系统层次,就是/etc 下的文件 用户层次,就是用户家目录下的
我们大家在平时使用Linux的时候,经常需要配置一些环境变量,这时候一般都是网上随便搜搜就有人介绍经验的。不过问题在于他们的方法各不相同,有人说配置在/etc/profile里,有人说配置在/etc/environment,有人说配置在~/.bash_profile里,有人说配置在~/.bashrc里,有人说配置在~/.bash_login里,还有人说配置在~/.profile里。。。这真是公说公有理。。。那么问题来了,Linux到底是怎么读取配置文件的呢,依据又是什么呢?下面这篇文章就来给大家详细的介绍下,一起来看看吧。
三、添加颜色 大多数终端都会响应某些非打印字符序列,来控制光标位置、字符属性(如:颜色、粗体、文本闪烁)等内容。 1.字符颜色 (1)是什么? 字符颜色是由发送到终端仿真器的一个 ANSI 转
在linux系统普通用户目录(cd /home/xxx)或root用户目录(cd /root)下,用指令ls -al可以看到4个隐藏文件,
8.6 管道符和作业控制 管道符、作业控制 ctrl z //暂停一个任务 jobs //查看后台的任务 bg [id] //把任务调到后台 fg [id] //把任务调到前台 命令后面加&直接丢到后台 管道符的使用 管道符 | ,表示把前面命令输出的结果,传输给后面的命令 cat 1.txt |wc -l ;cat 1.txt |grep 'aaa' grep 命令,用来过滤指定关键词的命令,只要在一行中含有这个关键词,就会把这一行过滤出来 wc -l 命令,查看文件有多少个 [root@loca
前两天拿到了云筏科技提供的一台 4 核 16G 内存,1TB 硬盘,300M 带宽的服务器(看了一下 IP,应该是位于加拿大的服务器)!虽然是国外的服务器,但从国内 ssh 上去后的各种操作还是非常流畅的,而且前期白菜般的体验价格和飞一般的带宽的确也很有吸引力,像我用来做 Galaxy 和一些 web 开发测试完全是没问题。
前言 先来简单介绍下, prompt是什么鬼? 顾名思义就是提示符的意思, 看起来和我们遥远, 但实际上只要是每个接触shell的童鞋, 都有看到, 那就是我们在输命令时前面的那串提示符. 例如:
vmstat 1 自动显示系统的状态 sleep 100 可以使系统沉睡100秒 管道符和作业控制 管道符的作用:把管道符前面执行的结果输出内容交给管道符后面的命令。 查看1.txt的内容并输出给wc -l命令统计行数: cat 1.txt |wc -l 查看1.txt的内容并输出给grep命令查询关键词’aaa’: cat 1.txt |grep ‘aaa’ 暂停一个任务,比如用vim正在编辑一个文件,可以暂停到命令界面做别的事情,vim编辑的文件则暂停在后台里: ctrl z 把任务调
• 大家有没有遇到过不想写代码或学习的时候呢?这种情况下,你们会选择放松还是停下来呢?我很好奇大家是怎么度过这段时间的。
本文介绍如何自定义 Bash 提示,以更好地识别当前服务器和命令。通过自定义 Bash 提示,我们可以将操作任务区分得更清楚,提高工作效率。
本篇博客将指导你如何修改Linux终端的字体颜色。我们将详细讨论配置终端字体颜色的方法,以及需要注意的事项,帮助你个性化定制终端外观。
在linux的命令窗口输入命令与输出内容颜色一样,内容太多导致不容易区分,设置下登录名的颜色。效果如下图:
先骂人,再逼逼~上个环境还没有配置好,我就来写这个了.我不服!!!谁让咱们东西学的不系统呢~记录一下.bashrc文件的用途.毕竟zsh也得用不是~
2016年,来自夏威夷大学马诺阿分校天文研究所的天文学家们曾经发布了一份包含30亿个天体的目录,其中包括恒星、星系和类星体(超大质量黑洞的活跃核心)。
前言 工欲善其事,必先利其器。经过多次的重复配置 ubuntu 开发坏境,我终于决定花点时间总结一下,并将其写成一个自动化配置脚本。服务器实例:ubuntu 16.04,技术栈:shell,pytho
在知乎上看到这个问题,有人写了方法,但不详尽,我正好也遇到了这个问题,补充一下吧。以下内容有点长哦,但对于开发者值得了解一下。
今天这篇文章,主要介绍如何美化 Windows terminal 中 WSL 的 Linux 终端,依然是以本人最熟悉的Ubuntu为例,其他版本的 Linux 请参考本文的流程换用对应的命令。假定你已按我的上一篇文章已安装好 Windows terminal预编译版本,同时安装好了 Ubuntu,并设置好了 WSL的权限,然后就可以按本文继续操作了。
命令历史 # cat /root/.bash_history //存放历史命令的地方 # history //查看命令历史的条数 # echo $HISTSIZE //查看可以保存的条数 # vim /etc/profile //改变变量HISTSIZE的值 “/HISTSIZE” 去搜索 # source /etc/profile //这样才能使我们刚刚修改的值生效 # vim /etc/profile →在HISTSIZE下增加 HISTTIME
一、命令行方式: 使用转义码字符 echo -e "\033]0;我的虚拟终端窗体标题3\007" 📷 终端标题被改变 使用转义字符 echo -n $'\e'"]0;我的虚拟终端窗体标题"$'\a' 📷 另一种方式的标题改变,都是bash脚本 说明 : '\e'就是ESCAPE键的转义字符,ASCII码33使用八进制表示就是033,转义表示为\033,\e与\033是等价的。bash脚本, 第二种表示方式,不太符合常用的bash习惯,因为没有使用转义的表示,而是由三个输出字符串构成(为了防止每个输出换行,
weblogic@pmtest:/if [ “PS1” ]; then echo test is ok; fi test is ok
Shell是一个命令解释器,它解释由用户输入的命令并且把它们送到内核,不仅如此,Shell有自己的编程语言用于对命令的编辑,它允许用户编写由shell命令组成的程序.Shel编程语言具有普通编程语言的很多特点,比如它也有循环结构和分支控制结构等,用这种编程语言编写的Shell程序与其他应用程序具有同样的效果,下面我们会介绍Shell-Script的编写.
这个问题困扰了我很久,每次登陆终端提示就是这样子: Last login: Fri Jan 19 15:57:15 2018 from Welcome to JCLOUD Elastic Compute Service -bash-4.2# 后来以为是软件环境问题,找到了个解决办法: 终端输入:PS1="[root@localhost ~]" 之后看起来是解决了这个问题,但是一直是这样子的提示,进出目录该有的提示都没有,就是个摆设。 后来找到了正确的解决方法。 这个问题出现的原因是.bashrc文件
/etc/profile这个是环境变量配置文件,里面是应经配置号的环境变量。当你在Ubuntu上安装配置jdk的JAVA_HOME时,需要把路径配置在里面。
在研究《管理Python虚拟环境的脚本》时,我们使用了source指令而没有使用sh或者bash来执行脚本,就是因为source指令可以让脚本在当前bash(sh)中执行;而sh或者bash则会新启动一个bash来执行。
-多年互联网运维工作经验,曾负责过大规模集群架构自动化运维管理工作。 -擅长Web集群架构与自动化运维,曾负责国内某大型金融公司运维工作。 -devops项目经理兼DBA。 -开发过一套自动化运维平台(功能如下): 1)整合了各个公有云API,自主创建云主机。 2)ELK自动化收集日志功能。 3)Saltstack自动化运维统一配置管理工具。 4)Git、Jenkins自动化代码上线及自动化测试平台。 5)堡垒机,连接Linux、Windows平台及日志审计。 6)SQL执行及审批流程。 7)慢查询日志分析web界面。
powershell是一种命令行外壳程序和脚本环境,使命令行用户和脚本编写者可以利用 .NET Framework的强大功能,PowerShell脚本的文本文件,其文件名需要加上扩展名“.PS1”。PowerShell需要.NET环境的支持,同时支持.NET对象,其可读性、易用性居所有Shell之首。
关于在命令行显示git分支,我找到了网上很多文章,都类似,比如下面这篇: 《mac终端使用git命令行显示分支信息》 就是修改.bashrc脚本添加如下代码就可以了,我之前在linux平台基本就是这么干的。
原贴:http://os.51cto.com/art/201205/334954.htm
Linux 常用软件安装 htop apt undate apt install htop Oh My Zsh 安装 # 1.安装zsh包 # centOS yum -y install zsh # ununtu apt install zsh # 2.查看当前shell echo $SHELL # 3.换默认shell为zsh,如果未切换,需要重启 shell chsh -s /bin/zsh # 4.安装on my zsh sh -c "$(curl -fsSL https://raw.gith
~/.bashrc:系统配置文件,包含专用于你的 bash shell 的bash信息、设置,每次登录或打开新的 shell 时,该文件会被自动读取和执行。
注:这里是bash环境,如果是csh请把export改成setenv 并用setenv用法(其实就是setenv HISTSIZE 100),在bash中可以把下面内容放在~/.bashrc或者是~/.bash_profile 中,如果是csh就放在~/.cshrc,如果想对所有用户生效,请放在/etc/profile中,一般这些文都有内容可以接着下面写。 1,历史命令记录数100条 #1,Environment variables export HISTSIZE=100 2,PS1值 #2,Sheel prompt-Bash export PS1="\t \u@\h (\w) [\!]$" 3,MASK值,新建文件夹权限700,新建文件权限600 #3,File creation mask umask 077 4,STTY #4,Terminal settings (for remote host only) stty erase ^H 5,DATE #5,Display welcome message echo "Welcome tao" echo "Today is `date`." echo 6,系统登录用户信息 #6,System information echo "Last three logins:";last `logname` |head -3 echo echo "Current users: `users`" echo echo "System uptime:";uptime echo echo "There are `who | wc -l` userids logged in right now." 7,默认编辑器VIM ,翻页器LESS #8,default pager ,editor export PAGER=less export LESS='-CFMs' export EDITOR=vim 8,如果没有操作默认300秒断开 export TMOUT=300 9,给MAN命令加上颜色 9# man pages in color export LESS_TERMCAP_mb=$'\E[01;31m' export LESS_TERMCAP_md=$'\E[01;31m' export LESS_TERMCAP_me=$'\E[0m' export LESS_TERMCAP_se=$'\E[0m' export LESS_TERMCAP_so=$'\E[01;44;33m' export LESS_TERMCAP_ue=$'\E[0m' export LESS_TERMCAP_us=$'\E[01;32m'j
领取专属 10元无门槛券
手把手带您无忧上云