Enhancing Quranic Study with a Command-Line Quran Search and Display Script
Category: Shell Scripting
Date: 7 months ago
Views: 1.06K
In the modern digital age, technology plays a significant role in facilitating various aspects of religious study and practice. Among the numerous religious texts revered by millions worldwide, the Quran holds a central position in Islam. To aid in the exploration and comprehension of this sacred scripture, a novel approach emerges—a command-line Quran search and display script. This article delves into the functionality, usage, and significance of such a tool in the context of Quranic study.
Understanding the Script
script_dir=$(dirname "$0")
file1="$script_dir/quran-simple-clean.txt"
file2="$script_dir/quran-uthmani.txt"
file3="$script_dir/chapters-simple.txt"
quran_text="$(paste -d'|' "$file1" "$file2" )"
# the command-line arguments
number1=$1
number2=$2
number3=$3
print_lines() {
chapter_name=$(sed -n "$2"p "$file3" )
echo "$1" | awk -F '|' -v num1="$2" -v num2="$3" -v num3="$4" -v chap="$chapter_name" \
'{
if ((num3 != "") && ($1 == num1) && ($2 >= num2) && ($2 <= num3)) {
printf("(\033[1;31m %d %s\033[1;0m) %s\n",$5,chap,$6);
} else if ((num2 != "") && (num3 == "") && ($1 == num1) && ($2 == num2)) {
printf("(\033[1;31m %d %s\033[1;0m) %s\n",$5,chap,$6);
} else if ((num2 == "") && (num3 == "") && ($1 == num1)) {
printf("(\033[1;31m %d %s\033[1;0m) %s\n",$5,chap,$6);
}
}'
}
if [[ $1 == h ]] ; then
echo "Usage:
$(basename "$0")
$(basename "$0") g open with uthmani Quran in gedit
$(basename "$0") [sourah/chapter] [num1] [num2]"
exit
fi
if [[ $1 == g ]] ; then
nohup gedit "$file2" </dev/null >/dev/null 2>&1 &
exit
fi
number='^[0-9]+$'
if [[ "$1" =~ $number ]] ; then
if [ -z "$number2" ]; then
text=$(print_lines "$quran_text" "$number1")
elif [[ -z "$number3" ]]; then
text=$(print_lines "$quran_text" "$number1" "$number2")
else
text=$(print_lines "$quran_text" "$number1" "$number2" "$number3")
fi
if [[ $@ == *g* ]]
then
echo "$text" > /tmp/quran_result
nohup gedit "/tmp/quran_result" </dev/null >/dev/null 2>&1 &
else
echo "$text"
fi
else
xkb-switch -s ara
pkill -RTMIN+12 i3blocks
pattern=$( zenity --entry --text="Search Holy Quran:" \
--title="search Holy Quran" --width=500 --timeout=30)
xkb-switch -s fr
pkill -RTMIN+12 i3blocks
if [[ -n $pattern ]] ; then
results="$(echo "$quran_text" | grep --color=always "$pattern")"
if [[ -n $results ]]
then resuls_count=$(echo "$results" | wc -l)
else resuls_count=0
fi
echo "searching : $pattern"
echo "================================"
echo "$resuls_count found"
echo "================================"
echo "$results" > /tmp/quran_result
awk -F'|' '
NR==FNR {chap[FNR]=$0; next}
{printf("(\033[1;31m %d %s\033[1;0m) %s\n",$5,chap[$1],$6);}
' "$file3" /tmp/quran_result
fi
fi
The command-line Quran search and display script is a versatile tool designed to streamline the process of accessing and studying verses from the Quran. Written in the Bash scripting language, this script leverages a combination of Unix commands such as 'sed', 'awk', 'paste', 'zenity', and 'xkb-switch' to provide users with a seamless experience.
Features and Usage
The script offers several features tailored to cater to the diverse needs of users engaging with the Quran:
• Interactive Search: Users can initiate an interactive search prompt, enabling them to search for specific keywords or phrases within the Quranic text.
• Verse Display: By providing chapter and verse numbers as command-line arguments, users can display specific verses from the Quran.
• Visual Enhancement: The script incorporates color-coded output for improved readability, enhancing the user experience during verse display.
• Integration with Text Editor: Users can seamlessly open the Uthmani version of the Quran in the 'gedit' text editor directly from the command line.
Significance in Quranic Study
The command-line Quran search and display script serves as a valuable tool for both scholars and enthusiasts alike:
• Accessibility: By offering a command-line interface, the script provides accessibility to users across various platforms without the need for complex software installations.
• Efficiency: With its streamlined search and display capabilities, the script enables users to quickly retrieve and study specific verses, enhancing the efficiency of Quranic study sessions.
• Customization: The script's modular design allows for easy customization and adaptation to specific study preferences or requirements, catering to the diverse needs of users.
GitHub Repository
The script along with the Quran text files can be found in the GitHub repository: https://github.com/neoMOSAID/quran-search. Users can access, contribute, and provide feedback on the script and its associated resources.
Conclusion
In the realm of Quranic study, the command-line Quran search and display script emerges as a versatile and efficient tool, empowering users to delve deeper into the sacred text with ease and convenience. Its integration of modern technology with traditional scholarship exemplifies the harmonious intersection of faith and innovation, facilitating a richer and more immersive Quranic study experience for all.
0 Comments, latest
No comments.