Compare commits

..

3 Commits

2 changed files with 14 additions and 11 deletions

View File

@ -48,6 +48,8 @@ search_engine: https://duckduckgo.com/?q=
youtube_search: https://www.youtube.com/results?search_query= youtube_search: https://www.youtube.com/results?search_query=
``` ```
Info: file paths are relative to your home directory.
## 🧑‍💻 Usage ## 🧑‍💻 Usage
- 💬 **Regular Commands:** Type any shell command and hit Enter to execute it. - 💬 **Regular Commands:** Type any shell command and hit Enter to execute it.

View File

@ -11,7 +11,7 @@ mkdir -p "$CONFIG_DIR"
if [ ! -f "$CONFIG_FILE" ]; then if [ ! -f "$CONFIG_FILE" ]; then
cat > "$CONFIG_FILE" << EOF cat > "$CONFIG_FILE" << EOF
# Quick Launcher Configuration # Quick Launcher Configuration
log_file: /logs/shrtrun.log log_file: /.logs/shrtrun.log
search_engine: https://duckduckgo.com/?q= search_engine: https://duckduckgo.com/?q=
youtube_search: https://www.youtube.com/results?search_query= youtube_search: https://www.youtube.com/results?search_query=
EOF EOF
@ -30,6 +30,14 @@ get_config_value() {
fi fi
} }
save_to_history() {
cmd="$1"
LAST_HISTORY=$(tail -n 1 "$HISTORY_FILE" 2>/dev/null)
if [ "$cmd" != "$LAST_HISTORY" ]; then
echo "$cmd" >> "$HISTORY_FILE"
fi
}
# Get configuration values # Get configuration values
SEARCH_ENGINE=$(get_config_value "search_engine" "https://duckduckgo.com/?q=") SEARCH_ENGINE=$(get_config_value "search_engine" "https://duckduckgo.com/?q=")
YOUTUBE_SEARCH=$(get_config_value "youtube_search" "https://www.youtube.com/results?search_query=") YOUTUBE_SEARCH=$(get_config_value "youtube_search" "https://www.youtube.com/results?search_query=")
@ -72,13 +80,6 @@ source "$HOME/.profile" 2>/dev/null
source "$HOME/.bashrc" 2>/dev/null source "$HOME/.bashrc" 2>/dev/null
source "$HOME/.bashrc_aliases" 2>/dev/null source "$HOME/.bashrc_aliases" 2>/dev/null
# Avoid duplicate consecutive entries
if [ -n "$USER_INPUT" ]; then
LAST_HISTORY=$(tail -n 1 "$HISTORY_FILE")
if [ "$USER_INPUT" != "$LAST_HISTORY" ]; then
echo "$USER_INPUT" >> "$HISTORY_FILE"
fi
fi
# Check for command # Check for command
if [[ "$USER_INPUT" == \!* ]]; then if [[ "$USER_INPUT" == \!* ]]; then
@ -94,7 +95,7 @@ if [[ "$USER_INPUT" == \!* ]]; then
xdg-open "$SEARCH_URL" &> /dev/null & xdg-open "$SEARCH_URL" &> /dev/null &
disown disown
# Append to history # Append to history
echo "$USER_INPUT" >> "$HISTORY_FILE" save_to_history "$USER_INPUT"
;; ;;
y) y)
# YouTube search # YouTube search
@ -103,7 +104,7 @@ if [[ "$USER_INPUT" == \!* ]]; then
xdg-open "$YOUTUBE_URL" &>/dev/null & xdg-open "$YOUTUBE_URL" &>/dev/null &
disown disown
# Append to history # Append to history
echo "$USER_INPUT" >> "$HISTORY_FILE" save_to_history "$USER_INPUT"
;; ;;
*) *)
show_notification "Unknown Command" "The command '$CMD_TYPE' is not recognized" show_notification "Unknown Command" "The command '$CMD_TYPE' is not recognized"
@ -116,7 +117,7 @@ else
# Execute in background and disown # Execute in background and disown
if eval "$USER_INPUT" &>/dev/null & then if eval "$USER_INPUT" &>/dev/null & then
disown disown
echo "$USER_INPUT" >> "$HISTORY_FILE" save_to_history "$USER_INPUT"
else else
show_notification "Command Failed" "'$USER_INPUT' could not be executed." show_notification "Command Failed" "'$USER_INPUT' could not be executed."
fi fi