Skip to content

Commit 54f9bdb

Browse files
committed
initializer changes
1 parent 9c702b6 commit 54f9bdb

File tree

4 files changed

+13
-26
lines changed

4 files changed

+13
-26
lines changed

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@ dist: smile
2626
@cp ./smile $(TARGET)
2727

2828
install: all
29+
sudo chmod 755 initializer/initializer.sh
30+
bash initializer/initializer.sh
31+
@sudo test -d /usr/bin/smile && sudo rm -rf /usr/bin/smile
2932
@sudo mv $(TARGET) /usr/bin/smile
30-
@echo "Installation complete. Smile is available in /usr/bin"
33+
@echo "Installation complete. Smile is available in /usr/bin"

initializer/initializer.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
echo "Checking if the command_not_found_handle is in the .bashrc file..."
4+
if ! grep -q 'command_not_found_handle' ~/.bashrc; then
5+
echo "Initializer: the command_not_found_handle is not in the .bashrc file. Appending it..."
6+
cat ./initializer/command_not_found_handle.sh >> ~/.bashrc
7+
else
8+
echo "Initializer: the command_not_found_handle is already in the .bashrc file"
9+
fi

initializer/initialzer.sh

-6
This file was deleted.

src/main.cpp

-19
Original file line numberDiff line numberDiff line change
@@ -121,23 +121,6 @@ bool suggestCommands(const po::variables_map vm, std::string inputCommand, Setti
121121
return true;
122122
}
123123

124-
/**
125-
* Ensures that the `command_not_found_handle` function is present in the `.bashrc` file by running the initializer script.
126-
*
127-
* @return int Returns 0 if the script executes successfully, otherwise returns a non-zero value on failure.
128-
*/
129-
int ensureCommandNotFoundHandler() {
130-
int result = system("bash initializer/initialzer.sh");
131-
132-
if (result == 0)
133-
spdlog::info("Initializer script successfully executed.");
134-
else
135-
spdlog::error("Error executing the initializer script. Return code: {}", result);
136-
137-
return result;
138-
}
139-
140-
141124
int main(int argc, char* argv[]) {
142125

143126
std::string inputCommand;
@@ -188,8 +171,6 @@ int main(int argc, char* argv[]) {
188171

189172
Settings settings;
190173

191-
ensureCommandNotFoundHandler();
192-
193174
//TODO: enable database insertion for history if enabled
194175

195176
//TODO: order results by most similar characters from the start to give more appropriate results?

0 commit comments

Comments
 (0)