Misc: bash, rust, helix

- Fix: `.bashrc` not loaded when `.bash_login` doesn't exist
- Fix: Rust install script error when `cc` doesn't exist
- Style: use tabs
- Helix: use tabs for bash, toml, & markdown
- Helix: highlight rust scripts
This commit is contained in:
DuckDuckWhale 2023-04-06 12:35:40 -07:00
parent 38ec154801
commit cac1b3176a
Signed by: DuckDuckWhale
GPG Key ID: E4B9FC170FFD71CE
3 changed files with 50 additions and 24 deletions

View File

@ -39,10 +39,24 @@ EOF
if [ -f ~/.bash_profile ]; then if [ -f ~/.bash_profile ]; then
mv ~/.bash_profile ~/.bash_login mv ~/.bash_profile ~/.bash_login
fi fi
cat >> ~/.bash_login << 'EOF' if [ -f ~/.bash_login ]; then
cat >> ~/.bash_login << 'EOF'
# custom # custom
EOF
else
cat >> ~/.bash_login << 'EOF'
# custom
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
EOF
fi
cat >> ~/.bash_login << 'EOF'
if [ -z "$TMUX" ] && [ -n "$SSH_TTY" ]; then if [ -z "$TMUX" ] && [ -n "$SSH_TTY" ]; then
tput sc tput sc
tput smso tput smso

View File

@ -1,22 +1,22 @@
#!/bin/sh -e #!/bin/sh -e
if [ "$1" = '-f' ]; then if [ "$1" = '-f' ]; then
force=true force=true
fi 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
fi fi
if ! command -v c++ > /dev/null; then if ! command -v c++ > /dev/null; then
echo "Error: c++ not found" echo "Error: c++ not found"
exit 1 exit 1
fi fi
if [ -d ~/.config/helix ]; then if [ -d ~/.config/helix ]; then
if [ "$force" = true ]; then if [ "$force" = true ]; then
rm -rf ~/.config/helix rm -rf ~/.config/helix
else else
echo "Error: helix config files already exist; use -f to force erase and reinstall" echo "Error: helix config files already exist; use -f to force erase and reinstall"
exit 1 exit 1
fi fi
fi fi
rm -rf helix-git rm -rf helix-git
git clone --depth 1 --branch 23.03 https://github.com/helix-editor/helix helix-git git clone --depth 1 --branch 23.03 https://github.com/helix-editor/helix helix-git
@ -38,7 +38,7 @@ rulers = [101]
left = ["mode", "spinner", "file-name"] left = ["mode", "spinner", "file-name"]
center = ["position-percentage"] center = ["position-percentage"]
right = [ right = [
"version-control", "diagnostics", "selections", "position", "file-encoding", "file-line-ending" "version-control", "diagnostics", "selections", "position", "file-encoding", "file-line-ending"
] ]
[keys.normal] [keys.normal]
@ -54,9 +54,9 @@ auto-pairs = false
[[language]] [[language]]
name = 'rust' name = 'rust'
indent.unit = "\t" indent = { tab-width = 4, unit = "\t" }
indent.tab-width = 4
config.checkOnSave = { command = "clippy" } config.checkOnSave = { command = "clippy" }
shebangs = ["rust-script"]
[[language]] [[language]]
name = "c" name = "c"
@ -68,11 +68,19 @@ indent = { tab-width = 4, unit = "\t" }
[[language]] [[language]]
name = 'java' name = 'java'
indent.unit = "\t" indent = { tab-width = 4, unit = "\t" }
indent.tab-width = 4
[[language]]
name = "bash"
indent = { tab-width = 4, unit = "\t" }
[[language]]
name = "toml"
indent = { tab-width = 4, unit = "\t" }
[[language]] [[language]]
name = "markdown" name = "markdown"
indent = { tab-width = 4, unit = "\t" }
language-server = { command = "ltex-ls" } language-server = { command = "ltex-ls" }
file-types = ["md"] file-types = ["md"]
scope = "source.markdown" scope = "source.markdown"

View File

@ -1,18 +1,22 @@
#!/bin/sh -e #!/bin/sh -e
if [ $# -gt 2 ]; then if [ $# -gt 2 ]; then
echo "Usage: $0 [-f]" echo "Usage: $0 [-f]"
exit 1 exit 1
fi fi
if [ "$1" = '-f' ]; then if [ "$1" = '-f' ]; then
force=true force=true
fi fi
if ! command -v curl > /dev/null; then if ! command -v curl > /dev/null; then
echo "Error: curl not found" echo "Error: curl not found"
exit 1 exit 1
fi
if ! command -v cc > /dev/null; then
echo "Error: cc not found"
exit 1
fi fi
if command -v cargo > /dev/null && [ "$force" != true ]; then if command -v cargo > /dev/null && [ "$force" != true ]; then
echo "Error: rust already installed; use -f to force" echo "Error: rust already installed; use -f to force"
exit 1 exit 1
fi fi
curl --proto '=https' --tlsv1.3 -sSf https://sh.rustup.rs | sh -s -- -y curl --proto '=https' --tlsv1.3 -sSf https://sh.rustup.rs | sh -s -- -y
. "$HOME/.cargo/env" . "$HOME/.cargo/env"