confOS/termux.sh
2024-03-30 18:28:29 +01:00

86 lines
2.5 KiB
Bash

#!/usr/bin/env bash
set -o errexit # crash the script when a command crash
set -o pipefail # same as above for piped command
set -o nounset # crash when a variable doesnt exist
# TRACE=1 for debug
if [[ "${TRACE-0}" == "1" ]]; then
set -o xtrace
fi
cd "$(dirname "$0")" # change script directory
function main {
# === Variables ==
local repo apt_arg
repo=https://git.mylloon.fr/Anri/confOS/raw/branch/main
apt_arg='-y -o Dpkg::Options::="--force-confnew"'
# === Update ==
apt-get update "${apt_arg}"
# === Packages ==
apt-get install "${apt_arg}" fish eza tealdeer bat
# === Fish ==
# Default shell
chsh -s fish
# Remove motd
fish -c "set -U fish_greeting"
# Reversed search
curl -sL https://git.io/fisher | fish -c "source && fisher install jorgebucaran/fisher"
fish -c "fisher install jethrokuan/fzf"
fish -c "fisher install jorgebucaran/autopair.fish"
# SSH
wget -q https://gitlab.com/kyb/fish_ssh_agent/raw/master/functions/fish_ssh_agent.fish -P "$HOME"/.config/fish/functions/
mkdir -p "$HOME"/.ssh
# Fish theme
fish -c "fish_config theme choose 'Base16 Eighties' && yes | fish_config theme save"
fish -c "set fish_color_comment 5c6773" # custom comment color
# Fish prompt
rm "$HOME"/.config/fish/functions/fish_prompt.fish 2> /dev/null ||:
wget -q "${repo}"/.config/fish/functions/fish_prompt.fish -P "$HOME"/.config/fish/functions/
# EZA colors
fish -c "set -Ux EXA_COLORS 'di=1;36:da=35'"
# Add SSH
echo "fish_ssh_agent" > "$HOME"/.config/fish/config.fish
# Add abbreviations
wget -q "${repo}"/.config/fish/conf.d/abbr.fish -O "$HOME"/.config/fish/conf.d/abbr.fish
# Add aliases
wget -q "${repo}"/.config/fish/conf.d/alias.fish -O "$HOME"/.config/fish/conf.d/alias.fish
# === Default editor ==
fish -c "set -Ux EDITOR nano"
# === tldr ==
fish -c "tldr --update"
# Fish completion
local url_tldr
url_tldr=$(curl -s https://api.github.com/repos/dbrgn/tealdeer/releases/latest \
| grep 'browser_download_url": ".*/completions_fish"' \
| cut --delimiter=":" --field=2,3 \
| tr -d \" )
wget -q --show-progress "${url_tldr:1}" -O completions_fish
mv completions_fish ~/.config/fish/completions/tldr.fish
# === Manual color ==
fish -c "set -Ux MANPAGER \"sh -c 'col -bx | bat -l man -p'\""
fish -c "set -Ux MANROFFOPT \"-c\""
# === Git ==
wget -q "${repo}"/dotfiles/.gitconfig -O "$HOME"/.gitconfig
}
if type termux-info &> /dev/null;
then
main "$@"
else
echo "Ce script ne fonctionne que sur Termux." >&2
fi