Skip to content

Instantly share code, notes, and snippets.

@sourab-jadav
Created June 8, 2024 08:47
Show Gist options
  • Save sourab-jadav/46800e7a740afe9f077853dd1427375e to your computer and use it in GitHub Desktop.
Save sourab-jadav/46800e7a740afe9f077853dd1427375e to your computer and use it in GitHub Desktop.
fuzzy finds through the commands
#!/bin/bash
# Path to the commands file
COMMANDS_FILE=~/commands.txt
# Check if the commands file exists
if [[ ! -f $COMMANDS_FILE ]]; then
echo "Commands file not found!"
exit 1
fi
# Use fzf to fuzzy find a command from the file
SELECTED_LINE=$(cat $COMMANDS_FILE | fzf)
# If a line was selected, extract and execute the command
if [[ -n "$SELECTED_LINE" ]]; then
# Extract the command using one or more spaces as the delimiter
COMMAND=$(echo "$SELECTED_LINE" | awk -F' + ' '{print $1}')
# Execute the command
echo "Executing: $COMMAND"
eval "$COMMAND"
fi
@sourab-jadav
Copy link
Author

ls -l List files in long format
cd .. Move to the parent directory
rm -rf Remove files and directories recursively and forcefully
grep Search for patterns within files
htop Interactive process viewer
df -h Display disk space usage in human-readable format

add these commands or any commands of your choice in commands.txt file
NOTE: info about the command and what it does should be kept in a single line :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment