Misc: Rust, Helix, tmux underline, bash, rg, ...

Add:
- Rust and Helix install/configure scripts
- tmux curly underline with colors
- Rocky SSH & Mosh setup
- `asciinema` and `rg`
- Mosh PPA for old Ubuntu systems
- VirtualBox USB devices group
- Add `~/.local/bin/` to path in .bashrc

Update:
- Use `~/.bash_login` instead of `~/.profile` for tmux on login and exec it
- Rename `gnome-todo` to `endeavour`
- Use new sshd alias
- Reload instead of restarting sshd

Remove:
- Vim colorschemes and plugins
- `.sh` extensions on executable scripts
This commit is contained in:
DuckDuckWhale 2023-03-19 22:14:45 -07:00
parent 7ff86d5f2d
commit c772724cac
Signed by: DuckDuckWhale
GPG Key ID: E4B9FC170FFD71CE
19 changed files with 221 additions and 30 deletions

View File

@ -1,32 +1,32 @@
#!/bin/sh
#!/bin/sh -e
cd ssh
./ssh.sh
./ssh
cd ..
cd bash
./bash.sh
./bash
cd ..
cd git
./git.sh
./git
cd ..
cd vim
./vim.sh
./vim
cd ..
cd gnome
./gnome.sh
./gnome
cd ..
cd readline
./readline.sh
./readline
cd ..
cd tmux
./tmux.sh
./tmux
cd ..
cd home-chmod
./home-chmod.sh
./home-chmod
cd ..

View File

