20 Commits
rust ... main

Author SHA1 Message Date
7cb548eaa1 Fix hypr 2026-03-20 17:50:35 +01:00
002c918f45 Adds screen sharing for hyprland 2025-07-21 14:52:34 +02:00
cd503caf9b hypridle and hyprlock 2025-06-20 18:56:23 +02:00
9d3885c6a4 Neovim extraconfig 2025-06-17 10:32:59 +02:00
d15d6360b9 Link all dir 2025-06-17 10:30:33 +02:00
4cc6baefc9 Should be good now :) 2025-05-08 16:47:38 +02:00
26143c5f81 Fix node bug 2025-05-08 15:09:53 +02:00
53c5859678 Working 2025-05-06 17:38:23 +02:00
78625c52d7 Fixes 2025-05-06 16:22:54 +02:00
d783dfcf77 Better support for noroot 2025-05-03 17:08:01 +02:00
806c1d1510 Fix bug in chsh 2025-05-03 17:02:39 +02:00
70838875e6 Working 2025-05-03 16:20:02 +02:00
235e2b7402 Python venv 2025-05-03 00:11:56 +02:00
8666527ddc Debian / Arch 2025-05-03 00:08:14 +02:00
a94894652b Better but still not sorking 2025-05-02 22:11:04 +02:00
178ba8ae8f Preparing for archlinux 2025-05-02 22:07:00 +02:00
8d1a0e9557 Add modules 2025-05-02 16:43:14 +02:00
b7a5c42b9b Fix bugs 2024-11-09 22:13:24 +01:00
9dbff77dd1 Webpage 2024-10-19 04:04:22 +02:00
2b8d7b3b92 A lot of work 2024-10-19 03:38:04 +02:00
9 changed files with 548 additions and 663 deletions

2
.gitignore vendored
View File

@@ -1,2 +0,0 @@
target
Cargo.lock

View File

@@ -1,10 +0,0 @@
[package]
name = "tforgione-installer"
version = "0.1.0"
authors = ["Thomas Forgione <thomas@forgione.fr>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
dialoguer = "0.7.1"

51
Dockerfile Normal file
View File

@@ -0,0 +1,51 @@
# Test on debian
FROM debian:11 AS debian-user
RUN \
apt update -y && \
apt install sudo curl -y && \
useradd -m tester && \
echo tester:tester | chpasswd && \
usermod -aG sudo tester
USER tester
WORKDIR /home/tester
COPY ./tforgione.sh /home/tester/tforgione.sh
RUN echo "cat tforgione.sh | bash" > /home/tester/.bash_history
CMD ["bash"]
# Test on ubuntu
FROM ubuntu:24.04 AS ubuntu-user
RUN \
apt update -y && \
apt install sudo curl -y && \
useradd -m tester && \
echo tester:tester | chpasswd && \
usermod -aG sudo tester
USER tester
WORKDIR /home/tester
COPY ./tforgione.sh /home/tester/tforgione.sh
RUN echo "cat tforgione.sh | bash" > /home/tester/.bash_history
CMD ["bash"]
# Test on archlinux
FROM archlinux AS archlinux-user
RUN \
pacman -Sy curl sudo --noconfirm && \
groupadd sudo && \
echo "%sudo ALL=(ALL:ALL) ALL" > /etc/sudoers.d/sudoers && \
useradd -m tester && \
echo tester:tester | chpasswd && \
usermod -aG sudo tester
USER tester
WORKDIR /home/tester
COPY ./tforgione.sh /home/tester/tforgione.sh
RUN echo "cat tforgione.sh | bash" > /home/tester/.bash_history
CMD ["bash"]

2
Makefile Normal file
View File

@@ -0,0 +1,2 @@
deploy:
scp tforgione.sh index.html pi:docker/sh

67
index.html Normal file
View File

@@ -0,0 +1,67 @@
<!doctype HTML>
<html>
<head>
<meta charset="utf-8">
<title>sh.tforgione.fr</title>
<style>
.container {
width: 800px;
margin: auto;
border: solid;
border-width: 1px;
padding: 5rem;
margin-top: 5rem;
}
h1 {
text-align: center;
margin-top: 0rem;
margin-bottom: 3rem;
}
.code {
width: 45rem;
margin: auto;
display: flex;
text-align: center;
}
pre::before {
content: "$ ";
color: grey;
}
pre {
display: inline;
width: 45rem;
margin: 0px;
background-color: black;
color: white;
padding: 1rem;
font-size: 1rem;
}
.button {
cursor: pointer;
background-color: white;
padding: 0 1rem 0 1rem;
margin: 0px;
}
</style>
</head>
<body>
<div class="container">
<h1>Run the following command to get started with tforgione's dotfiles!</h1>
<div class="code">
<pre><code id="code">curl --proto '=https' --tlsv1.2 -sSf https://sh.tforgione.fr | bash</code></pre><button id="copy" class="button"><svg width="24" height="25" viewBox="0 0 24 25" xmlns="http://www.w3.org/2000/svg" alt="Copy curl command to clipboard to download Rustup">
<path d="M18 20h2v3c0 1-1 2-2 2H2c-.998 0-2-1-2-2V5c0-.911.755-1.667 1.667-1.667h5A3.323 3.323 0 0110 0a3.323 3.323 0 013.333 3.333h5C19.245 3.333 20 4.09 20 5v8.333h-2V9H2v14h16v-3zM3 7h14c0-.911-.793-1.667-1.75-1.667H13.5c-.957 0-1.75-.755-1.75-1.666C11.75 2.755 10.957 2 10 2s-1.75.755-1.75 1.667c0 .911-.793 1.666-1.75 1.666H4.75C3.793 5.333 3 6.09 3 7z"></path><path d="M4 19h6v2H4zM12 11H4v2h8zM4 17h4v-2H4zM15 15v-3l-4.5 4.5L15 21v-3l8.027-.032L23 15z"></path>
</svg></button>
</div>
</div>
<script>
document.getElementById('copy').addEventListener('click', function() {
navigator.clipboard.writeText("curl --proto '=https' --tlsv1.2 -sSf https://sh.tforgione.fr | bash");
});
</script>
</body>
</html>

View File

@@ -1,314 +0,0 @@
use std::ffi::OsStr;
use std::fmt;
use std::fs::{metadata, symlink_metadata};
use std::path::PathBuf;
use std::process::Command;
use dialoguer::{theme::SimpleTheme, Confirm, MultiSelect};
macro_rules! unwrap_or_false {
($expr: expr) => {
match $expr {
Ok(v) => v,
Err(_) => return false,
}
};
}
/// Returns the home directory.
pub fn home() -> PathBuf {
PathBuf::from(std::env::var("HOME").unwrap())
}
/// A path from the user's home.
pub fn from_home(path: &str) -> PathBuf {
home().join(path)
}
/// Tests that a command exists.
pub fn test_command(cmd: &str) -> bool {
unwrap_or_false!(command("sh", &["-c", &format!("command -v {}", cmd)]).output())
.status
.success()
}
/// Helper to create commands in one line.
pub fn command<I, S>(program: &str, args: I) -> Command
where
I: IntoIterator<Item = S>,
S: AsRef<OsStr>,
{
let mut command = Command::new(program);
command.args(args);
command
}
/// Helper to create commands for cloning a github repository.
pub fn github_clone<T: AsRef<OsStr>>(user: &str, repo: &str, dest: T) -> Command {
command(
"git",
&[
&"clone".as_ref(),
&format!("https://github.com/{}/{}", user, repo).as_ref(),
dest.as_ref(),
],
)
}
/// Helper to create commands for cloning a gitea repository.
pub fn gitea_clone<T: AsRef<OsStr>>(user: &str, repo: &str, dest: T) -> Command {
command(
"git",
&[
&"clone".as_ref(),
&format!("https://gitea.tforgione.fr/{}/{}", user, repo).as_ref(),
dest.as_ref(),
],
)
}
/// The supported package manager.
#[derive(Copy, Clone)]
pub enum PackageManager {
/// The apt manager, availble on Debian, Ubuntu and others.
Apt,
/// The pacman manager, available on ArchLinux, Manjaro and others.
Pacman,
}
impl PackageManager {
/// Returns the command to install a page using the right package manager.
pub fn install<'a>(&self, package: &'a str) -> Command {
match self {
PackageManager::Apt => {
command("sh", &["-c", &format!("sudo apt install -y {}", package)])
}
PackageManager::Pacman => command("sudo", &["pacman", "-S", package]),
}
}
}
/// All the installable components.
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum Component {
/// Whether the user is allowed to run sudo commands.
Sudo,
/// Git enables to clone repository, which is necessary for many components.
Git,
/// The configuration uses the zsh shell.
Zsh,
/// The configuration files.
Dotfiles,
/// The zshrc config file
Zshrc,
/// The oh my zsh repository.
OhMyZsh,
}
impl Component {
/// List all components.
pub fn all() -> Vec<Component> {
vec![
Component::Git,
Component::Zsh,
Component::Dotfiles,
Component::OhMyZsh,
Component::Zshrc,
]
}
/// Returns the command that installs a component.
pub fn install_command(self, package_manager: PackageManager) -> Command {
match self {
Component::Sudo => panic!("you can't install sudo"),
Component::Git => package_manager.install("git"),
Component::Zsh => package_manager.install("zsh"),
Component::Dotfiles => {
gitea_clone("tforgione", "dotfiles", from_home(".config/dotfiles"))
}
Component::OhMyZsh => github_clone("ohmyzsh", "ohmyzsh", from_home(".config/ohmyzsh")),
Component::Zshrc => command(
"ln",
&[
AsRef::<OsStr>::as_ref("-s"),
&from_home(".config/dotfiles/zshrc").as_ref(),
&from_home(".zshrc").as_ref(),
],
),
}
}
/// Installs a component.
pub fn install(self) -> Result<()> {
self.install_command(PackageManager::Apt).output().unwrap();
Ok(())
}
/// Returns a command that tests if a component is installed.
pub fn is_installed(self) -> bool {
match self {
Component::Sudo => true,
Component::Git => test_command("git"),
Component::Zsh => test_command("zsh"),
Component::Dotfiles => {
unwrap_or_false!(metadata(from_home(".config/dotfiles"))).is_dir()
}
Component::OhMyZsh => unwrap_or_false!(metadata(from_home(".config/ohmyzsh"))).is_dir(),
Component::Zshrc => unwrap_or_false!(symlink_metadata(from_home(".zshrc")))
.file_type()
.is_symlink(),
}
}
/// Returns the dependencies of each component.
pub fn dependencies(self) -> &'static [Component] {
match self {
Component::Sudo => &[],
Component::Git => &[Component::Sudo],
Component::Zsh => &[Component::Sudo],
Component::Dotfiles => &[Component::Git],
Component::Zshrc => &[Component::Zsh, Component::Dotfiles, Component::OhMyZsh],
Component::OhMyZsh => &[Component::Git],
}
}
/// Returns the str representation of the command.
pub fn to_str(self) -> &'static str {
match self {
Component::Sudo => "sudo",
Component::Git => "git",
Component::Zsh => "zsh",
Component::Dotfiles => "dotfiles",
Component::Zshrc => "zshrc",
Component::OhMyZsh => "ohmyzsh",
}
}
}
impl fmt::Display for Component {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(
fmt,
"{} (requires {}{})",
self.to_str(),
self.dependencies()
.into_iter()
.map(|x| x.to_str())
.collect::<Vec<_>>()
.join(", "),
if self.is_installed() {
", already installed"
} else {
""
}
)
}
}
/// The struct that holds the information about the install.
pub struct Installer {
/// All the components to install, and whether the users want to install them.
components: Vec<(Component, bool)>,
}
impl Installer {
/// Creates a new installer.
pub fn new() -> Installer {
Installer {
components: Component::all().into_iter().map(|x| (x, false)).collect(),
}
}
/// Asks interactively to the user which components to install.
pub fn interact(&mut self) -> bool {
let multiselected = self
.components
.iter()
.map(|(component, _)| format!("{}", component))
.collect::<Vec<_>>();
let defaults = self
.components
.iter()
.map(|(_, active)| *active)
.collect::<Vec<_>>();
let selections = MultiSelect::with_theme(&SimpleTheme)
.items(&multiselected[..])
.defaults(&defaults[..])
.interact()
.unwrap();
for i in selections {
self.components[i].1 = true;
}
println!("The following components will be installed:");
for (comp, to_install) in &self.components {
if *to_install {
println!(" - {}", comp.to_str());
}
}
let message = "Is this correct?";
Confirm::with_theme(&SimpleTheme)
.with_prompt(message)
.interact()
.unwrap()
}
/// Runs the installer.
pub fn start(&self) -> Result<()> {
for (component, to_install) in &self.components {
if *to_install {
self.install_component(*component)?;
}
}
Ok(())
}
/// Installs a component.
pub fn install_component(&self, component: Component) -> Result<()> {
if component.is_installed() || component == Component::Sudo {
return Ok(());
}
println!("Install {}", component.to_str());
for dep in component.dependencies() {
self.install_component(*dep)?;
}
if !component.is_installed() {
component.install()?;
}
Ok(())
}
}
/// The error type of this library.
pub enum Error {}
impl fmt::Display for Error {
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
Ok(())
}
}
/// The result type of this library.
pub type Result<T> = std::result::Result<T, Error>;
/// Runs the installer
pub fn main() -> Result<()> {
let mut installer = Installer::new();
if installer.interact() {
installer.start()?;
}
Ok(())
}

View File

@@ -1,6 +0,0 @@
fn main() {
if let Err(e) = tforgione_installer::main() {
eprintln!("installer crashed: {}", e);
std::process::exit(1);
}
}

18
test-env.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/usr/bin/env bash
debian() {
docker build . --tag debian-user --target debian-user --debug
docker container run -it debian-user bash
}
ubuntu() {
docker build . --tag ubuntu-user --target ubuntu-user --debug
docker container run -it ubuntu-user bash
}
archlinux() {
docker build . --tag archlinux-user --target archlinux-user --debug
docker container run -it archlinux-user bash
}
"$@"

View File

@@ -1,6 +1,5 @@
#!/usr/bin/env sh #!/usr/bin/env bash
# This script installs the default things for having a stylish zsh
user=$USER user=$USER
user_shell=`getent passwd $USER | cut -f7 -d:` user_shell=`getent passwd $USER | cut -f7 -d:`
@@ -42,14 +41,6 @@ test_command() {
done done
} }
yes_no_ask_required() {
yes_no_ask $@ "(required)"
if [ $? -ne 0 ]; then
error "refused to perform required task, can't continue"
exit 1
fi
}
yes_no_ask() { yes_no_ask() {
info_n $@ "[Y/n]" info_n $@ "[Y/n]"
read answer read answer
@@ -60,383 +51,471 @@ yes_no_ask() {
fi fi
} }
install() { has_sudo=0
test_command apt has_apt=0
has_pacman=0
should_install_git=0
should_install_zsh=0
should_clone_dotfiles=0
should_install_dotfiles=0
should_install_update_remainder=0
should_install_neovim=0
should_configure_neovim=0
should_install_rust=0
should_install_nodejs=0
should_configure_nodejs=0
should_install_python=0
should_configure_python=0
should_install_hyprland=0
find_os() {
apt --version > /dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
sudo apt install -yqq $@ has_apt=1
return return
fi fi
test_command pacman pacman --version > /dev/null 2>&1
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
sudo pacman -S $@ has_pacman=1
return return
fi fi
error "distribution not recognized, can't install $@." error_n "os not supported"
exit 1
} }
remove() { ask_for_dotfiles() {
test_command apt
if [ $? -eq 0 ]; then
sudo apt purge -yqq $1
sudo apt autoremove -yqq
return
fi
test_command pacman
if [ $? -eq 0 ]; then
sudo pacman -Rsn $1
return
fi
error "distribution not recognized, can't remove $1."
}
install_python3() {
test_command apt
if [ $? -eq 0 ]; then
sudo apt install -yqq python3 python3-pip
return
fi
test_command pacman
if [ $? -eq 0 ]; then
sudo pacman -S python python-pip
return
fi
error "distribution not recognized, can't install python3."
}
install_python_neovim() {
test_command pip3
if [ $? -eq 0 ]; then
sudo pip3 install neovim
return
fi
test_command pip
if [ $? -eq 0 ]; then
sudo pip install neovim
return
fi
error "couldn't find pip, can't install python-neovim."
}
install_neovim() {
test_command apt
if [ $? -eq 0 ]; then
sudo apt install -yqq neovim
return
fi
test_command pacman
if [ $? -eq 0 ]; then
sudo pacman -S neovim
return
fi
error "distribution not recognized, can't install neovim."
}
git_clone() {
info_n "cloning $1..."
git clone $@ > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo " OK!"
else
echo
error "clone failed!"
fi
}
clone_dotfiles() {
if [ ! -d $HOME/.config/dotfiles ]; then
test_command git
if [ $? -ne 0 ]; then
if [ $sudo_available -ne 0 ]; then
error "git is needed, but you don't have git or sudo"
return 1
else
yes_no_ask_required "you'll need git for this, do you wish to install git?"
install git
fi
fi
git_clone https://gitea.tforgione.fr/tforgione/dotfiles/ $HOME/.config/dotfiles
echo "# Checks that the update is done weekly, if its not done, prints a nice message" > $HOME/.config/dotfiles/zsh/extraconfig.zsh
echo "export UPDATE_CHECK=weekly" >> $HOME/.config/dotfiles/zsh/extraconfig.zsh
echo "export UPDATE_CHECK_TYPE=sliding" >> $HOME/.config/dotfiles/zsh/extraconfig.zsh
mkdir -p $HOME/.config/dotfiles/.data
if [ $sudo_available -ne 0 ]; then
touch $HOME/.config/dotfiles/.data/noroot
fi
fi
}
configure_dotfiles() {
if [ ! -d $HOME/.config/dotfiles ]; then
yes_no_ask "do you wish to configure the dotfiles?"
if [ $? -ne 0 ]; then
return
fi
clone_dotfiles
fi
}
configure_shell() {
installed_locally=false
yes_no_ask "do you wish to install and configure zsh?"
if [ $? -ne 0 ]; then
yes_no_ask "you don't want zsh? Ok... but can I at least give you a nice bashrc?"
if [ $? -ne 0 ]; then
info "ok :'( I guess I'm not doing anything then"
return
fi
clone_dotfiles
rm -f $HOME/.bashrc
ln -s `realpath $HOME/.config/dotfiles/bashrc` `realpath $HOME/.bashrc`
mkdir -p $HOME/.config/dotfiles/bash
echo "# Checks that the update is done weekly, if its not done, prints a nice message" > $HOME/.config/dotfiles/bash/extraconfig.bash
echo "export UPDATE_CHECK=weekly" >> $HOME/.config/dotfiles/bash/extraconfig.bash
info "bashrc configured successfully"
return
fi
clone_dotfiles
test_command zsh test_command zsh
if [ $? -ne 0 ]; then if [ $? -eq 0 ]; then
if [ $sudo_available -ne 0 ]; then has_zsh=1
warn "zsh is needed, but you don't have zsh or sudo" else
yes_no_ask "do you want me to compile and install zsh locally?" has_zsh=0
if [ $? -ne 0 ]; then fi
error "zsh is needed, but you refused to install zsh"
return 1
fi
installed_locally=true
info "downloading zsh..."
mkdir tmp
cd tmp
curl https://codeload.github.com/zsh-users/zsh/tar.gz/zsh-5.7.1 --output zsh.tar.gz > /dev/null 2>&1
tar xvf zsh.tar.gz > /dev/null 2>&1
cd zsh-zsh-5.7.1
info "building zsh (this may take a while)..."
./Util/preconfig > /dev/null 2>&1
./configure --prefix ~/.local/share > /dev/null 2>&1
make > /dev/null 2>&1
info "installing zsh (this may take a while)..."
make install > /dev/null 2>&1
cd ../../
rm -rf tmp
info "zsh installed!"
else test_command git
yes_no_ask_required "this magnificent prompt is based on zsh, do you wish to install zsh?" if [ $? -eq 0 ]; then
install zsh has_git=1
else
has_git=0
fi
if [ $has_sudo -eq 0 ]; then
if [ $has_zsh -eq 0 ] || [ $has_git -eq 0 ]; then
warn "can't install dotfiles without sudo, or zsh and git"
return
fi fi
fi fi
mkdir -p $HOME/.config yes_no_ask "do you wish to install and configure dotfiles?"
if [ ! -d $HOME/.config/ohmyzsh ]; then if [ $? -eq 0 ]; then
git_clone https://github.com/ohmyzsh/ohmyzsh $HOME/.config/ohmyzsh
if [ $has_zsh -eq 0 ]; then
should_install_zsh=1
fi
if [ $has_git -eq 0 ]; then
should_install_git=1
fi
should_clone_dotfiles=1
should_install_dotfiles=1
yes_no_ask "do you want a weekly remainder to do your system's update?"
if [ $? -eq 0 ]; then
should_install_update_remainder=1
fi
fi
}
ask_for_neovim() {
test_command nvim
if [ $? -eq 0 ]; then
has_neovim=1
else
has_neovim=0
fi fi
if [ -f $HOME/.zshrc ]; then if [ $has_neovim -eq 0 ] && [ $has_sudo -eq 0 ]; then
path1=`realpath $HOME/.zshrc` warn "can't install neovim without sudo"
path2=`realpath $HOME/.config/dotfiles/zshrc` return
if [ "$path1" == "$path2" ]; then fi
info "it seems that your zshrc is already a good link."
else if [ $has_neovim -eq 1 ]; then
if `realpath $HOME/.zshrc`; then yes_no_ask "do you wish to configure neovim?"
warn "you already have a zshrc, it will be moved to ~/.zshrc.bak" if [ $? -eq 0 ]; then
mv $HOME/.zshrc $HOME/.zshrc.bak should_clone_dotfiles=1
fi should_configure_neovim=1
info "linking zshrc"
ln -s $HOME/.config/dotfiles/zshrc $HOME/.zshrc
fi fi
else else
info "linking zshrc" yes_no_ask "do you wish to install and configure neovim?"
ln -s $HOME/.config/dotfiles/zshrc $HOME/.zshrc if [ $? -eq 0 ]; then
fi should_clone_dotfiles=1
should_install_neovim=1
if [ "$user_shell" == "/bin/zsh" ]; then should_configure_neovim=1
info "it seems that you already use zsh."
else
info "it seems your shell is not zsh..."
if [ $sudo_available -eq 0 ]; then
# Sudo is available, run chsh
yes_no_ask "do you want to change your shell?"
if [ $? -eq 0 ]; then
info "changing your shell"
sudo chsh $user -s /bin/zsh
else
info "not doing anything"
fi
else
info "you don't have root, but you can run 'exec zsh' at the end of your bashrc"
yes_no_ask "do you wish to do that?"
if [ $? -eq 0 ]; then
echo >> $HOME/.bashrc
if [ "$installed_locally" == "true" ]; then
echo "exec ~/.local/share/bin/zsh" >> $HOME/.bashrc
else
echo "exec zsh" >> $HOME/.bashrc
fi
echo >> $HOME/.bashrc
else
info "not doing anything"
fi
fi fi
fi fi
} }
configure_neovim() { ask_for_rust() {
test_command nvim
if [ $? -ne 0 ] && [ $sudo_available -ne 0 ]; then
warn "you don't have sudo or neovim, skipping neovim configuration"
return
fi
yes_no_ask "do you wish to install and configure neovim?"
if [ $? -ne 0 ]; then
info "not installing neovim"
return
fi
clone_dotfiles
test_command nvim
if [ $? -ne 0 ]; then
info "installing neovim"
install_neovim
fi
# Try and install python3 and python-neovim
test_command python3 pip3
if [ $? -ne 0 ]; then
install_python3
fi
install_python_neovim
# Create config files an directories
mkdir -p $HOME/.config/nvim $HOME/.nvim/backups $HOME/.nvim/swp $HOME/.nvim/undo
rm -f $HOME/.config/nvim/init.vim
ln -s $HOME/.config/dotfiles/init.vim $HOME/.config/nvim/init.vim
# Install vim plug
curl -fLo $HOME/.local/share/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# Install plugins
nvim +PlugInstall +qa
}
configure_powerline() {
yes_no_ask "do you wish to install powerline fonts?"
if [ $? -ne 0 ]; then
return
fi
info installing powerline fonts
git_clone https://github.com/powerline/fonts
cd fonts
./install.sh
cd ..
rm -rf fonts
}
configure_rust() {
yes_no_ask "do you wish to install and configure rust?" yes_no_ask "do you wish to install and configure rust?"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
return return
fi fi
curl https://sh.rustup.rs -sSf | sh -s -- --no-modify-path -y test_command rustc
export PATH=$HOME/.cargo/bin:$PATH if [ $? -ne 0 ]; then
should_install_rust=1
fi
}
cargo_update_installed=1 ask_for_python() {
yes_no_ask "do you wish to install cargo-update? it allows to update package automatically" test_command python
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
cargo_update_installed=0 has_python=1
cargo install cargo-update else
has_python=0
fi fi
yes_no_ask "do you wish to install racer? it enabled rust completion from vim" if [ $has_python -eq 0 ] && [ $has_sudo -eq 0 ]; then
if [ $? -eq 0 ]; then warn "can't install python without sudo"
rustup toolchain add nightly return
cargo +nightly install racer fi
if [ $cargo_update_installed -eq 0 ]; then
cargo install-update-config -t nightly racer if [ $has_python -eq 1 ]; then
yes_no_ask "do you wish to configure python?"
if [ $? -eq 0 ]; then
should_configure_python=1
fi
else
yes_no_ask "do you wish to install and configure python?"
if [ $? -eq 0 ]; then
should_install_python=1
should_configure_python=1
fi fi
fi fi
} }
configure_node() { ask_for_nodejs() {
yes_no_ask "do you wish to install and configure node and npm?" test_command node
if [ $? -eq 0 ]; then
has_node=1
else
has_node=0
fi
if [ $? -ne 0 ]; then if [ $has_node -eq 0 ] && [ $has_sudo -eq 0 ]; then
warn "can't install node without sudo"
return return
fi fi
install nodejs npm if [ $has_node -eq 1 ]; then
yes_no_ask "do you wish to configure nodejs?"
if [ $? -eq 0 ]; then
should_configure_node=1
fi
else
yes_no_ask "do you wish to install and configure nodejs?"
if [ $? -eq 0 ]; then
should_install_nodejs=1
should_configure_nodejs=1
fi
fi
mkdir ~/.npmbin
npm config set prefix ~/.npmbin
npm install -g npm
remove npm
} }
configure_awesome() { ask_for_hyprland() {
yes_no_ask "do you wish to install and configure awesome?" if [ $has_sudo -eq 0 ]; then
return
fi
if [ $has_pacman -ne 1 ]; then
warn "can't install hyprland on this OS"
return
fi
yes_no_ask "do you wish to install and configure hyprland?"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
return return
fi fi
install awesome acpi should_clone_dotfiles=1
git_clone https://gitea.tforgione.fr/tforgione/awesome ~/.config/awesome should_install_hyprland=1
}
git_clone https://github.com/horst3180/arc-icon-theme --depth 1 && cd arc-icon-theme debug() {
./autogen.sh --prefix=/usr if [ $should_install_git -eq 1 ]; then
sudo make install info "should install git"
cd .. fi
rm -rf arc-icon-theme
if [ $should_install_zsh -eq 1 ]; then
info "should install zsh"
fi
if [ $should_install_dotfiles -eq 1 ]; then
info "should install dotfiles"
fi
if [ $should_install_neovim -eq 1 ]; then
info "should install neovim"
fi
if [ $should_configure_neovim -eq 1 ]; then
info "should configure neovim"
fi
if [ $should_install_rust -eq 1 ]; then
info "should install rust"
fi
if [ $should_install_python -eq 1 ]; then
info "should install python"
fi
if [ $should_configure_python -eq 1 ]; then
info "should configure python"
fi
if [ $should_install_nodejs -eq 1 ]; then
info "should install nodejs"
fi
if [ $should_configure_nodejs -eq 1 ]; then
info "should configure nodejs"
fi
if [ $should_install_hyprland -eq 1 ]; then
info "should install hyprland"
fi
}
run() {
packages=()
python_packages=()
if [ $should_install_git -eq 1 ]; then
packages+=(git)
fi
if [ $should_install_zsh -eq 1 ]; then
packages+=(zsh)
fi
if [ $should_install_neovim -eq 1 ]; then
if [ $has_pacman -eq 1 ]; then
packages+=(neovim)
fi
fi
if [ $should_install_nodejs -eq 1 ]; then
packages+=(nodejs)
if [ $has_pacman -eq 1 ]; then
packages+=(npm)
fi
fi
if [ $should_install_python ]; then
# Install python
if [ $has_apt -eq 1 ]; then
packages+=(python3)
packages+=(python-is-python3)
packages+=(python3-pip)
packages+=(python3-venv)
elif [ $has_pacman -eq 1 ]; then
packages+=(python)
fi
# Install some python plugins that work well with neovim if necessary
if [ $should_configure_neovim -eq 1 ]; then
python_packages+=(neovim)
python_packages+=(pycodestyle)
python_packages+=("python-lsp-server[all]")
fi
fi
if [ $should_install_hyprland -eq 1 ]; then
packages+=(hyprland)
packages+=(hyprpaper)
packages+=(hyprpicker)
packages+=(hyprlock)
packages+=(hypridle)
packages+=(xdg-desktop-portal-hyrpland)
packages+=(egl-wayland)
packages+=(pavucontrol)
packages+=(waybar)
packages+=(slurp)
packages+=(wl-clipboard)
packages+=(brightnessctl)
python_packages+=(psutil)
fi
# Add apt repository for recent nodejs for debian
if [ $should_install_nodejs -eq 1 ] && [ $has_apt -eq 1 ]; then
curl -fsSL https://deb.nodesource.com/setup_current.x | sudo bash
fi
if [ $has_sudo -eq 1 ]; then
if [ $has_apt -eq 1 ]; then
sudo apt install -y ${packages[@]}
if [ $should_install_neovim ]; then
# Install neovim from github to get latest version
curl -L https://github.com/neovim/neovim/releases/download/stable/nvim-linux-x86_64.tar.gz -o tmp.tar.gz
sudo mkdir -p /opt/nvim
sudo tar xf tmp.tar.gz -C /opt/nvim --strip-components=1
sudo ln -s /opt/nvim/bin/nvim /usr/bin/nvim
rm tmp.tar.gz
fi
elif [ $has_pacman -eq 1 ]; then
sudo pacman -Sy ${packages[@]} --noconfirm --needed
fi
if [ $should_configure_dotfiles ]; then
sudo chsh $USER -s /usr/bin/zsh
fi
fi
# Prepare venv for python
if [ $should_configure_python -eq 1 ]; then
python -m venv $HOME/.venv
VIRTUAL_ENV=$HOME/.venv $HOME/.venv/bin/pip install ${python_packages[@]}
fi
# Configure dotfiles
if [ $should_clone_dotfiles -eq 1 ]; then
if [ ! -d $HOME/.config/dotfiles ]; then
git clone https://gitea.tforgione.fr/tforgione/dotfiles $HOME/.config/dotfiles
fi
fi
if [ $should_install_dotfiles -eq 1 ]; then
if [ ! -d $HOME/.config/ohmyzsh ]; then
git clone https://github.com/ohmyzsh/ohmyzsh $HOME/.config/ohmyzsh
fi
ln -s $HOME/.config/dotfiles/zshrc $HOME/.zshrc
if [ $should_install_update_remainder -eq 1 ]; then
echo "# Checks that the update is done weekly, if its not done, prints a nice message" >> $HOME/.config/dotfiles/zsh/extraconfig.zsh
echo "export UPDATE_CHECK=weekly" >> $HOME/.config/dotfiles/zsh/extraconfig.zsh
echo "export UPDATE_CHECK_TYPE=sliding" >> $HOME/.config/dotfiles/zsh/extraconfig.zsh
export UPDATE_CHECK=weekly
export UPDATE_CHECK_TYPE=sliding
$HOME/.config/dotfiles/bin/update postpone
if [ $has_sudo -eq 0 ]; then
mkdir -p $HOME/.config/dotfiles/.data
touch $HOME/.config/dotfiles/.data/noroot
fi
fi
fi
# Configure hyprland
if [ $should_install_hyprland -eq 1 ]; then
if [ ! -d $HOME/.config/hypr ]; then
git clone https://gitea.tforgione.fr/tforgione/hypr
fi
ln -s $HOME/.config/hypr/waybar $HOME/.config/waybar
touch $HOME/.config/hypr/exec-once.conf
touch $HOME/.config/hypr/monitors.conf
fi
# Configure neovim
if [ $should_configure_neovim -eq 1 ]; then
# Create config files an directories
mkdir -p $HOME/.nvim/backups $HOME/.nvim/swp $HOME/.nvim/undo
ln -s $HOME/.config/dotfiles/nvim $HOME/.config/nvim
# Empty extra config for nvim
mkdir -p $HOME/.config/dotfies/nvim/lua
echo "-- Customize your neovim config here" > $HOME/.config/dotfiles/nvim/lua/extraconfig.lua
# Install vim plug
curl -fLo $HOME/.local/share/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# Install plugins
nvim +PlugInstall +qa
fi
# Configure nodejs
if [ $should_configure_nodejs -eq 1 ]; then
mkdir -p $HOME/.npmbin
npm config set prefix $HOME/.npmbin
npm install -g npm
fi
# Configure rust
if [ $should_install_rust -eq 1 ]; then
curl https://sh.rustup.rs -sSf | sh -s -- --no-modify-path -y
export PATH=$HOME/.cargo/bin:$PATH
rustup component add rust-analyzer
fi
}
banner() {
echo -e "\x1b[32;1m┌───────────────────────────────────────────────────────────────────────────────────────────┐"
echo "│ _ __ _ _ _ _ _ _ │"
echo "│ | | / _| (_) ( ) (_) | | | | | │"
echo "│ | |_| |_ ___ _ __ __ _ _ ___ _ __ ___|/ ___ _ _ __ ___| |_ __ _| | | ___ _ __ │"
echo "│ | __| _/ _ \| '__/ _\` | |/ _ \| '_ \ / _ \ / __| | | '_ \/ __| __/ _\` | | |/ _ \ '__| │"
echo "│ | |_| || (_) | | | (_| | | (_) | | | | __/ \__ \ | | | | \__ \ || (_| | | | __/ | │"
echo "│ \__|_| \___/|_| \__, |_|\___/|_| |_|\___| |___/ |_|_| |_|___/\__\__,_|_|_|\___|_| │"
echo "│ __/ | │"
echo "│ |___/ │"
echo "├───────────────────────────────────────────────────────────────────────────────────────────┤"
echo "│ WELCOME TO TFORGIONE'S INSTALLER │"
echo -e "└───────────────────────────────────────────────────────────────────────────────────────────┘\x1b[0m"
}
ending_banner() {
echo -e "\x1b[32;1m┌───────────────────────────────────────────────────────────────────────────────────────────┐"
echo "│ _ __ _ _ _ _ _ _ │"
echo "│ | | / _| (_) ( ) (_) | | | | | │"
echo "│ | |_| |_ ___ _ __ __ _ _ ___ _ __ ___|/ ___ _ _ __ ___| |_ __ _| | | ___ _ __ │"
echo "│ | __| _/ _ \| '__/ _\` | |/ _ \| '_ \ / _ \ / __| | | '_ \/ __| __/ _\` | | |/ _ \ '__| │"
echo "│ | |_| || (_) | | | (_| | | (_) | | | | __/ \__ \ | | | | \__ \ || (_| | | | __/ | │"
echo "│ \__|_| \___/|_| \__, |_|\___/|_| |_|\___| |___/ |_|_| |_|___/\__\__,_|_|_|\___|_| │"
echo "│ __/ | │"
echo "│ |___/ │"
echo "├───────────────────────────────────────────────────────────────────────────────────────────┤"
echo "│ TFORGIONE'S DOTFILES INSTALLED! HAVE A GREAT DAY! │"
echo -e "└───────────────────────────────────────────────────────────────────────────────────────────┘\x1b[0m"
} }
main() { main() {
echo_green "=== WELCOME TO TFORGIONE'S CONFIG INSTALLER ===" banner
find_os
info "before anything, i need to know if your user can use sudo" info "before anything, i need to know if your user can use sudo"
yes_no_ask "can your user use sudo?" yes_no_ask "can your user use sudo?"
sudo_available=$? if [ $? -eq 0 ]; then
has_sudo=1
fi
configure_dotfiles ask_for_dotfiles
configure_shell ask_for_neovim
configure_neovim ask_for_rust
configure_powerline ask_for_python
configure_rust ask_for_nodejs
configure_node ask_for_hyprland
configure_awesome
debug
run
ending_banner
} }
main < /dev/tty main < /dev/tty