Skip to content

Instantly share code, notes, and snippets.

@pastleo
Last active August 29, 2015 14:03
Show Gist options
  • Save pastleo/052cb89f4c17b5663466 to your computer and use it in GitHub Desktop.
Save pastleo/052cb89f4c17b5663466 to your computer and use it in GitHub Desktop.
中興大學資訊工程學系2014招生影片內所使用的BASH程式碼
#!/bin/bash
process_bar()
{
for (( i = 0; i < 50; i++ )); do
printf "\r["
for (( j = 0; j < 50; j++ )); do
if [ "$i" -ge "$j" ]; then
printf "#"
else
printf " "
fi
done
printf "]"
#printf
sleep "0.$((RANDOM/15000))$((RANDOM%100))"
done
echo "$1"
}
# Color codes:
# # Normal Colors
# Black = "0;30"
# Red = "0;31"
# Green = "0;32"
# Yellow = "0;33"
# Blue = "0;34"
# Purple = "0;35"
# Cyan = "0;36"
# White = "0;37"
#
# # Bold
# BBlack = "1;30"
# BRed = "1;31"
# BGreen = "1;32"
# BYellow = "1;33"
# BBlue = "1;34"
# BPurple = "1;35"
# BCyan = "1;36"
# BWhite = "1;37"
#
# # Background
# On_Black = "40"
# On_Red = "41"
# On_Green = "42"
# On_Yellow = "43"
# On_Blue = "44"
# On_Purple = "45"
# On_Cyan = "46"
# On_White = "47"
set_color()
{
if [ $1 ]; then
printf "\033[%sm" $1
else
printf "\033[0m"
fi
}
print_color_line()
{
set_color $2
printf "$1"
set_color
printf "\n"
}
echo "Detecting 主任..."
process_bar
set_color "41"
printf "ERROR: 主任 Not Found!"
set_color
printf "\n\nPreparing rescue mode...\n"
process_bar " DONE!"
printf "\ncat the_X.c\n"
print_color_line " # 觀看 the_X.c 內容" "40"
printf "\n==the_X.c======================\n#include <劉小羊.h>\n\nint main(){\n\tEnable(\"劉小羊\");\n}\n===============================\ng++ the_X.c 劉小羊.exe\n"
print_color_line " # 編譯 the_X.c 檔案成為 劉小羊.exe 執行檔" "40"
process_bar
#set_color "41"
print_color_line "ERROR: Compile Error at line 5" "41"
print_color_line "缺乏 程式設計能力" "41"
print_color_line "缺乏 各項電腦知識" "41"
sleep 1.25
print_color_line "===解決方案=======================" "44"
print_color_line "準備使用資訊培育X計畫..." "44"
process_bar
print_color_line "學習使用 C,C++,Java...,並熟悉問題解決方法,更可以向學長學習更多..." "44"
process_bar " Success!"
print_color_line "學習電腦知識 計算機概論、計算機網路...等" "44"
process_bar " Success!"
print_color_line "加入學校資訊相關學生組織,獲得更多相關學習機會和經驗" "44"
process_bar " Success!"
printf "g++ the_X.c 劉小羊.exe\n"
print_color_line " # 編譯 the_X.c 檔案成為 劉小羊.exe 執行檔" "40"
process_bar " Success!"
printf "./劉小羊.exe\n"
# echo
# echo "Require Skill 程式設計能力"
# echo "Require Knowledge 各項電腦知識"
# set_color
# echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment