helm/zsh/lib/os

59 lines
1.1 KiB
Bash

function is_deb {
command_exists apt-get
}
function is_mac {
[[ $(uname) == 'Darwin' ]]
}
function is_linux {
[[ $(uname) == 'Linux' ]]
}
if is_mac; then
# Change working directory to the top-most Finder window location
function cdf() { # short for `cdfinder`
cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')"
}
# Open a file in Mac OS's quick-look
function quicklook {
(( $# > 0 )) && qlmanage -p $* &>/dev/null &
}
# Check to see if the (mac) app exists
function app_exists {
[ -d /Applications/"$1" ] || [ -e /Applications/"$1".app ] || [ -e ~/Applications/"$1".app ]
}
function pkg_install() {
brew install $1
}
function pkg_remove() {
brew remove $1
}
function pkg_update() {
brew update && brew upgrade
}
elif is_deb; then
function pkg_install() {
sudo apt-get -y install $1
}
function pkg_remove() {
sudo apt-get -y remove $1
}
function pkg_update() {
sudo apt-get update && sudo apt-get upgrade
}
fi
# vim:set ft=zsh: