From 128e81a157ea40278592f9b827049c4d7bcfe810 Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Wed, 4 Oct 2023 21:50:44 -0400 Subject: [PATCH] Tweak bashrc and rust format scripts --- bashrc | 33 ++++++--------------------------- bin/cfmt | 12 ++++++++++++ bin/format-rs-from-helix | 28 +++++++++------------------- bin/run-from-helix | 2 +- 4 files changed, 28 insertions(+), 47 deletions(-) create mode 100755 bin/cfmt mode change 100644 => 100755 bin/format-rs-from-helix diff --git a/bashrc b/bashrc index 5750f0c..f6ad5fb 100755 --- a/bashrc +++ b/bashrc @@ -6,9 +6,8 @@ [ -z "$PS1" ] && return # set PATH so it includes user's private bin if it exists -if [ -d "$HOME/bin" ] ; then - PATH="$HOME/bin:$PATH" -fi +[ -d "$HOME/bin" ] && PATH="$HOME/bin:$PATH" +[ -d "$HOME/.config/bin" ] && PATH="$HOME/.config/bin:$PATH" # don't put duplicate lines in the history. See bash(1) for more options # ... or force ignoredups and ignorespace @@ -108,7 +107,9 @@ function pdfcat () { } # https://incenp.org/notes/2015/gnupg-for-ssh-authentication.html -gpg-connect-agent /bye +# gpg-connect-agent /bye +export GPG_TTY=$(tty) +gpg-connect-agent updatestartuptty /bye >/dev/null export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" function mkcd() { @@ -134,29 +135,7 @@ export VISUAL=$EDITOR export PATH="$PATH:$HOME/.cargo/bin" -export PATH="$PATH:/mnt/winegames/bin" - -#alias cfmt='cargo fmt -- --config imports_granularity=crate' -function cfmt() { -if [ -f rustfmt.toml]; then - cargo fmt -- --config-path rustfmt.toml - exit $? -fi -if [ -f .rustfmt.toml]; then - cargo fmt -- --config-path .rustfmt.toml - exit $? -fi -if [ -f rustfmt.nightly.toml]; then - cargo +nightly fmt -- --config-path rustfmt.nightly.toml - exit $? -fi -if [ -f .rustfmt.nightly.toml]; then - cargo +nightly fmt -- --config-path .rustfm.nightly.toml - exit $? -fi -# ok then just run my preferred format -cargo +nightly fmt -- --config imports_granularity=crate -} +[ -d /mnt/winegames/bin ] && export PATH="$PATH:/mnt/winegames/bin" function spurdo() { sed "s/kek/geg/gI;s/epic/ebin/gI;s/america/clapistan/gI;s/right/rite/gI;s/your/ur/gI;s/\./ :DD/gI;s/'//gI;s/,/XDD/gI;s/wh/w/gI;s/th/d/gI;s/af/ab/gI;s/ap/ab/gI;s/ca/ga/gI;s/ck/gg/gI;s/co/go/gI;s/ev/eb/gI;s/ex/egz/gI;s/et/ed/gI;s/iv/ib/gI;s/it/id/gI;s/ke/ge/gI;s/nt/nd/gI;s/op/ob/gI;s/ot/od/gI;s/po/bo/gI;s/pe/be/gI;s/pi/bi/gI;s/up/ub/gI;s/va/ba/gI;s/ck/gg/gI;s/cr/gr/gI;s/kn/gn/gI;s/lt/ld/gI;s/mm/m/gI;s/nt/dn/gI;s/pr/br/gI;s/ts/dz/gI;s/tr/dr/gI;s/bs/bz/gI;s/ds/dz/gI;s/es/es/gI;s/fs/fz/gI;s/gs/gz/gI;s/ is/iz/gI;s/as/az/gI;s/ls/lz/gI;s/ms/mz/gI;s/ns/nz/gI;s/rs/rz/gI;s/ss/sz/gI;s/ts/tz/gI;s/us/uz/gI;s/ws/wz/gI;s/ys/yz/gI;s/alk/olk/gI;s/ing/ign/gI;s/ic/ig/gI;s/ng/nk/gI" \ diff --git a/bin/cfmt b/bin/cfmt new file mode 100755 index 0000000..7ee239e --- /dev/null +++ b/bin/cfmt @@ -0,0 +1,12 @@ +#!/bin/bash + +args="" + +for cfg in rustfmt.toml .rustfmt.toml rustfmt.nightly.toml .rustfmt.nightly.toml rustfmt-nightly.toml .rustfmt-nightly.toml +do +[ "$cfg" == "rustfmt.nightly.toml" ] && args="+nightly $args" +[ -f $cfg ] && exec cargo $args fmt -- --config-path $cfg +done + +# or if no files, fallback to my preferred format +exec cargo $args fmt -- --config imports_granularity=crate diff --git a/bin/format-rs-from-helix b/bin/format-rs-from-helix old mode 100644 new mode 100755 index 5251878..8c6d520 --- a/bin/format-rs-from-helix +++ b/bin/format-rs-from-helix @@ -1,22 +1,12 @@ -!/bin/bash +#!/bin/bash args="--emit stdout --edition 2021 --color never" -if [ -f rustfmt.toml]; then - rustfmt $args --config-path rustfmt.toml - exit $? -fi -if [ -f .rustfmt.toml]; then - rustfmt $args --config-path .rustfmt.toml - exit $? -fi -if [ -f rustfmt.nightly.toml]; then - rustfmt +nightly $args --config-path rustfmt.nightly.toml - exit $? -fi -if [ -f .rustfmt.nightly.toml]; then - rustfmt +nightly $args --config-path .rustfm.nightly.toml - exit $? -fi -# ok then just run my preferred format -rustfmt +nightly $args --config imports_granularity=crate +for cfg in rustfmt.toml .rustfmt.toml rustfmt.nightly.toml .rustfmt.nightly.toml rustfmt-nightly.toml .rustfmt-nightly.toml +do +[ "$cfg" == "rustfmt.nightly.toml" ] && args="+nightly $args" +[ -f $cfg ] && exec rustfmt $args --config-path $cfg +done + +# or if no files, fallback to my preferred format +exec rustfmt $args --config imports_granularity=crate diff --git a/bin/run-from-helix b/bin/run-from-helix index b14be35..6c83697 100755 --- a/bin/run-from-helix +++ b/bin/run-from-helix @@ -1,4 +1,4 @@ -#/bin/bash +#!/bin/bash exec cargo test