Last active
October 19, 2015 22:08
-
-
Save alenbasic/a3c844c8960cdbcc29be to your computer and use it in GitHub Desktop.
A simple pacman wrapper script that allows you to search for packages in pacman and then if you'd like, install them.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# The output is similar to what you'd see by simply running pacman -Ss "search term" | |
# but each package name is prepended with a number. If you wish to install any of the | |
# packages after making a search, you simply enter in the number of the package, otherwise | |
# q to quit. Once you select which package to install, pacman -S is run and will ask for your | |
# password and confirm if you really wish to install the package. | |
search_term="$1" | |
if [[ -z "$search_term" ]]; then | |
echo "please enter a search term" | |
exit | |
fi | |
pacman -Ss "$search_term" | awk 'NR % 2 { printf "%s) %s\n", i += 1, $0 } !(NR % 2) { print $0; }' | |
read -p "which package do you wish to install (q to cancel): " usrans | |
if [[ "$usrans" == "q" ]]; then exit; fi | |
sudo pacman -S $(pacman -Ssq "$search_term" | sed -n "$usrans"p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment