├── .gitignore ├── .gitmodules ├── readme.md ├── LICENSE └── awsm-cmd /.gitignore: -------------------------------------------------------------------------------- 1 | venv 2 | __pycache__ 3 | build 4 | dist 5 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Awesome.json"] 2 | path = Awesome.json 3 | url = https://github.com/lockys/Awesome.json 4 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # awsm-cmd 2 | 3 | A bash script to search [Awesome List](https://github.com/sindresorhus/awesome) 4 | from the command-line. 5 | 6 | ## Usage 7 | 8 | ``` 9 | Usage: 10 | awsm-cmd 11 | -b Browser to open the URL 12 | -r Search awesome list through rofi 13 | -f Search awesome list through fzf 14 | -u Update awesome list repository 15 | -h help 16 | ``` 17 | 18 | * Search for a particular project from the awesome list using rofi and open the URL in the 19 | default browser 20 | 21 | ``` 22 | awsm-cmd -r 23 | 24 | ``` 25 | 26 | * You can specify a default browser in the script 27 | 28 | ``` 29 | awsm-cmd 30 | AWESOME_JSON_REPO="Awesome.json" 31 | BROWSER="{DEFAULT_BROWSER}" 32 | ``` 33 | 34 | * Or you can specify a custom browser while running the command 35 | 36 | ``` 37 | 38 | awsm-cmd -r -b firefox 39 | 40 | ``` 41 | 42 | 43 | ## Requirements 44 | 45 | * [rofi](https://github.com/DaveDavenport/rofi) 46 | * [fzf](https://github.com/junegunn/fzf) 47 | * [git](https://git-scm.com/) 48 | * [jq](https://github.com/stedolan/jq) 49 | * sed 50 | * bash 51 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 rand-net 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /awsm-cmd: -------------------------------------------------------------------------------- 1 | AWESOME_JSON_REPO="Awesome.json" 2 | BROWSER="chromium" 3 | 4 | # UPDATE REPO 5 | # =================== 6 | 7 | update_json_repo(){ 8 | cd "$AWESOME_JSON_REPO" 9 | git submodule update --remote --merge 10 | } 11 | 12 | # SEARCH REPO - ROFI 13 | # =================== 14 | 15 | search_json_repo_rofi(){ 16 | 17 | cd "$AWESOME_JSON_REPO/repo-json/" 18 | # Get Topic filename 19 | TOPIC=$(for f in *; do [ -f "$f" ] && echo "$f"; done | rofi -i -dmenu -m -2 -fullscreen -p "TOPIC:" -normal-window) 20 | # Prefix Topic Filename Full Path 21 | TOPIC_PATH="$AWESOME_JSON_REPO/repo-json/""$TOPIC" 22 | 23 | # Get App Name 24 | cd ../.. 25 | PROJECT_NAME=$(jq -r '.[] | .name + " => (" + .description + ")"' "$TOPIC_PATH" | rofi -i -dmenu -fullscreen -p "PROJECT:" -normal-window) 26 | 27 | # Remove Description form app names 28 | CLEANED_PROJECT_NAME=$(echo $PROJECT_NAME | sed -E "s/=>.*$//g") 29 | FINAL_PROJECT_NAME=$(echo "$CLEANED_PROJECT_NAME"| sed 's/"//g; s/\ //g' ) #Clean whitespace 30 | 31 | # Open App URL 32 | PROJECT_URL=$(jq -r --arg FINAL_PROJECT_NAME "$FINAL_PROJECT_NAME" '.[] | select(.name==$FINAL_PROJECT_NAME) | .url ' "$TOPIC_PATH") 33 | 34 | #Return Value 35 | echo $PROJECT_URL 36 | } 37 | 38 | 39 | # SEARCH REPO - FZF 40 | # =================== 41 | 42 | search_json_repo_fzf(){ 43 | 44 | cd "$AWESOME_JSON_REPO/repo-json/" 45 | # Get Topic filename 46 | TOPIC=$(for f in *; do [ -f "$f" ] && echo "$f"; done | fzf -m -e --prompt "TOPIC:") 47 | # Prefix Topic Filename Full Path 48 | TOPIC_PATH="$AWESOME_JSON_REPO/repo-json/""$TOPIC" 49 | 50 | # Get App Name 51 | cd ../.. 52 | PROJECT_NAME=$(jq -r '.[] | .name + " => (" + .description + ")"' "$TOPIC_PATH" | fzf -m -e --prompt "PROJECT:") 53 | 54 | # Remove Description form app names 55 | CLEANED_PROJECT_NAME=$(echo $PROJECT_NAME | sed -E "s/=>.*$//g") 56 | FINAL_PROJECT_NAME=$(echo "$CLEANED_PROJECT_NAME"| sed 's/"//g; s/\ //g' ) #Clean whitespace 57 | 58 | # Open App URL 59 | PROJECT_URL=$(jq -r --arg FINAL_PROJECT_NAME "$FINAL_PROJECT_NAME" '.[] | select(.name==$FINAL_PROJECT_NAME) | .url ' "$TOPIC_PATH") 60 | 61 | #Return Value 62 | echo $PROJECT_URL 63 | } 64 | 65 | 66 | # USAGE - CMD OPTIONS 67 | # ==================== 68 | 69 | usage(){ 70 | echo "Usage: " 71 | echo "awsm-cli" 72 | echo -e "\t -b Browser to open the URL" 73 | echo -e "\t -r Search awesome list through rofi" 74 | echo -e "\t -f Search awesome list through fzf" 75 | echo -e "\t -u Update awesome list repository" 76 | echo -e "\t -h help" 77 | exit 2 78 | } 79 | 80 | while getopts 'b:rfuh' c 81 | do 82 | case $c in 83 | b) CUSTOM_BROWSER=$OPTARG;; 84 | r) MENU="rofi";; 85 | f) MENU="fzf";; 86 | u) update_json_repo;; 87 | h) usage ;; 88 | esac 89 | done 90 | shift $((OPTIND-1)) 91 | 92 | # CHECK FOR CUSTOM BROWSER 93 | # ======================== 94 | if [[ -n "$CUSTOM_BROWSER" ]] 95 | then 96 | echo $MENU 97 | if [[ "$MENU" == "rofi" ]] 98 | then 99 | URL="$(search_json_repo_rofi)" 100 | setsid -f $CUSTOM_BROWSER $URL >/dev/null 2>&1 101 | 102 | elif [[ "$MENU" == "fzf" ]] 103 | then 104 | URL="$(search_json_repo_fzf)" 105 | setsid -f $CUSTOM_BROWSER $URL >/dev/null 2>&1 106 | fi 107 | else 108 | echo $MENU 109 | if [[ "$MENU" == "rofi" ]] 110 | then 111 | URL="$(search_json_repo_rofi)" 112 | setsid -f $BROWSER $URL >/dev/null 2>&1 113 | elif [[ "$MENU" == "fzf" ]] 114 | then 115 | URL="$(search_json_repo_fzf)" 116 | setsid -f $BROWSER $URL >/dev/null 2>&1 117 | fi 118 | fi 119 | --------------------------------------------------------------------------------