@ -9,6 +9,10 @@ export EDITOR='vim'
export VISUAL='vim'
export GPG_TTY=$(tty)
if [[ -d "$HOME/.local/bin" && ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
PATH="$HOME/.local/bin:$PATH"
fi
# cool colored command prompt
PS1='${debian_chroot:+($debian_chroot)}\[\e[01;38;5;11m\]\u\[\e[00;38;5;208m\]@\[\e[01;38;5;27m\]\h\[\e[00m\]:\[\e[00;38;5;45m\]\w\[\e[0m\]\$ '
@ -32,20 +36,23 @@ popd() {
cd .
}
EOF
cat >> ~/.profile << 'EOF'
if [ -f ~/.bash_profile ]; then
mv ~/.bash_profile ~/.bash_login
fi
cat >> ~/.bash_login << 'EOF'
# custom
if [ -z "$TMUX" ] && [ -n "$SSH_TTY" ]; then
tput sc
tput smso
echo -n 'tmux: space - shell: any key'
echo -n 'tmux: space / shell: any key'
tput sgr0
read -rsN1 input
tput rc
tput el
if [ "$input" = ' ' ]; then
tmux new -As default
exec tmux new -As default
fi
fi
EOF

View File

@ -2,6 +2,10 @@ set -g clock-mode-style 12
set -g default-command "${SHELL}"
set -g default-terminal "tmux-256color"
set -as terminal-features ",xterm-256color:RGB"
# curly underline support
set -as terminal-overrides ',*:Smulx=\E[4::%p1%dm'
# underline colors - needs tmux-3.0
set -as terminal-overrides ',*:Setulc=\E[58::2::%p1%{65536}%/%d::%p1%{256}%/%{255}%&%d::%p1%{255}%&%d%;m'
set -g history-limit 10000
set -g prefix C-q
set -sg escape-time 25

View File

@ -1,10 +1,3 @@
" vim-plug
call plug#begin()
Plug 'chriskempson/base16-vim'
Plug 'dhruvasagar/vim-table-mode'
call plug#end()
colorscheme base16-default-dark
filetype plugin indent on
syntax on

2
auto/vim/vim Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
cp -i .vimrc ~

View File

@ -1,4 +0,0 @@
#!/bin/sh
cp -i .vimrc ~
curl -Lo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

65
manual/helix/helix Executable file
View File

@ -0,0 +1,65 @@
#!/bin/sh -e
if ! command -v cargo > /dev/null; then
echo "Error: cargo not found"
exit 1
fi
if ! command -v c++ > /dev/null; then
echo "Error: c++ not found"
exit 1
fi
git clone https://github.com/helix-editor/helix helix-git
cd helix-git
cargo install --locked --path helix-term
mkdir -p ~/.config/helix
rm -rf runtime/grammars/sources
mv runtime ~/.config/helix
rm -rf helix-git
cat > ~/.config/helix/config.toml << 'EOF'
theme = "monokai_pro_ristretto"
[editor]
auto-pairs = false
bufferline = "multiple"
rulers = [101]
[editor.statusline]
left = ["mode", "spinner", "file-name"]
center = ["position-percentage"]
right = ["diagnostics", "selections", "position", "file-encoding", "file-line-ending"]
[keys.normal]
space.z = ":reflow 100"
[editor.soft-wrap]
enable = true
EOF
cat > ~/.config/helix/languages.toml << 'EOF'
[editor]
auto-pairs = false
[[language]]
name = 'rust'
indent.unit = "\t"
indent.tab-width = 4
config.checkOnSave = { command = "clippy" }
[[language]]
name = "c"
indent = { tab-width = 4, unit = "\t" }
[[language]]
name = "cpp"
indent = { tab-width = 4, unit = "\t" }
[[language]]
name = 'java'
indent.unit = "\t"
indent.tab-width = 4
[[language]]
name = "markdown"
language-server = { command = "ltex-ls" }
file-types = ["md"]
scope = "source.markdown"
roots = []
EOF

32
manual/rust/rust Executable file
View File

@ -0,0 +1,32 @@
#!/bin/sh -e
if [ $# -gt 2 ]; then
echo "Usage: $0 [-f]"
exit 1
fi
if [ "$1" = '-f' ]; then
force=true
fi
if ! command -v curl > /dev/null; then
echo "Error: curl not found"
exit 1
fi
if command -v cargo > /dev/null && [ "$force" != true ]; then
echo "Error: rust already installed; use -f to force"
exit 1
fi
curl --proto '=https' --tlsv1.3 -sSf https://sh.rustup.rs | sh -s -- -y
. "$HOME/.cargo/env"
rustup component add rust-analyzer
cat >> ~/.cargo/config.toml << 'EOF'
[registries.crates-io]
protocol = "sparse"
EOF
mkdir -p ~/.local/bin
cat >> ~/.local/bin/rust-analyzer << 'EOF'
#!/bin/sh
$(rustup which rust-analyzer) "$@"
EOF
chmod +x ~/.local/bin/rust-analyzer
cargo install cargo-auditable
cargo install --force cargo-auditable rust-script
./rust-configure

64
manual/rust/rust-configure Executable file
View File

@ -0,0 +1,64 @@
#!/usr/bin/env rust-script
//! ```cargo
//! [dependencies]
//! anyhow = "1.0.69"
//! dirs = "4.0.0"
//! ```
use anyhow::Context;
use std::{
fs::{self, File},
io::{BufRead, BufReader},
};
const ENV: &str = r#". "$HOME/.cargo/env""#;
fn main() -> anyhow::Result<()> {
let home = dirs::home_dir().context("can't find home directory")?;
let mut login_path = home.clone();
login_path.push(".bash_login");
let login = BufReader::new(File::open(&login_path).context("failed to read ~/.bash_login")?);
let mut bashrc_path = home.clone();
bashrc_path.push(".bashrc");
let bashrc = BufReader::new(File::open(&bashrc_path).context("failed to read ~/.bashrc")?);
let mut empty = false;
let mut new_bashrc = String::new();
for line in bashrc.lines() {
let line = line.context("failed to read line in ~/.bashrc")?;
if line.is_empty() && empty {
continue;
}
empty = line.is_empty();
if line != ENV {
new_bashrc.push_str(&line);
new_bashrc.push('\n');
}
}
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(())
}

8
setup/rocky-setup.md Normal file
View File

@ -0,0 +1,8 @@
# Rocky 9 Setup
## OpenSSH Server & Mosh
Same as Ubuntu, but:
- `s/apt/dnf/g`
- `s/sshd_config/sshd_config-rhel/g`
- `s/OpenSSH/SSH/g`

View File

@ -5,13 +5,13 @@ Here's my personal Ubuntu 22.10 setup. (Make sure to enable Wayland on Nvidia!)
- Set font size in Terminal to 15 and initial column count to 85
- Must haves:
- `sudo apt install curl ddcutil deja-dup earlyoom ffmpeg flatpak git gnome-boxes gnome-clocks \
gnome-software-plugin-flatpak gnome-sound-recorder gnome-todo gnome-weather goldendict gparted \
gnome-software-plugin-flatpak gnome-sound-recorder endeavour gnome-weather goldendict gparted \
keepassxc mosh mpv needrestart obs-studio shadowsocks-libev sshfs synaptic tmux trash-cli ufw \
vim-gtk3 vlc wl-clipboard`
vim-gtk3 vlc wl-clipboard rg
- Optional:
- `sudo apt install gnome-firmware gnome-games gnome-nettool gnome-packagekit gnome-passwordsafe \
gnome-shell-pomodoro gnome-usage gthumb mkvtoolnix-gui openjdk-17-jdk pulseeffectsqpdf ranger \
syncplay virtualbox-qt heif-gdk-pixbuf heif-thumbnailer`
syncplay virtualbox-qt heif-gdk-pixbuf heif-thumbnailer asciinema`
- Remove all snaps:
- ```
# if this command fails, unmount the snap mounts as reported by `mount` and try again
@ -49,6 +49,8 @@ Here's my personal Ubuntu 22.10 setup. (Make sure to enable Wayland on Nvidia!)
- Cross compiling (?)
- `gcc-aarch64-linux-gnu`
- `gcc-arm-linux-gnueabihf`
- Virtualbox
- `sudo usermod -aG vboxusers $(whoami)`
## UFW
@ -228,6 +230,8 @@ sudo chmod -R 700 /opt/grub
## OpenSSH Server & Mosh
```
# trusted PPA from mosh developer for truecolor support
# sudo add-apt-repository ppa:keithw/mosh-dev
sudo apt install -y openssh-server mosh
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
sudo cp ../system/sshd/sshd_config /etc/ssh/sshd_config
@ -240,7 +244,7 @@ chmod 600 ~/.ssh/authorized_keys
# insert your SSH public keys into the file
sudo ufw limit OpenSSH
sudo ufw allow 60001:60999/udp
sudo systemctl restart ssh
sudo systemctl reload sshd
```
## See logs as admin

View File

@ -4,9 +4,9 @@ Port 22
PermitRootLogin no
PubkeyAuthentication yes
PasswordAuthentication no
# would be deprecated soon by
# KbdInteractiveAuthentication no
ChallengeResponseAuthentication no
# deprecated alias:
# ChallengeResponseAuthentication no
KbdInteractiveAuthentication no
UsePAM yes
AllowTcpForwarding yes
X11Forwarding yes

View File

@ -0,0 +1,16 @@
Include /etc/ssh/sshd_config.d/*.conf
AllowGroups ssh-users
Port 22
PermitRootLogin no
PubkeyAuthentication yes
PasswordAuthentication no
# deprecated alias:
# ChallengeResponseAuthentication no
KbdInteractiveAuthentication no
AuthorizedKeysFile .ssh/authorized_keys
UsePAM yes
AllowTcpForwarding yes
X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_* COLORTERM
Subsystem sftp /usr/libexec/openssh/sftp-server