修改 mysql/oracle/bash/vimrc/cmd 提示符格式与颜色
(1)修改mysql提示符:
MySQL 客户端的默认提示符是 "mysql>",基本上没什么实际作用。其实可以修改这个提示符,让它显示一些有用的信息,例如当前所在的数据库等。修改方法有四种,其中前两种只对当前连接有效,后两种则对所有连接有效。
我的建议:vi /etc/my.cnf
[mysql]
prompt=\u@\h: \d \r:\m:\s>
效果:
mysql -uroot -proot
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.5.22-log Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
root@localhost : (none) 07:15:23>use mysql
Database changed
root@localhost : mysql 07:15:30>
root@localhost : mysql 07:16:52>
1、连接客户端时通过参数指定。
mysql --prompt="(u@h) [d]> "
这样提示符就会变成 (user@host) [database]>
还有更多可以可以参考官方文档 4.5.1.2. mysql Commands
2、连接上客户端后,通过 prompt 命令修改。
prompt (u@h) [d]>
3、在 MySQL 的配置文件中配置。
[mysql]
prompt=(\u@\h) [\d]>\_
4、通过环境变量配置。
export MYSQL_PS1="(u@h) [d]> "
其中h表示主机而d表示数据库,更多设置如下(以下摘自MySQL手册)
v 服务器版本
d 当前的数据库
h 服务器主机
p 当前的TCP/IP端口或套接字文件
u 你的用户名
U 你的全user_name@host_name账户名
\ ‘’反斜线字符
n 新行字符
t Tab字符
空格(反斜线后面的空格)
_ 空格
R 当前的时间,24-小时军用时间(0-23)
r 当前的时间,标准12-小时(1-12)
m 当前时间的分钟
y 当前的年,两位
Y 当前的年,四位
D 当前的日期
s 当前时间的秒
w 当前周的天,3字符格式(Mon,T ,...)
P am/pm
o 当前的月,数字格式
O 当前的月,3字符格式(Jan,Feb,...)
c 随发出的每个语句递增的计数
S 分号
' 单引号
" 双引号
以上内容在window及linux环境下测试通过,请放心使用。
REF:
http://renial.iteye.com/blog/773675
http://blog.163.com/yang_jianli/blog/static/1619900062011283527540/
(2)oracle提示符修改:
修改 C:oracleproduct11.2.0dbhomesqlplusadminglogin.sql
SET SQLPROMPT "_USER'@'_CONNECT_IDENTIFIER> "
set serveroutput on
--显示当前时间
set time on
--显示语句执行时间
set timing on
--DEFINE _EDITOR=vim
set linesize 140
效果:
21:36:57 SCOTT@orcl> select * from test1 minus select * from test2;
ID NAME
---------- ----------
11 dongruan
111 yg
REF: http://blog.csdn.net/tianlesoftware/article/details/6412769
(3)修改 linux bash shell vimrc 提示符:
请参考:http://www.linuxfocus.org/ChineseGB/May2004/article335.shtml
ip2=`ip a 2>/dev/null|grep 'eth0$'|grep -Po '(d{1,3}.d{1,3})(?=/)'` ip2=`ip a 2>/dev/null|grep 'eth0$'|grep -Po '((d{1,3}.){3}d{1,3})(?=/)'` alias june='eval "PS1="[e[36;1m]u[e[0m]@[e[33;1m]h[e[40;35;9m $ip2 e[0m]e[40;34;1mt e[0m[e[31;1m]w [e[0m]>n""'
vimrc 配置范例:
https://github.com/acumon/misc/blob/master/.vimrc
https://github.com/joedicastro/dotfiles/tree/master/vim
man page 颜色范例:
(1)配色 1:
export LESS_TERMCAP_mb=$'e[01;31m'
export LESS_TERMCAP_md=$'e[01;35m'
export LESS_TERMCAP_me=$'e[0m'
export LESS_TERMCAP_se=$'e[0m'
export LESS_TERMCAP_so=$'e[01;33m'
export LESS_TERMCAP_ue=$'e[0m'
export LESS_TERMCAP_us=$'e[04;36m'
(2)配色 2:
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'
.bashrc 完整范例:
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
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'
export HISTSIZE=5000
export HISTTIMEFORMAT='[%F %T] '
shopt -s histappend
export PROMPT_COMMAND=
export EDITOR=vim
export LANG=zh_CN.utf8
export PATH=$PATH:.:/opt/soft/python-2.7.11/bin
IP=`/sbin/ip a 2>/dev/null|grep -iE '(em1|eth0)$'|grep -Po '((d{1,3}.){3}d{1,3})(?=/)'`
#HOST_NAME=dop_online${IP##*.}
. .hostname
#alias june='eval "PS1="[e[36;1m]u[e[0m]@[e[33;1m]h[e[40;35;9m $ip e[0m]e[40;34;1mt e[0m[e[31;1m]w [e[0m]>n""'
#export PS1='[u@h W]$'
export PS1="[e[36;1m]u[e[0m]@[e[33;1m]$HOST_NAME[e[40;35;9m $IP e[0m]e[40;34;1mt e[0m[e[31;1m]w [e[0m]>n"
alias rp='realpath'
alias grep='grep --color'
alias ls='ls --color=tty'
alias vi='vim'
alias cmd='cd /opt/script/rpcMonitor && python exec_cmd.py'
alias lh='ls -ld `pwd`/.[^.]*'
#export KRB5CCNAME=/tmp/krb5cc_pub_$$
#trap kdestroy 0 1 2 3 5 15
kinit -k -t /etc/krb5.keytab
myScp(){
[[ $1 == "" ]] || [[ $2 == "" ]] && echo "请输入源文件与目标文件路径,如:myScp ~/a.txt /work" && return
for ip in `cat ~/.ip_list`
do
echo -e "nn==========>>>>>>>>>>>>$ip:"
rsync -avz $1 work@$ip:$2
done
}
#baseDir=/root/tmp
#cd $baseDir
#userDir=`echo $SSH_CLIENT|awk '{print $1}'`
changeDir(){
echo "--------------------------------------------------------------------"
echo -e "e[41;37;1m 欢迎登录,系统使用注意事项如下: e[0m"
echo -e "e[41;37;1m 1、第一次登录请在 /home/work 下新建自己名字的目录(比如 mkdir -p ~/your_name ),私人文件请都放在自己的目录下。e[0m"
echo -e "e[41;37;1m 2、应用、服务请部署到 /opt 下对应的目录,比如 web soft script log 等等。e[0m"
echo -e "e[41;37;1m 3、由于一台机器会多人使用,请勿随意放置文件、安装程序,有需要请联系 your_name 统一规划。e[0m"
echo "--------------------------------------------------------------------"
}
[[ $- == *i* ]] && changeDir
(4)修改 windows cmd 提示符:
新建 prompt 环境变量,具体含义 help prompt
具体效果步骤请参考:
http://hi.baidu.com/leejun_2005/item/0e29f4bad4bca5a0ebba9373
http://hi.baidu.com/leejun_2005/item/4459eb7a2c314e3b70442353
(5)bash color 详解
Escape sequences
You’ve probably seen things like e[32m
or x1b[1;31m
. These are ANSI escape codes used for defining a color. All ANSI escape sequences start with, well, ESC
. There’re several ways of encoding an ESC
:
Shell |
e |
---|---|
ASCII Hex |