1. 程式人生 > >一個shell腳本,讓你的linux命令行酷炫起來

一個shell腳本,讓你的linux命令行酷炫起來

bashrc exe print eth1 ps1 sysv echo png end

#!/bin/bash

# This program is to modify showed marked
#
# biaoshi.sh 207
# by wangxianzheng 2011/12/20

PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
echo "########execute $0 begin...##############"

SYSVER=$(head -n 1 /etc/issue |awk ‘{print $3}‘)

function modify_bashrc(){
echo "DST=$(NETCARD=$( ifconfig |grep -B1 192.168 |awk ‘/eth/ {if ($1=="eth1") print "eth1"; else print "eth0"}‘ |head -1) ;ifconfig |awk ‘{if(a) {split($0,b,"addr:| Bcast:");print b[2]} ;a=0}/‘"$NETCARD"‘/{a=1}‘ |head -1)"
sed -i -e"/PS1/ s#PS1=\"\[.*\\\.*\]#PS1=\"\\\[\\\e\[1;32m\\\]\[\\\u\@\\\[\\\e\[m\\\]\\\[\\\e\[1;36m\\\]\$\(NETCARD=\$\(ifconfig \|grep -B1 192.168 \|awk \‘/eth/ \{if \(\$1==\"eth1\"\) print \"eth1\"\; else print \"eth0\"\}\‘ \|head -1\) \;ifconfig \|awk \‘\{if\(a\) \{split\(\$0\,b\,\"addr\:\| Bcast\:\")\;print b\[2\]\} \;a=0\}/\‘\"\$NETCARD\"\‘/\{a=1\}\‘ \|head -1\)\\\[\\\e\[m\\\]\\\[\\\e\[1;32m\\\] \\\w\]\\\[\\\e\[m\\\]# " /etc/bashrc

sed -i "s/PROMPT_COMMAND=‘echo/PROMPT_COMMAND=‘‘; #‘echo/" /etc/bashrc
}

case $SYSVER in
4.6)
echo "The current system VER $SYSVER"
modify_bashrc
;;
5.4)
echo "The current system VER $SYSVER"
modify_bashrc
;;
*)
echo "The current system don‘t know $SYSVER"
modify_bashrc
;;
esac


echo "########execute $0 end...##############"

技術分享

一個shell腳本,讓你的linux命令行酷炫起來