ps1

How to add an icon to the bash prompt

北城余情 提交于 2019-12-12 07:58:50
问题 I know you can edit the bash prompt permanently by editing the PS1 variable in your ~/.bashrc file, mine looks like this: PS1="\[\e[0;31m\]<HERP(._.)DERP>\[\e[0;0m\]"; but can you set a tiny little image in there as well? For instance, if I wanted to add a little American flag icon, or something before "HERP(._.)DERP", could I do this? 回答1: Sorry, no. Terminals don't do graphics. For a full description of what you can do, see the PROMPTING section of the bash(1) man page: PROMPTING When

Conditional pwd in an PS1 definition

吃可爱长大的小学妹 提交于 2019-12-11 11:34:30
问题 I want to display the current working directory in my prompt differently if I am in a symlink than not. I have this far: [[ `pwd -P` = `pwd` ]] && echo "\[1;31m\]$(pwd -P)" || echo "\[1;32m\]$(pwd)" will return the desired output but it will not work as a replacement for \w in the command prompt. I tried wrapping it with backticks but that just results in pwd -Ppwd in the PS1 . I want to conditionally change the color and the value if it is a symlink or not which is why I want the if/else

linux PS1 - display branch name only inside a git repo

你离开我真会死。 提交于 2019-12-11 03:01:49
问题 After searching the net, I found that one can display the git branch name with the PS1 with below PS1="$(__git_ps1 ) " While this is working fine, and it display the branch name in PS1 prompt. But it is displayed where-ever I navigate, even outside the git-checked-out-repo. I would like to display the branch name only if I am under a git tracked folder/repo. Any way to achieve this? Searching SO and net didn't pop-up helpful links in this respect. 回答1: You need to defer execution of $(__git

bash ps1 only executes a script once on new terminal windows [duplicate]

人盡茶涼 提交于 2019-12-11 02:17:48
问题 This question already has answers here : Why doesn't my bash prompt update? (2 answers) Closed 4 years ago . I have a very simple ps1 script in my .bashrc file, this excutes a random script generator called blah. export PS1="\[$(tput bold)\]\[$(tput setaf 1)\]\\$ \[$(tput sgr0)\] $PWD :: **$(. blah)** ::" the blah script simply should export a random string each time in the shell.... function silly { local RANDOMQUOTE=$[ ($RANDOM % 10 ) ] local fooey=('rand1' 'rand2' 'rand3' 'rand4' 'rand5');

Powershell script not running properly from SCCM [closed]

冷暖自知 提交于 2019-12-10 15:34:48
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . I'm trying to deploy Lego MindStorms through SCCM. I have a PowerShell script that I'm using to start the EXE and do some other things after the install.

how to modify conda 'source activate' ps1 behavior

与世无争的帅哥 提交于 2019-12-08 19:21:14
问题 my current bash ps1 is as follows: bldred='\e[1;31m' # Red bldcyn='\e[1;36m' # Cyan bldwht='\e[1;37m' # White txtrst='\e[0m' # Text Reset - Useful for avoiding color bleed export PS1="\n\[$bldred\]\u\[$txtrst\]@\[$bldwht\]\h\[$txtrst\]:\[$bldcyn\]\w\[$txtrst\]$ " However, running: source activate <env-name-here> by default, tells conda to prepend the env-name to my PS1 : (<env-name-here>) user@short-domain:fullpath$ Is there a way to tell conda to insert the env-name within my PS1 instead,

Use PS0 and PS1 to display execution time of each bash command

女生的网名这么多〃 提交于 2019-12-07 05:45:10
问题 It seems that by executing code in PS0 and PS1 variables (which are eval'ed before and after a prompt command is run, as I understand) it should be possible to record time of each running command and display it in the prompt. Something like that: user@machine ~/tmp $ sleep 1 user@machine ~/tmp 1.01s $ However, I quickly got stuck with recording time in PS0, since something like this doesn't work: PS0='$(START=$(date +%s.%N))' As I understand, START assignment happens in a sub-shell, so it is

Getting a dynamic bash prompt PS1 right

倾然丶 夕夏残阳落幕 提交于 2019-12-07 05:43:37
问题 I'm working on a dynamic bash prompt where I want reported in PS1 which version of a config file is enabled on the local filesystem. This is a contrived example of what I'm trying to do, simplified. The things that are going wrong: bad wrapping and/or escape brackets appearing. Can anyone spot what I'm doing wrong? If the contrived config matches "v2", I want to see that version in PS1 as YELLOW. If it's "v1", in the prompt as GREEN. The setup: $ grep FOOVER foo-*.conf foo-v1.conf:# FOOVER

linux修改终端输入见面颜色

匆匆过客 提交于 2019-12-06 21:18:18
1.PS1 要修改linux终端命令行颜色,我们需要用到PS1,PS1是Linux终端用户的一个环境变量,用来说明命令行提示符的设置。在终端输入命令:#set,即可在输出中找到关于PS1的定义如下: PS1='[\u@\h \W]\$ ' PS1的定义中个常用的参数的含义如下: 符号 作用 \d 代表日期,格式为weekday month date,例如:"Mon Aug 1" \H 完整的主机名称 \h 仅取主机的第一个名字 \t 显示时间为24小时格式,如:HH:MM:SS \T 显示时间为12小时格式 \A 显示时间为24小时格式:HH:MM \u 当前用户的账号名称 \v BASH的版本信息 \w 完整的工作目录名称 \W 利用basename取得工作目录名称,所以只会列出最后一个目录 # 下达的第几个命令 \$ 提示字符,如果是root时,提示符为:#<br>普通用户则为:$ 由此,我们可知linux默认的命令行提示信息为:[当前用户的账号名称@主机的第一个名字 工作目录的最后一项]# 2.颜色的设置 在PS1中设置字符颜色的格式为:[\e[F;Bm],其中“F“为字体颜色,编号为30-37,“B”为背景颜色,编号为40-47。颜色表如下: F B 颜色 30 40 黑色 31 41 红色 32 42 绿色 33 43 ××× 34 44 蓝色 35 45 紫红色 36

short date in bash PS1 prompt

六眼飞鱼酱① 提交于 2019-12-06 16:41:29
问题 You can use \d in the your PS1 confuration to display a long date ie. Tues 18 May, but how can I get it to display it in a format like 18.05.2012 for example? 回答1: Try this: PS1="\$(date +%d.%m.%Y) > " export PS1 回答2: Try including \D{%d.%m.%Y} . You can use any time format suppoorted by strftime(3) . 回答3: Use \D{format } where format is a strftime format code. For example: $ export PS1='\D{%d.%m.%Y}$ ' 08.02.2012$ 回答4: Rather than telling the shell to execute the date command each time, you