[关闭]
@snuffles 2020-08-15T17:55:28.000000Z 字数 1427 阅读 1111

为Linux terminal配置时间分隔线

linux


PS 之前看ning弄得挺漂亮的,今天小折腾一下分隔线。

reference
为OSX和Linux的TERMINAL增加时间分割线

先上效果
using effect


网上能够搜到code,就是不同的系统好像要放在不同的文件下。
我的是Ubuntu 12.04:

  1. cd home/username //注意要ls -a才能看到隐藏的.bashrc
  2. cp .bashrc .bashrc-backup//先存一份原来的配置,方便改回来
  3. sudo gedit home/username/.bashrc //username是自己的用户名字

然后把下面的代码放在.bashrc的后面

  1. ############################################
  2. # Modified from emilis bash prompt script
  3. # from https://github.com/emilis/emilis-config/blob/master/.bash_ps1
  4. #
  5. # Modified for Mac OS X by
  6. # @corndogcomputer
  7. ###########################################
  8. # Fill with minuses
  9. # (this is recalculated every time the prompt is shown in function prompt_command):
  10. fill="--- "
  11. reset_style='\[\033[00m\]'
  12. status_style=$reset_style'\[\033[0;90m\]' # gray color; use 0;37m for lighter color
  13. prompt_style=$reset_style
  14. command_style=$reset_style'\[\033[1;29m\]' # bold black
  15. # Prompt variable:
  16. PS1="$status_style"'$fill \t\n'"$prompt_style"'${debian_chroot:+($debian_chroot)}\u@\h:\w\$'"$command_style "
  17. # Reset color for command output
  18. # (this one is invoked every time before a command is executed):
  19. trap 'echo -ne "\033[00m"' DEBUG
  20. function prompt_command {
  21. # create a $fill of all screen width minus the time string and a space:
  22. let fillsize=${COLUMNS}-9
  23. fill=""
  24. while [ "$fillsize" -gt "0" ]
  25. do
  26. fill="-${fill}" # fill with underscores to work on
  27. let fillsize=${fillsize}-1
  28. done
  29. # If this is an xterm set the title to user@host:dir
  30. case "$TERM" in
  31. xterm*|rxvt*)
  32. bname=`basename "${PWD/$HOME/~}"`
  33. echo -ne "\033]0;${bname}: ${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"
  34. ;;
  35. *)
  36. ;;
  37. esac
  38. }
  39. PROMPT_COMMAND=prompt_command
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注