-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript
More file actions
executable file
·103 lines (90 loc) · 2.21 KB
/
script
File metadata and controls
executable file
·103 lines (90 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
filename=$1
# create a new file with touch
touch $filename
if [ ! -s $filename ]; then
echo "File is empty. Please add content to file before proceeding."
read -p "Do you want to add content to the file now? (y/n): " choice
if [ "$choice" = "y" ]; then
echo "Please select a text editor to add content to file:"
select text_editor in "vi" "emacs" "nano"
do
case $text_editor in
vi )
vi $filename
echo "File content added using vi editor."
break
;;
emacs )
emacs $filename
echo "File content added using emacs editor."
break
;;
nano )
nano $filename
echo "File content added using nano editor."
break
;;
*)
echo "Invalid option. Please select a valid text editor."
esac
done
else
echo "Aborting script."
exit
fi
else
read -p "Do you want to edit the file? (y/n):" edit_choice
if [ "$edit_choice" = "y" ]; then
echo "Please select a text editor to add content to file:"
select text_editor in "vi" "emacs" "nano"
do
case $text_editor in
vi )
vi $filename
echo "File content added using vi editor."
break
;;
emacs)
emacs $filename
echo "File content added using emacs editor."
break
;;
nano )
nano $file
echo "File content added using nano editor."
break
;;
*)
echo "Invalid option. Please select a valid text editor."
esac
done
fi
fi
# change the execute permission for the owner of the file
read -p "Do you want to set file permissions? (y/n):" perm_choice
if [ "$perm_choice" = "y" ]; then
read -p "Enter the permission value (e.g. 755):" perm_value
chmod $perm_value $filename
echo "File permissions set to $perm_value"
else
chmod u+x $filename
echo "File permissions set to u+x for owner"
fi
# add the file to git
read -p "Do you want to push changes to remote repository? (y/n):" push_choice
if [ "$push_choice" = "y" ]; then
git add $filename
# prompt the user for a commit message
#
read -p "Enter a commit message:" commit_message
# commit the changes to the local repository
git commit -m "$commit_message"
# push the changes to the remote repository
git push
# Task Completed
echo "Changes pushed to remote repository"
echo "Task Completed Successfully, Good Job!!!"
fi
sleep 1
echo "Good bye $(git config user.name)"