1
2
3
4
5
6
7
8 if tty -s; then interactive_shell=1; fi
9
10 [ "$interactive_shell" ] && echo "Running .bash_include"
11
12
13
14 default_tty_setting=`stty -g`
15
16 colorprompting='\[\e[1;31m\]\!\[\e[m\] [\[\e[1;33m\]\u\[\e[m\]@\[\e[1;32m\]\h\[\e[m\] \[\e[1;36m\]\w\[\e[m\]]\$ '
17 nocolorprompting='\! [\u@\h \w]\$ '
18
19 historycountfile="$HOME/.bash_history.count"
20 historybackupfile="$HOME/.bash_history.bak"
21 bgrunfiledir="$HOME/tmp/bgrun-`whoami`"
22 trashdir="$HOME/trash"
23
24 HISTSIZE=1000000
25 HISTFILESIZE=1000000
26 HISTCONTROL=ignoredups:ignorespace
27
28 REALPATH_PROGRAM="realpath"
29
30
31
32
33
34
35 export EDITOR=vim
36 export FCEDIT=vim
37 export PAGER=less
38
39
40
41
42
43
44 alias startcolor='PS1=$colorprompting'
45 alias stopcolor='PS1=$nocolorprompting'
46
47 alias ll='ls -l'
48 alias grep='grep --color=always'
49 alias rm='rm -i'
50 alias cp='cp -pi'
51 alias mv='mv -i'
52 alias jobs='jobs -l'
53 alias less='less -RS'
54
55 alias cccc='LANG=C;LC_ALL=C'
56 alias enus='LANG=en_US.UTF-8;LC_ALL=en_US.UTF-8'
57 alias big5='LANG=zh_TW.Big5;LC_ALL=zh_TW.Big5'
58 alias zhtw='LANG=zh_TW.UTF-8;LC_ALL=zh_TW.UTF-8'
59 alias utf8='LANG=zh_TW.UTF-8;LC_ALL=zh_TW.UTF-8'
60
61 alias savetty='default_tty_setting=`stty -g`'
62 alias resetty='stty $default_tty_setting'
63
64
65
66
67
68
69 function compile_all ()
70 {
71 local noask=0
72 [ "$1" = '' ] && echo "Which file(s) do you want to compile? " && return 1
73 [ "$1" = "-n" ] && noask=1
74 if [ "$noask" = "0" ]; then
75 read -e -p "CFLAGS: " -i "$CFLAGS" NEWCFLAGS
76 read -e -p "LDFLAGS: " -i "$LDFLAGS" NEWLDFLAGS
77 [ "$NEWCFLAGS" '!=' '' ] && CFLAGS=$NEWCFLAGS
78 [ "$NEWLDFLAGS" '!=' '' ] && LDFLAGS=$NEWLDFLAGS
79 else
80 shift
81 fi
82 while [ "$1" '!=' '' ]
83 do
84 local TARGETFILE="`echo "$1" | cut -d . -f 1`"
85 local SUFFIX="`echo "$1" | cut -d . -f 2`"
86 if [ -f "$1" ]; then
87 true
88 else
89 printf\
90 '\e[1;33mWarning\e[0m: Non-existent file or not a regular file\n'
91 shift ; continue
92 fi
93 [ "$TARGETFILE" = "$1" ] && shift && continue
94 if [ "$SUFFIX" = "c" ]; then
95 echo "[CC] $1 -> $TARGETFILE"
96 gcc $CFLAGS "$1" $LDFLAGS -o "$TARGETFILE"
97 elif [ "$SUFFIX" = "cpp" ]; then
98 echo "[CXX] $1 -> $TARGETFILE"
99 g++ $CFLAGS "$1" $LDFLAGS -o "$TARGETFILE"
100 else
101 printf 'Unknown suffix (\e[1;33mskipped\e[0m)\n'
102 fi
103 [ "$?" '!=' "0" ] && printf\
104 '\e[1;31mError\e[0m while compiling file\n'
105 shift
106 done
107 return 0
108 }
109
110
111 function convert_to_html ()
112 {
113 while [ "$1" '!=' '' ]
114 do
115 for i in "$1"
116 do
117 vim $i -c 'set background=dark' \
118 -c 'highlight PreProc ctermfg=darkcyan' \
119 -c "$BEFORE_CONVERT_TO_HTML" \
120 -c "$BEFORE_CONVERT_TO_HTML1" \
121 -c "$BEFORE_CONVERT_TO_HTML2" \
122 -c TOhtml \
123 -c :w \
124 -c :qa
125 done
126 shift
127 done
128 }
129
130 function mkscreenacl ()
131 {
132 PERMIT_COMMAND="select windowlist other meta detach reset hardcopy info redisplay lastmsg next prev xon xoff windows suspend help colon copy paste writebuf readbuf displays stuff attach"
133 while [ "$1" '!=' '' ]
134 do
135 for i in $PERMIT_COMMAND
136 do
137 echo "aclchg $1 +x $i"
138 done
139 echo "aclchg $1 -rw \"#?\""
140 shift
141 done
142 }
143
144
145
146 alias bgr=bgrun
147 alias bgv=bgview
148 alias bgl=bglist
149 alias bgc=bgcount
150 alias bgls=bglist
151 alias bgrm=bgclean
152
153 function bgrun ()
154 {
155 [ "$#" = "0" ] && return 1
156 [ '!' -d "$bgrunfiledir" ] && mkdir -p "$bgrunfiledir"
157 local current_time=`date "+%Y%m%d-%H%M%S"`
158 local cmdname=`echo "$1" | sed -e 's/-/_/g' -e 's/\\//_/g' -e 's/ /_/g'`
159 if [ "`echo "$cmdname" | cut -c 1`" == "_" ]
160 then
161 cmdname=`echo "$cmdname" | cut -c 2-`
162 fi
163 local filename="$bgrunfiledir/$current_time-$cmdname"
164 echo "Writing to $filename"
165 echo "$@" > $filename
166 "$@" &>> "$filename" &
167 }
168
169 function bglist ()
170 {
171 local viewtime=0
172 [ "$1" = "--full" ] && viewtime=1
173 {
174 for i in `find "$bgrunfiledir" -maxdepth 1 -mindepth 1 | sort`
175 do
176 [ "$viewtime" == "1" ] && echo "$i"
177 head -n 1 "$i"
178 done
179 } | {
180 if [ "$viewtime" == "1" ]
181 then
182 local readstat=0
183 local -i i=1
184 while true
185 do
186 local dateandtime_long
187 local cmdline
188 read dateandtime_long
189 read cmdline
190 [ "$?" '!=' "0" ] && break
191 local dateandtime=`basename "$dateandtime_long"`
192 local part_year=`echo $dateandtime | cut -c 1-4`
193 local part_month=`echo $dateandtime | cut -c 5-6`
194 local part_date=`echo $dateandtime | cut -c 7-8`
195 local part_hour=`echo $dateandtime | cut -c 10-11`
196 local part_minute=`echo $dateandtime | cut -c 12-13`
197 local part_second=`echo $dateandtime | cut -c 14-15`
198 printf '%6d' "$i"
199 echo " $part_year-$part_month-$part_date $part_hour:$part_minute:$part_second $cmdline"
200 i=$i+1
201 done
202 else
203 cat -n
204 fi
205 } | $PAGER
206 }
207
208 function bgview ()
209 {
210 local -i yourchoice
211 if [ "$1" = "" ]
212 then
213 yourchoice=`bgcount`
214 else
215 if [ "$1" -le "0" ]
216 then
217 yourchoice=$((`bgcount`+$1))
218 else
219 yourchoice=$1
220 fi
221 fi
222 echo "Your choice is $yourchoice."
223 local realfilename=`find "$bgrunfiledir" -maxdepth 1 -mindepth 1 | sort | sed -n ${yourchoice}p`
224 echo "Command Line: `head -n 1 "$realfilename"`"
225 read -e -p "View '$realfilename' ? " confirm
226 if [ "$confirm" = "n" ] || [ "$confirm" = "N" ]
227 then
228 return 1
229 fi
230 {
231 printf "Command Line: "
232 cat "$realfilename"
233 } | $PAGER
234 }
235
236 function bgcount ()
237 {
238 find "$bgrunfiledir" -maxdepth 1 -mindepth 1 | cut -d - -f 2,3 | wc | awk '{print $2}'
239 }
240
241 function bgclean ()
242 {
243 if [ "$1" = "all" ]
244 then
245 echo "Removing the directory $bgrunfiledir"
246 rm -rf "$bgrunfiledir" &
247 return 0
248 else
249 split_arguments "$@"
250 local -i i=0
251 while [ "${arglist[$i]}" ]
252 do
253 arglist[$i]="-e ${arglist[$i]}p"
254 i=$i+1
255 done
256 local oneline
257 find "$bgrunfiledir" -maxdepth 1 -mindepth 1 | sort | sed -n ${arglist[*]} | {
258 while read oneline
259 do
260 echo "Removing $oneline"
261 rm -f "$oneline"
262 done
263 }
264 fi
265 unset arglist
266 unset prefixlist
267 }
268
269 function bgdu ()
270 {
271 du -a "$bgrunfiledir"
272 }
273
274
275
276 function check_dmesg ()
277 {
278 [ "$#" = "0" ] && return 1
279
280 while true
281 do
282 PREVIOS_DMESG_BUF="$DMESG_BUF"
283 DMESG_BUF="`dmesg`"
284 [ "$PREVIOS_DMESG_BUF" '!=' "$DMESG_BUF" ] && [ "$FIRST_RUN" = "4" ] && echo '===> system message buffer was modified <==='
285 sleep $1
286 [ "$?" '!=' "0" ] && return 1
287 FIRST_RUN=0
288 done
289 }
290
291 function prehistory_backup ()
292 {
293 echo "Backing up current history file"
294 local currentcount=`wc "$HISTFILE" | awk '{print $1}'`
295 [ '!' -f "$historycountfile" ] && touch "$historycountfile"
296 local -i previoushistorycount
297 previoushistorycount=`cat "$historycountfile"`
298 if [ "$currentcount" -lt "$previoushistorycount" ]
299 then
300 printf "\e[1;31mWarning\e[m: Your $HISTFILE may be MODIFIED BY OTHER PROGRAMS!\n"
301 printf "Note: \e[1;33m$currentcount\e[m < $previoushistorycount\n"
302 echo "Your $historycountfile and $historybackupfile will not be overwritten until this problem is fixed."
303 echo " 1. Check your $HISTFILE."
304 echo " 2. Edit your $HISTFILE manually if some unexpected changes are found."
305 echo " (You may need $historybackupfile to do it) "
306 echo " 3. Remove the file $historycountfile."
307 echo " 4. Run the command \`prehistory_backup' again."
308 return 3
309 fi
310 echo "$currentcount" > "$historycountfile"
311 \cp -f "$HISTFILE" "$historybackupfile"
312 }
313
314
315
316 alias trash_put=trash_mv
317
318
319 function trash_mv ()
320 {
321 [ "$#" = "0" ] && return 1
322 [ '!' -d "$trashdir" ] && mkdir -p "$trashdir"
323 local original_path
324 local current_time
325 local -i i=0
326 split_arguments "$@"
327 while [ "${arglist[$i]}" ]
328 do
329 original_path="`$REALPATH_PROGRAM "${arglist[$i]}"`"
330 current_time=`date "+%Y%m%d-%H%M%S"`
331 better_time=`date "+%Y-%m-%d %H:%M:%S"`
332 dirname="`basename "${arglist[$i]}" | sed -e 's/-/_/g' -e 's/ /_/g'`"
333 fulldirname="$trashdir/$current_time-$dirname"
334 mkdir -p "$fulldirname"
335 echo "Move: ${arglist[$i]} -> $fulldirname"
336 "${prefixlist[@]}" mv "${arglist[$i]}" "$fulldirname"
337 echo "$better_time" > "$fulldirname/information.date"
338 echo "$original_path" > "$fulldirname/information.path"
339 i=$i+1
340 shift
341 done
342 unset arglist
343 unset prefixlist
344 }
345
346 function trash_rm ()
347 {
348 echo bb
349 }
350
351 function trash_ls ()
352 {
353 echo cc
354 }
355
356 function trash_cd ()
357 {
358 echo dd
359 }
360
361 function trash_recover ()
362 {
363 echo yy
364 }
365
366 function trash_count ()
367 {
368 echo zz
369 }
370
371 function trash_du ()
372 {
373 split_arguments "$@"
374 local oneline
375 find "$trashdir" -maxdepth 1 -mindepth 1 | sort | {
376 while read oneline
377 do
378 echo "'$oneline'"
379 done
380 } | xargs -n 10 "${prefixlist[@]}" du -s
381 unset arglist
382 unset prefixlist
383 }
384
385
386
387
388
389 alias helpf='help_function'
390 alias helpm='help_myself'
391
392 function print_iconv ()
393 {
394 [ "$1" = "$2" ] && cat && return 0
395 iconv -f "$1" -t "$2"
396 }
397
398 function help_function ()
399 {
400 [ "$#" = "0" ] && {
401 cat << ENDHELPMSG
402 <<< Help >>>
403 help_myself [arguments ...]
404 help_function [functions ...]
405 <<< Group: Background >>>
406 bgrun command [arguments ...]
407 bglist [--full]
408 bgview [number]
409 bgclean [all | numbers ...]
410 bgcount
411 bgdu
412 <<< Group: Trash >>>
413 trash_mv [filename ...] [-- sudo_prefix ...]
414 trash_ls
415 trash_cd [number]
416 trash_recover [number] [-- sudo_prefix ...]
417 trash_rm [all | numbers ...] [-- sudo_prefix ...]
418 trash_count
419 trash_du [-- sudo_prefix ...]
420 <<< Group: PATH Editor >>>
421 path_editor
422 ldpath_editor
423 x split_path
424 x update_path
425 <<< Other >>>
426 compile_all [-n] filename ...
427 convert_to_html filename ...
428 mkscreenacl username ...
429 check_dmesg seconds
430 prehistory_backup
431 check_important_files
432 backup_file filename ... [-- sudo_prefix ]
433 keep_sudo_credential [seconds]
434 x split_arguments [arguments ...]
435 ENDHELPMSG
436 } && return 0
437 local current_charset=`echo "$LC_ALL" | cut -d . -f 2`
438 local -i i
439 while [ "$1" ]
440 do
441 case "$1" in
442 "help_myself")
443 cat << ENDHELPMSG | print_iconv "UTF-8" "$current_charset"
444 help_myself
445 一個測試命令列的小函式
446 ENDHELPMSG
447 ;;
448 "help_function")
449 cat << ENDHELPMSG | print_iconv "UTF-8" "$current_charset"
450 help_function
451 顯示 .bash_include 提供的額外函式清單
452 註:前方加上「x」符號者表示此為內部使用的函式,不宜直接使用
453 ENDHELPMSG
454 ;;
455 "bgrun")
456 cat << ENDHELPMSG | print_iconv "UTF-8" "$current_charset"
457 bgrun command [arguments ...]
458 執行指令 command 並將輸出導入檔案
459 註:此函式會自動以目前時間和指令名稱為檔案命名
460 ENDHELPMSG
461 ;;
462 "bglist")
463 cat << ENDHELPMSG | print_iconv "UTF-8" "$current_charset"
464 bglist [--full]
465 列出所有使用 bgrun 執行的指令
466 若加上 --full 選項,則可同時察看時間
467 ENDHELPMSG
468 ;;
469 "bgview")
470 cat << ENDHELPMSG | print_iconv "UTF-8" "$current_charset"
471 bgview [number]
472 顯示以 bgrun 執行指令的輸出,若省略 number,表示是最近一次執行的指令
473 若 number > 0,
474 表示第 number 個指令 (此數值可由 bglist 函式取得)
475 若 number <= 0,
476 表示第「指令總數-number」個指令 (指令總數可由 bgcount 函式取得)
477 ENDHELPMSG
478 ;;
479 "bgclean")
480 cat << ENDHELPMSG | print_iconv "UTF-8" "$current_charset"
481 bgclean [all | numbers ...]
482 bgclean all 可清除所有指令的輸出檔
483 bgclean 3 5 7 10 表示清除第 3、5、7、10 個指令輸出檔 (編號可由 bglist 取得)
484 ENDHELPMSG
485 ;;
486 "bgcount")
487 cat << ENDHELPMSG | print_iconv "UTF-8" "$current_charset"
488 bgcount
489 顯示指令輸出檔總數
490 ENDHELPMSG
491 ;;
492 "bgdu")
493 cat << ENDHELPMSG | print_iconv "UTF-8" "$current_charset"
494 bgdu
495 顯示每個指令輸出檔的檔案大小 (單位:KB)
496 ENDHELPMSG
497 ;;
498 *)
499 echo "Help message for $1 is not found"
500 ;;
501 esac
502 shift
503 done
504 }
505
506 function help_myself ()
507 {
508 echo "argc = $#"
509 echo "argv[0] = $0"
510 i=1
511 while [ "$1" ]
512 do
513 echo "argv[$i] = $1"
514 i=$(($i+1))
515 shift
516 done
517 }
518
519
520
521 function split_arguments ()
522 {
523 local argcount=$#
524 local -i i=0
525 local prefix_start=0
526 while [ "$1" ]
527 do
528 if [ "$prefix_start" == "0" ]
529 then
530 if [ "$1" = "--" ]
531 then
532 prefix_start=1
533 i=0
534 shift
535 continue
536 else
537 arglist[$i]="$1"
538 fi
539 else
540 prefixlist[$i]="$1"
541 fi
542 i=$i+1
543 shift
544 done
545 }
546
547 function check_important_files ()
548 {
549 IMPORTANT_FILES='.screenrc .vimrc'
550 for i in $IMPORTANT_FILES
551 do
552 [ '!' -f "$i" ] && printf "\e[1;31mWarning\e[m: \e[1;33m$i\e[m does not exist.\n"
553 done
554 }
555
556
557
558 function split_path ()
559 {
560 local fifoname="$HOME/`uuidgen`"
561 mkfifo "$fifoname"
562 local -i i=0
563 local oneline
564 export patharr
565 echo "$current_path" | sed -e 's/:/ /g' | xargs -n 1 echo > "$fifoname" &
566 exec 3<"$fifoname"
567 while read -u 3 patharr[$i]
568 do
569 i=$i+1
570 done
571 exec 3<&-
572 unlink "$fifoname"
573 echo $oneline
574 }
575
576 function update_path ()
577 {
578 current_path=''
579 local -i i=0
580 local firsttime="yes"
581 while [ "${patharr[$i]}" ]
582 do
583 if [ '!' "${patharr[$i]}" = ":" ]
584 then
585 if [ "$firsttime" ]
586 then
587 firsttime=''
588 else
589 current_path+=':'
590 fi
591 current_path+="${patharr[$i]}"
592 fi
593 i=$i+1
594 done
595 }
596
597 function path_editor ()
598 {
599 export current_path="$PATH"
600 local should_continue="yes"
601 local command
602 local command_sub
603 local command_sub2
604 local -i i
605 while [ "$should_continue" ]
606 do
607 split_path
608 i=0
609 while [ "${patharr[$i]}" ]
610 do
611 echo "$i: ${patharr[$i]}"
612 i=$i+1
613 done
614 read -e -p "(A)ppend/(D)elete/(E)dit/(M)ove/(R)eset/(Q)uit ? " command
615 case "$command" in
616 A|a)
617 read -e -p "Type new entry: " patharr[$i]
618 update_path
619 ;;
620 D|d)
621 read -e -p "Line: " command_sub
622 patharr[$command_sub]=':'
623 update_path
624 ;;
625 E|e)
626 read -e -p "Line: " command_sub
627 read -e -p "Modify this entry: " -i "${patharr[$command_sub]}" patharr[$command_sub]
628 update_path
629 ;;
630 M|m)
631 read -e -p "Exchange: " command_sub
632 read -e -p "With: " command_sub2
633 swaptmp="${patharr[$command_sub]}"
634 patharr[$command_sub]="${patharr[$command_sub2]}"
635 patharr[$command_sub2]="$swaptmp"
636 unset swaptmp
637 update_path
638 ;;
639 R|r)
640 current_path="$PATH"
641 ;;
642 Q|q)
643 PATH="$current_path"
644 echo "PATH=$PATH"
645 should_continue=''
646 ;;
647 *)
648 echo " *** Unknown command *** "
649 ;;
650 esac
651 done
652 unset patharr
653 }
654
655 function path_editor ()
656 {
657 export current_path="$PATH"
658 local should_continue="yes"
659 local command
660 local command_sub
661 local command_sub2
662 local -i i
663 while [ "$should_continue" ]
664 do
665 split_path
666 i=0
667 while [ "${patharr[$i]}" ]
668 do
669 echo "$i: ${patharr[$i]}"
670 i=$i+1
671 done
672 read -e -p "(A)ppend/(D)elete/(E)dit/(M)ove/(R)eset/(Q)uit ? " command
673 case "$command" in
674 A|a)
675 read -e -p "Type new entry: " patharr[$i]
676 update_path
677 ;;
678 D|d)
679 read -e -p "Index: " command_sub
680 patharr[$command_sub]=':'
681 update_path
682 ;;
683 E|e)
684 read -e -p "Index: " command_sub
685 read -e -p "Modify this entry: " -i "${patharr[$command_sub]}" patharr[$command_sub]
686 update_path
687 ;;
688 M|m)
689 read -e -p "From: " command_sub
690 read -e -p "To: " command_sub2
691 swaptmp="${patharr[$command_sub]}"
692 patharr[$command_sub]="${patharr[$command_sub2]}"
693 patharr[$command_sub2]="$swaptmp"
694 unset swaptmp
695 update_path
696 ;;
697 R|r)
698 current_path="$PATH"
699 ;;
700 Q|q)
701 export PATH="$current_path"
702 echo "PATH=$PATH"
703 should_continue=''
704 ;;
705 *)
706 echo " *** Unknown command *** "
707 ;;
708 esac
709 done
710 unset patharr
711 }
712
713 function ldpath_editor ()
714 {
715 export current_path="$LD_LIBRARY_PATH"
716 local should_continue="yes"
717 local command
718 local command_sub
719 local command_sub2
720 local -i i
721 while [ "$should_continue" ]
722 do
723 split_path
724 i=0
725 while [ "${patharr[$i]}" ]
726 do
727 echo "$i: ${patharr[$i]}"
728 i=$i+1
729 done
730 read -e -p "(A)ppend/(D)elete/(E)dit/(M)ove/(R)eset/(Q)uit ? " command
731 case "$command" in
732 A|a)
733 read -e -p "Type new entry: " patharr[$i]
734 update_path
735 ;;
736 D|d)
737 read -e -p "Index: " command_sub
738 patharr[$command_sub]=':'
739 update_path
740 ;;
741 E|e)
742 read -e -p "Index: " command_sub
743 read -e -p "Modify this entry: " -i "${patharr[$command_sub]}" patharr[$command_sub]
744 update_path
745 ;;
746 M|m)
747 read -e -p "From: " command_sub
748 read -e -p "To: " command_sub2
749 swaptmp="${patharr[$command_sub]}"
750 patharr[$command_sub]="${patharr[$command_sub2]}"
751 patharr[$command_sub2]="$swaptmp"
752 unset swaptmp
753 update_path
754 ;;
755 R|r)
756 current_path="$LD_LIBRARY_PATH"
757 ;;
758 Q|q)
759 export LD_LIBRARY_PATH="$current_path"
760 echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
761 should_continue=''
762 ;;
763 *)
764 echo " *** Unknown command *** "
765 ;;
766 esac
767 done
768 unset patharr
769 }
770
771
772
773 function backup_file ()
774 {
775 split_arguments "$@"
776 local current_time=`date +%Y%m%d`
777 local rootfilename
778 local -i i=0
779 local -i j
780 while [ "${arglist[$i]}" ]
781 do
782 if [ '!' -f "${arglist[$i]}" ]
783 then
784 printf "\e[1;31mError\e[m: ${arglist[$i]} does not exist or it is not a regular file.\n"
785 i=$i+1
786 continue
787 fi
788 rootfilename="${arglist[$i]}.$current_time"
789 if [ -e "$rootfilename" ]
790 then
791 j=0
792 while [ "$j" -lt "10" ]
793 do
794 if [ -e "$rootfilename.$j" ]
795 then
796 j=$j+1
797 continue
798 else
799 "${prefixlist[@]}" \cp "${arglist[$i]}" "$rootfilename.$j"
800 break
801 fi
802 done
803 if [ '!' "$j" -lt "10" ]
804 then
805 printf "\e[1;31mError\e[m: Can not create a backup file for ${arglist[$i]}.\n"
806 printf "\e[1;33mPlease delete some backup file because I only use 0 - 9.\e[m\n"
807 fi
808 else
809 "${prefixlist[@]}" \cp "${arglist[$i]}" "$rootfilename"
810 fi
811 i=$i+1
812 done
813 unset arglist
814 unset prefixlist
815 }
816
817 function keep_sudo_credential ()
818 {
819 if [ "$1" ]
820 then
821 update_sudo_interval="$1"
822 else
823 update_sudo_interval="60"
824 fi
825 while true
826 do
827 sudo -v
828 sleep "$update_sudo_interval"
829 done
830 }
831
832
833
834 if [ "$interactive_shell" ]
835 then
836 echo "Running interactive shell configuration"
837 check_important_files
838 startcolor
839 prehistory_backup
840 bind '"\e[A":history-search-backward'
841 bind '"\e[B":history-search-forward'
842 fi
843
844 [ "`uname`" = "Linux" ] && REALPATH_PROGRAM="readlink -f"
845
846 umask 0022
847
848 [ "$interactive_shell" ] && echo "Setting shell options"
849
850 shopt -s histappend
851 shopt -s checkwinsize
852 shopt -s checkjobs
853 shopt -s checkhash
854 shopt -s cmdhist
855 shopt -s mailwarn
856
857 [ "$interactive_shell" ] && echo "Done"
858