profile/packages/packages.sh

234 lines
5.4 KiB
Bash
Raw Normal View History

2018-02-18 00:12:28 +00:00
#!/bin/sh -e
2018-02-17 19:12:09 +00:00
2018-02-17 19:31:58 +00:00
. ./os.sh
2018-02-17 19:12:09 +00:00
apt_install() {
2018-02-17 19:38:24 +00:00
DEBIAN_FRONTEND="noninteractive" sudo apt-get install -y "$@"
2018-02-17 19:12:09 +00:00
}
pacman_install() {
sudo pacman -S --noconfirm --needed "$@"
}
yay_install() {
packages=""
for package in "$@"; do
if ! pacman -Q "${package}" >/dev/null 2>&1; then
packages="${packages} ${package}"
fi
done
if [ ! -z "${packages}" ]; then
yay -S --noconfirm --needed ${packages}
fi
for package in "$@"; do
if ! pacman -Q "${package}" >/dev/null 2>&1; then
return 1 # at least one of the packages has not been correctly installed!
fi
done
return 0
2018-02-17 19:12:09 +00:00
}
pacaur_install() {
pacaur -S --noconfirm --needed "$@"
}
yaourt_install() {
yaourt -S --noconfirm --needed "$@"
}
pip3_install() {
pip3 install --ignore-installed --user -U "$@"
2018-02-17 19:12:09 +00:00
}
2019-11-22 09:22:54 +00:00
pipx_install() {
2022-06-13 13:48:35 +00:00
for pkg in "$@"; do
2019-11-22 09:22:54 +00:00
pipx install --force "$pkg"
done
}
download() {
curl -L "$@"
}
2018-02-17 19:12:09 +00:00
###
# Actual package installation code from here
# macOS brew
if has_tags pm:brew; then
brew update
brew install \
coreutils \
libarchive \
2018-07-17 13:27:18 +00:00
gnu-tar \
gzip \
xz \
jq \
git \
gnupg \
md5sha1sum \
rxvt-unicode \
zsh \
zsh-syntax-highlighting
fi
2018-02-17 19:12:09 +00:00
# Arch Linux
if has_tags pm:pacman; then
# libarchive for bsdtar
sudo pacman -Sy
2018-02-17 19:12:09 +00:00
pacman_install \
base-devel \
libarchive \
tar \
gzip \
2018-02-17 19:19:37 +00:00
xz \
jq \
2018-02-19 09:48:46 +00:00
git \
gnupg
2018-02-17 19:12:09 +00:00
# yay
if ! has_tags pm:yay; then
if has_tags pacaur; then
pacaur_install yay
elif has_tags yaourt; then
yaourt_install yay
else
(
dir="$(mktemp -d)"
cd "${dir}"
download https://aur.archlinux.org/cgit/aur.git/snapshot/yay.tar.gz | tar -xz --strip=1
2018-02-17 19:12:09 +00:00
makepkg -sri --noconfirm
cd
rm -rf "${dir}"
)
fi
add_tag pm:yay
fi
# from here on we should have yay available
yay_install \
2021-10-09 20:42:47 +00:00
customizepkg-git \
2018-02-17 19:12:09 +00:00
zsh \
2020-09-30 08:03:22 +00:00
zsh-syntax-highlighting \
logo-ls
2018-02-17 19:12:09 +00:00
if has_tags desktop; then
yay_install \
powerline-fonts \
2020-09-30 07:12:04 +00:00
ttf-nerd-fonts-symbols \
ttf-fira-code \
ttf-segoe-ui-variable
2018-02-17 19:12:09 +00:00
fi
# pip
if ! has_tags pm:pip3; then
yay_install python-pip
add_tag pm:pip3
fi
fi
# Debian/Ubuntu-ish
if has_tags pm:apt; then
sudo apt update
apt_install \
'^(bsdtar|libarchive-tools)$' \
2018-02-17 19:12:09 +00:00
tar \
gzip \
xz-utils \
python3-pip \
python3-venv \
2018-02-17 19:12:09 +00:00
zsh \
zsh-syntax-highlighting \
jq \
2018-02-19 09:48:46 +00:00
git \
gnupg2
2018-02-17 19:12:09 +00:00
add_tag pm:pip3
fi
# Python3
if has_tags pm:pip3; then
pip3_install \
2019-11-22 09:22:54 +00:00
pipx
add_tag pm:pipx
fi
if has_tags pm:pipx; then
pipx_install \
powerline-status \
thefuck
2018-02-17 19:12:09 +00:00
fi
2022-06-13 13:48:55 +00:00
# change git user settings
set_git_config_if_unset() {
local name
local value
name="$1"
value="$2"
if ! git config --global --get "$1" >/dev/null; then
echo "Configuring global git setting: $1 = $2"
git config --global "$1" "$2"
fi
}
clear_git_config_if_pointing_nowhere() {
local name
name="$1"
if git config --global --get "$1" >/dev/null && ! command -v $(git config --global --get "$1") >/dev/null; then
echo "Resetting global git setting since it no longer points anywhere useful: $1"
git config --global --unset "$1"
fi
}
set_git_config_if_unset alias.change-commits '!f() { VAR=$1; OLD=$2; NEW=$3; shift 3; git filter-branch --env-filter \"if [[ \\\"$`echo $VAR`\\\" = '"'"'$OLD'"'"' ]]; then export $VAR='"'"'$NEW'"'"'; fi\" $@; }; f'
set_git_config_if_unset alias.glog 'log --all --pretty="format:%d %Cgreen%h%Creset %an - %s" --graph'
set_git_config_if_unset commit.gpgsign true
set_git_config_if_unset core.autocrlf input
set_git_config_if_unset core.editor "$EDITOR"
set_git_config_if_unset init.defaultBranch main
set_git_config_if_unset pull.rebase false
set_git_config_if_unset tag.gpgsign true
set_git_config_if_unset user.email "icedream@icedream.pw"
set_git_config_if_unset user.name "Carl Kittelberger"
#set_git_config_if_unset user.signingkey B5108C5A158A6608AD3361DA1573F6D8EFE4D0CF
set_git_config_if_unset user.signingkey 04ADEF85EA6AEC6F75941E84468BBEEBB9EC6AEA
# set up kdiff3 as mergetool if it is installed
clear_git_config_if_pointing_nowhere merge.tool
for bin in kdiff3 meld p4merge vimdiff; do
if command -v "$bin" >/dev/null; then
set_git_config_if_unset merge.tool "$bin"
fi
done
2018-02-17 19:12:09 +00:00
# change default terminal to urxvt
if has_tags desktop; then
if has_tags os_like:debian; then
sudo update-alternatives --config urxvt
fi
for de in gnome cinnamon; do
gsettings set org.${de}.desktop.default-applications.terminal exec /usr/bin/urxvt
gsettings set org.${de}.desktop.default-applications.terminal exec-arg "-x"
done
2022-06-08 15:36:45 +00:00
gsettings set org.cinnamon.desktop.interface font-name 'Sans 9'
gsettings set org.cinnamon.desktop.screensaver font-date 'Sans 24'
gsettings set org.cinnamon.desktop.screensaver font-message 'Sans 14'
gsettings set org.cinnamon.desktop.screensaver font-time 'Sans 64'
gsettings set org.cinnamon.desktop.wm.preferences titlebar-font 'Sans Bold 9'
gsettings set org.cinnamon.desktop.wm.preferences titlebar-uses-system-font false
#gsettings set org.gnome.desktop.interface document-font-name 'Cantarell 11'
gsettings set org.gnome.desktop.interface font-name 'Sans, 10'
gsettings set org.gnome.desktop.interface monospace-font-name 'Monospace Regular 10'
gsettings set org.gnome.desktop.wm.preferences titlebar-font 'Sans Bold 9'
gsettings set org.gnome.desktop.wm.preferences titlebar-uses-system-font false
gsettings set org.gnome.libgnomekbd.indicator font-family ''
gsettings set org.gnome.libgnomekbd.indicator font-size 9
gsettings set org.nemo.desktop font 'Sans 9'
gsettings set x.dm.slick-greeter font-name 'Sans 9'
2018-02-17 19:12:09 +00:00
fi