Skip to content

Instantly share code, notes, and snippets.

@silvernode
Created October 8, 2015 10:42
Show Gist options
  • Save silvernode/3248a205e13784309ff6 to your computer and use it in GitHub Desktop.
Save silvernode/3248a205e13784309ff6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
def pacman(args, pkgArgs)
installCmd = "pacman -S"
searchCmd = "pacman -Ss"
updateCmd = "pacman -Su"
syncCmd = "pacman -Sy"
syncANDupdateCmd = "pacman -Syu"
refreshSyncCmd = "pacman -Syy"
removeCmd = "pacman -R"
recursiveRemoveCmd = "pacman -Rdd"
checkUpdatesCmd = "checkupdates"
#pull variables from previously loaded .rb file
install = "#{installCmd} #{pkgArgs}"
search = "#{searchCmd} #{pkgArgs}"
update = "#{updateCmd} #{pkgArgs}"
remove = "#{removeCmd} #{pkgArgs}"
sync = "#{syncCmd} #{pkgArgs}"
supdate = "#{syncANDupdateCmd} #{pkgArgs}"
case args
# Install Options
when
"i",
"-i",
"-S",
"get",
"install"; exec ("sudo #{install}")
# Search options
when
"s",
"se",
"-s",
"-Ss",
"find",
"search"; exec (search)
# Update options (without syncing)
when
"u",
"up",
"-u",
"-Su",
"update"; exec ("sudo #{update}")
# Remove options
when
"r",
"rm",
"-R",
"remove",
"delete"; exec ("sudo #{remove}")
# Sync options
when
"-Sy",
"sync",
"refresh"; exec ("sudo #{sync}")
# Update options (with syncing)
when
"sup",
"-Syu",
"syncup"; exec ("sudo #{supdate}")
else; puts "You must give one argument"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment