Misc: helix and ubuntu-setup
- Use shallow clone to install Helix - Fix rust-configure panics when bash dotfiles don't exist - Use tabs for Rust scripts - Fix Helix version to 23.03 - Helix force install - Helix LSP inlay hints key - Other Ubuntu packages
This commit is contained in:
parent
5531ddb2d1
commit
38ec154801
@ -1,4 +1,7 @@
|
|||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
if [ "$1" = '-f' ]; then
|
||||||
|
force=true
|
||||||
|
fi
|
||||||
if ! command -v cargo > /dev/null; then
|
if ! command -v cargo > /dev/null; then
|
||||||
echo "Error: cargo not found"
|
echo "Error: cargo not found"
|
||||||
exit 1
|
exit 1
|
||||||
@ -7,7 +10,16 @@ if ! command -v c++ > /dev/null; then
|
|||||||
echo "Error: c++ not found"
|
echo "Error: c++ not found"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
git clone https://github.com/helix-editor/helix helix-git
|
if [ -d ~/.config/helix ]; then
|
||||||
|
if [ "$force" = true ]; then
|
||||||
|
rm -rf ~/.config/helix
|
||||||
|
else
|
||||||
|
echo "Error: helix config files already exist; use -f to force erase and reinstall"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
rm -rf helix-git
|
||||||
|
git clone --depth 1 --branch 23.03 https://github.com/helix-editor/helix helix-git
|
||||||
cd helix-git
|
cd helix-git
|
||||||
cargo install --locked --path helix-term
|
cargo install --locked --path helix-term
|
||||||
mkdir -p ~/.config/helix
|
mkdir -p ~/.config/helix
|
||||||
@ -25,10 +37,13 @@ rulers = [101]
|
|||||||
[editor.statusline]
|
[editor.statusline]
|
||||||
left = ["mode", "spinner", "file-name"]
|
left = ["mode", "spinner", "file-name"]
|
||||||
center = ["position-percentage"]
|
center = ["position-percentage"]
|
||||||
right = ["diagnostics", "selections", "position", "file-encoding", "file-line-ending"]
|
right = [
|
||||||
|
"version-control", "diagnostics", "selections", "position", "file-encoding", "file-line-ending"
|
||||||
|
]
|
||||||
|
|
||||||
[keys.normal]
|
[keys.normal]
|
||||||
space.z = ":reflow 100"
|
space.z = ":reflow 100"
|
||||||
|
space.i = ":toggle lsp.display-inlay-hints"
|
||||||
|
|
||||||
[editor.soft-wrap]
|
[editor.soft-wrap]
|
||||||
enable = true
|
enable = true
|
||||||
@ -63,3 +78,4 @@ file-types = ["md"]
|
|||||||
scope = "source.markdown"
|
scope = "source.markdown"
|
||||||
roots = []
|
roots = []
|
||||||
EOF
|
EOF
|
||||||
|
rm -rf helix-git
|
||||||
|
@ -21,6 +21,10 @@ cat >> ~/.cargo/config.toml << 'EOF'
|
|||||||
[registries.crates-io]
|
[registries.crates-io]
|
||||||
protocol = "sparse"
|
protocol = "sparse"
|
||||||
EOF
|
EOF
|
||||||
|
mkdir -p ~/.config/rustfmt
|
||||||
|
cat >> ~/.config/rustfmt/rustfmt.toml << 'EOF'
|
||||||
|
hard_tabs = true
|
||||||
|
EOF
|
||||||
mkdir -p ~/.local/bin
|
mkdir -p ~/.local/bin
|
||||||
cat >> ~/.local/bin/rust-analyzer << 'EOF'
|
cat >> ~/.local/bin/rust-analyzer << 'EOF'
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
//! dirs = "4.0.0"
|
//! dirs = "4.0.0"
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::{anyhow, bail, Context};
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
fs::{self, File},
|
fs::{self, File},
|
||||||
io::{BufRead, BufReader},
|
io::{BufRead, BufReader, ErrorKind},
|
||||||
};
|
};
|
||||||
|
|
||||||
const ENV: &str = r#". "$HOME/.cargo/env""#;
|
const ENV: &str = r#". "$HOME/.cargo/env""#;
|
||||||
@ -18,47 +18,67 @@ fn main() -> anyhow::Result<()> {
|
|||||||
let home = dirs::home_dir().context("can't find home directory")?;
|
let home = dirs::home_dir().context("can't find home directory")?;
|
||||||
let mut login_path = home.clone();
|
let mut login_path = home.clone();
|
||||||
login_path.push(".bash_login");
|
login_path.push(".bash_login");
|
||||||
let login = BufReader::new(File::open(&login_path).context("failed to read ~/.bash_login")?);
|
let login = match File::open(&login_path) {
|
||||||
|
Ok(file) => {
|
||||||
|
let login = BufReader::new(file);
|
||||||
|
let mut skip = false;
|
||||||
|
let mut new_login = String::new();
|
||||||
|
let mut removed = false;
|
||||||
|
let mut added = false;
|
||||||
|
for line in login.lines() {
|
||||||
|
let line = line.context("failed to read line in ~/.bash_login")?;
|
||||||
|
if line.is_empty() && skip {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
skip = line.is_empty();
|
||||||
|
if line == ENV {
|
||||||
|
removed = true;
|
||||||
|
} else {
|
||||||
|
new_login.push_str(&line);
|
||||||
|
new_login.push('\n');
|
||||||
|
}
|
||||||
|
if line == "# custom" && !added {
|
||||||
|
added = true;
|
||||||
|
new_login.push('\n');
|
||||||
|
new_login.push_str(ENV);
|
||||||
|
new_login.push_str("\n\n");
|
||||||
|
skip = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if removed && !added {
|
||||||
|
bail!("would remove \"{ENV}\" and not add it back");
|
||||||
|
}
|
||||||
|
new_login.trim().to_owned() + "\n"
|
||||||
|
}
|
||||||
|
Err(e) if e.kind() == ErrorKind::NotFound => format!("# custom\n\n{ENV}\n"),
|
||||||
|
Err(e) => bail!(anyhow!(e).context("failed to read ~/.bash_login")),
|
||||||
|
};
|
||||||
|
fs::write(login_path, &login).context("failed to write new ~/.bash_login")?;
|
||||||
|
|
||||||
let mut bashrc_path = home.clone();
|
let mut bashrc_path = home.clone();
|
||||||
bashrc_path.push(".bashrc");
|
bashrc_path.push(".bashrc");
|
||||||
let bashrc = BufReader::new(File::open(&bashrc_path).context("failed to read ~/.bashrc")?);
|
let bashrc = match File::open(&bashrc_path) {
|
||||||
|
Ok(file) => {
|
||||||
let mut empty = false;
|
let bashrc = BufReader::new(file);
|
||||||
let mut new_bashrc = String::new();
|
let mut skip = false;
|
||||||
for line in bashrc.lines() {
|
let mut new_bashrc = String::new();
|
||||||
let line = line.context("failed to read line in ~/.bashrc")?;
|
for line in bashrc.lines() {
|
||||||
if line.is_empty() && empty {
|
let line = line.context("failed to read line in ~/.bashrc")?;
|
||||||
continue;
|
if line.is_empty() && skip {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
skip = line.is_empty();
|
||||||
|
if line != ENV {
|
||||||
|
new_bashrc.push_str(&line);
|
||||||
|
new_bashrc.push('\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
new_bashrc.trim().to_owned() + "\n"
|
||||||
}
|
}
|
||||||
empty = line.is_empty();
|
Err(e) if e.kind() == ErrorKind::NotFound => "# custom\n".to_owned(),
|
||||||
if line != ENV {
|
Err(e) => bail!(anyhow!(e).context("failed to read ~/.bashrc")),
|
||||||
new_bashrc.push_str(&line);
|
};
|
||||||
new_bashrc.push('\n');
|
fs::write(bashrc_path, &bashrc).context("failed to write new ~/.bashrc")?;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut empty = false;
|
|
||||||
let mut new_login = String::new();
|
|
||||||
for line in login.lines() {
|
|
||||||
let line = line.context("failed to read line in ~/.bash_login")?;
|
|
||||||
if line.is_empty() && empty {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
empty = line.is_empty();
|
|
||||||
if line != ENV {
|
|
||||||
new_login.push_str(&line);
|
|
||||||
new_login.push('\n');
|
|
||||||
}
|
|
||||||
if line == "# custom" {
|
|
||||||
new_login.push('\n');
|
|
||||||
new_login.push_str(ENV);
|
|
||||||
new_login.push_str("\n\n");
|
|
||||||
empty = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fs::write(bashrc_path, &new_bashrc).context("failed to write new .bashrc")?;
|
|
||||||
fs::write(login_path, &new_login).context("failed to write new .bash_login")?;
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,12 @@ Here's my personal Ubuntu 22.10 setup. (Make sure to enable Wayland on Nvidia!)
|
|||||||
- `sudo apt install curl ddcutil deja-dup earlyoom endeavour ffmpeg flatpak git gnome-boxes \
|
- `sudo apt install curl ddcutil deja-dup earlyoom endeavour ffmpeg flatpak git gnome-boxes \
|
||||||
gnome-clocks gnome-software-plugin-flatpak gnome-sound-recorder gnome-weather goldendict \
|
gnome-clocks gnome-software-plugin-flatpak gnome-sound-recorder gnome-weather goldendict \
|
||||||
gparted keepassxc mpv needrestart obs-studio ripgrep shadowsocks-libev sshfs synaptic tmux \
|
gparted keepassxc mpv needrestart obs-studio ripgrep shadowsocks-libev sshfs synaptic tmux \
|
||||||
trash-cli ufw vim-gtk3 vlc wl-clipboard`
|
trash-cli ufw vim-gtk3 vlc wl-clipboard linux-tools-generic`
|
||||||
- Optional:
|
- Optional:
|
||||||
- `sudo apt install gnome-firmware gnome-games gnome-nettool gnome-packagekit gnome-passwordsafe \
|
- `sudo apt install arp-scan asciinema bookworm foliate gimp gnome-firmware gnome-games \
|
||||||
gnome-shell-pomodoro gnome-usage gthumb mkvtoolnix-gui openjdk-17-jdk pulseeffectsqpdf ranger \
|
gnome-nettool gnome-packagekit gnome-passwordsafe gnome-shell-pomodoro gnome-usage gthumb \
|
||||||
syncplay virtualbox-qt heif-gdk-pixbuf heif-thumbnailer asciinema`
|
heif-gdk-pixbuf heif-thumbnailer mkvtoolnix-gui openjdk-17-jdk pulseeffectsqpdf ranger \
|
||||||
|
syncplay virtualbox-qt`
|
||||||
- Remove all snaps:
|
- Remove all snaps:
|
||||||
- ```
|
- ```
|
||||||
# if this command fails, do the following then try again:
|
# if this command fails, do the following then try again:
|
||||||
@ -80,6 +81,7 @@ Here's my personal Ubuntu 22.10 setup. (Make sure to enable Wayland on Nvidia!)
|
|||||||
- `sudo apt install gnome-tweaks`
|
- `sudo apt install gnome-tweaks`
|
||||||
- Extensions
|
- Extensions
|
||||||
- `sudo apt install gnome-shell-extensions`
|
- `sudo apt install gnome-shell-extensions`
|
||||||
|
- Go to settings -> `Region & Language` and install `Chinese (simplified)`.
|
||||||
- GSConnect
|
- GSConnect
|
||||||
- `sudo apt install gnome-shell-extension-gsconnect`
|
- `sudo apt install gnome-shell-extension-gsconnect`
|
||||||
- UFW:
|
- UFW:
|
||||||
@ -92,7 +94,6 @@ Here's my personal Ubuntu 22.10 setup. (Make sure to enable Wayland on Nvidia!)
|
|||||||
- Use Wayland for correct fractional scaling:
|
- Use Wayland for correct fractional scaling:
|
||||||
`sudo flatpak override --socket=wayland --env=MOZ_ENABLE_WAYLAND=1
|
`sudo flatpak override --socket=wayland --env=MOZ_ENABLE_WAYLAND=1
|
||||||
org.mozilla.firefox`
|
org.mozilla.firefox`
|
||||||
- Go to settings -> `Region & Language` and install `Chinese (simplified)`.
|
|
||||||
- OBS Studio
|
- OBS Studio
|
||||||
- `$ sudo apt install qtwayland5`
|
- `$ sudo apt install qtwayland5`
|
||||||
- On Ubuntu <22.10, in `/usr/share/applications/com.obsproject.Studio.desktop`, replace
|
- On Ubuntu <22.10, in `/usr/share/applications/com.obsproject.Studio.desktop`, replace
|
||||||
|
Loading…
Reference in New Issue
Block a user