@snuffles
2020-08-15T09:55:28.000000Z
字数 1427
阅读 1151
linux
PS 之前看ning弄得挺漂亮的,今天小折腾一下分隔线。
reference
为OSX和Linux的TERMINAL增加时间分割线
先上效果
网上能够搜到code,就是不同的系统好像要放在不同的文件下。
我的是Ubuntu 12.04:
cd home/username //注意要ls -a才能看到隐藏的.bashrc
cp .bashrc .bashrc-backup//先存一份原来的配置,方便改回来
sudo gedit home/username/.bashrc //username是自己的用户名字
然后把下面的代码放在.bashrc的后面
############################################
# Modified from emilis bash prompt script
# from https://github.com/emilis/emilis-config/blob/master/.bash_ps1
#
# Modified for Mac OS X by
# @corndogcomputer
###########################################
# Fill with minuses
# (this is recalculated every time the prompt is shown in function prompt_command):
fill="--- "
reset_style='\[\033[00m\]'
status_style=$reset_style'\[\033[0;90m\]' # gray color; use 0;37m for lighter color
prompt_style=$reset_style
command_style=$reset_style'\[\033[1;29m\]' # bold black
# Prompt variable:
PS1="$status_style"'$fill \t\n'"$prompt_style"'${debian_chroot:+($debian_chroot)}\u@\h:\w\$'"$command_style "
# Reset color for command output
# (this one is invoked every time before a command is executed):
trap 'echo -ne "\033[00m"' DEBUG
function prompt_command {
# create a $fill of all screen width minus the time string and a space:
let fillsize=${COLUMNS}-9
fill=""
while [ "$fillsize" -gt "0" ]
do
fill="-${fill}" # fill with underscores to work on
let fillsize=${fillsize}-1
done
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
bname=`basename "${PWD/$HOME/~}"`
echo -ne "\033]0;${bname}: ${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"
;;
*)
;;
esac
}
PROMPT_COMMAND=prompt_command