📄 qd
字号:
#!/bin/sh#Quick enter your content. Use slackware of linux.#You can used/modified any codes.#qdir version is 1.00.#Writen by yxp 2002-04-11 started. setup_content=/etc/qdirhistory_dir=$setup_content/history_dirusage(){ echo "qd(quick dir) version 1.01 commant format:" echo "<qd -s content [position]> then add a content to $history_dir." echo "if content = ./, then add current content to $history_dir." echo "if position(1-20) is not, default value equal 1." echo "" echo "<qd -d [position]> then delete a content from $history_dir." echo "if position is not, default value equal last." echo "" echo "<qd -l [position]> then list contents from $history_dir." echo "if position is not, default value equal 1, else list all contents, then choice one position's content and enter it." echo "" echo "<qd -e [position]> then enter a content from $history_dir." echo "if position is not, default value equal 1." echo "" echo "<qd -c> then clear $history_dir." exit 1}handle(){ line_num=`wc -l $history_dir | awk '{print $1}'` h_setup_content=/etc/qdir h_history_dir=$h_setup_content/history_dir tmp=$h_setup_content/tmp pos=1 enter_dir="" if [ "$1" = "-s" ] then [ ! $3 ] || pos=$3 enter_dir=$2 [ ! "$2" = "./" ] || enter_dir=`pwd` [ ! "$2" = "." ] || enter_dir=`pwd` if [ $pos -gt $line_num ] then pos=`expr $line_num + 1` echo "$pos $enter_dir" >> $h_history_dir exit 1 fi# [ ! $pos -gt $line_num ] || pos=`expr $line_num + 1`# [ ! $line_num -gt 20 ] || ! echo "have 20 contents in $h_history_dir" \# || exit 1 [ ! $line_num -eq 0 ] || ! echo "$pos $enter_dir" >> $h_history_dir || exit 1 flag="" new_num=0 > $tmp cat $h_history_dir | while read num content do new_num=`expr $new_num + 1` [ ! $flag ] || num=`expr $num + 1` [ ! $num -gt 20 ] || exit 1 if [ $num -eq $pos ] then flag="have" echo "$pos $enter_dir" >> $tmp new_num=`expr $new_num + 1` echo "$new_num $content" >> $tmp else echo "$new_num $content" >> $tmp fi done mv $tmp $h_history_dir fi#***************************************************************************** if [ "$1" = "-l" ] then [ ! $2 ] || ! pos=$2 || ! cat $h_history_dir | grep "^$pos " || exit 1 cat $h_history_dir fi#***************************************************************************** if [ "$1" = "-e" ] then if [ $2 ] then for x in `cat $h_history_dir | cut -d' ' -f1` do if [ "$x" = "$2" ] then enter_dir=`cat $h_history_dir | grep "^$2 " | sed "s/$2 //"` echo "$enter_dir" > $QD exit 1 fi done cat $h_history_dir echo "Not content number $2" exit 1 fi cat $h_history_dir echo -n "Press <Entere> to exit or enter your choice(1-$line_num/q/Q/): " while read choice do if [ "$choice" = "q" -o "$choice" = "Q" ] then echo "Nothing to do!" exit 1 fi [ "$choice" ] || { echo "Nothing to do!" exit 1 } for x in `cat $h_history_dir | cut -d' ' -f1` do if [ "$x" = "$choice" ] then enter_dir=`cat $h_history_dir | grep "^$choice " | sed "s/$choice //"` echo "$enter_dir" > $QD exit 1 fi done echo -n "Press <Entere> to exit or enter your choice(1-$line_num/q/Q/): " done fi#***************************************************************************** if [ "$1" = "-d" ] then pos=$line_num [ ! $2 ] || pos=$2 [ ! $pos -gt $line_num ] || ! echo "in $h_history_dir, only have $line_num contents " || exit new_num=0 > $tmp cat $h_history_dir | while read num content do new_num=`expr $new_num + 1` if [ $num -eq $pos ] then new_num=`expr $new_num - 1` echo "delete: $num $content" else echo "$new_num $content" >> $tmp fi done mv $tmp $h_history_dir fi#***************************************************************************** if [ "$1" = "-c" ] then echo -n "Are you sure to clear $h_history_dir(y\Y or q\Q)? " while read choice do if [ "$choice" = "y" -o "$choice" = "Y" ] then > $h_history_dir echo "clear $h_history_dir OK!" exit 1 fi if [ "$choice" = "q" -o "$choice" = "Q" ] then echo "Nothing to do!" exit 1 fi echo -n "Are you sure to clear $h_history_dir(y\Y or q\Q)? " done fi}[ $# -eq 0 ] && handle -e if [ $# -gt 3 ]then usagefi case $1 in-s) [ $2 ] || usage handle $1 $2 $3 ;;-d) [ ! $3 ] || usage handle $1 $2 ;;-l) [ ! $3 ] || usage handle $1 $2 ;;-e) [ ! $3 ] || usage handle $1 $2 ;; -c) [ ! $3 ] || usage [ ! $2 ] || usage handle $1 ;;*) usage ;;esac
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -