From ed903f6ba027d3b40f4b9cbdccb6fc2ad6673e9c Mon Sep 17 00:00:00 2001 From: Luca Matei Pintilie Date: Wed, 18 Jan 2023 21:24:34 +0100 Subject: Better shell scripts --- .bashrc | 15 ++++++++------ .profile | 66 +++++++++++++++++++++++++++++++++++++++++------------------- bootstrap.sh | 22 +++++++++++--------- 3 files changed, 66 insertions(+), 37 deletions(-) diff --git a/.bashrc b/.bashrc index 70e9699..29fef1e 100644 --- a/.bashrc +++ b/.bashrc @@ -10,7 +10,8 @@ # Test for an interactive shell. There is no need to set anything # past this point for scp and rcp, and it's important to refrain from # outputting anything in those cases. -if [[ $- != *i* ]] ; then +if [[ $- != *i* ]] +then # Shell is non-interactive. Be done now! return fi @@ -21,22 +22,24 @@ fi alias cls="clear" BAT="$(which bat 2> /dev/null || which batcat 2> /dev/null)" -if [ -n $BAT ] +if [ -n "$BAT" ] then alias cat="$BAT -p" fi -alias ls="$(which lsd 2> /dev/null || echo "ls -h -F --color=auto --group-directories-first")" -alias sudo="$(which doas 2> /dev/null || which sudo 2> /dev/null || echo 'su -c')" +alias ls="$(which lsd 2> /dev/null || echo "ls -h -F --color=auto --group-directories-first")" +alias sudo="$(which doas 2> /dev/null || which sudo 2> /dev/null || echo "su -c")" alias codium="flatpak run com.vscodium.codium --no-sandbox --enable-features=UseOzonePlatform --ozone-platform=wayland" alias tmux="tmux -2" . /usr/share/bash-completion/bash_completion -for f in $HOME/.local/share/bash-completion/*; do +for f in $HOME/.local/share/bash-completion/* +do . "$f" done -GPG_TTY="$(tty)" export GPG_TTY; +GPG_TTY="$(tty)" +export GPG_TTY eval "$(starship init bash)" diff --git a/.profile b/.profile index 6ebf84e..bc07a20 100644 --- a/.profile +++ b/.profile @@ -1,37 +1,61 @@ #!/usr/bin/env sh -if [ -z "${XDG_RUNTIME_DIR}" ]; then - XDG_RUNTIME_DIR="/tmp/${UID}-runtime-dir"; export XDG_RUNTIME_DIR; - if [ ! -d "${XDG_RUNTIME_DIR}" ]; then - mkdir "${XDG_RUNTIME_DIR}"; - chmod 0700 "${XDG_RUNTIME_DIR}"; +if [ -z "${XDG_RUNTIME_DIR}" ] +then + XDG_RUNTIME_DIR="/tmp/$UID-runtime-dir" + export XDG_RUNTIME_DIR + if [ ! -d "$XDG_RUNTIME_DIR" ] + then + mkdir "$XDG_RUNTIME_DIR" + chmod 0700 "$XDG_RUNTIME_DIR" fi fi -DENO_INSTALL="$HOME/.deno"; export DENO_INSTALL; +DENO_INSTALL="$HOME/.deno" # https://github.com/denoland/deno/pull/15974 -DENO_NO_UPDATE_CHECK="yes" export DENO_NO_UPDATE_CHECK; -DENO_NO_PROMPT="yes" export DENO_NO_PROMPT; +DENO_NO_UPDATE_CHECK="yes" +DENO_NO_PROMPT="yes" # https://learn.microsoft.com/en-us/dotnet/core/tools/telemetry -DOTNET_CLI_TELEMETRY_OPTOUT="true" export DOTNET_CLI_TELEMETRY_OPTOUT; +DOTNET_CLI_TELEMETRY_OPTOUT="true" # https://nextjs.org/telemetry -NEXT_TELEMETRY_DEBUG=1 export NEXT_TELEMETRY_DEBUG; +NEXT_TELEMETRY_DEBUG=1 + +BUN_INSTALL="$HOME/.bun" +GOPROXY="direct" +EDITOR="$(which nvim 2> /dev/null || which vim 2> /dev/null || which nano 2> /dev/null || which vi 2> /dev/null)" +GTK_THEME="Dracula" +TERMINAL="st" -BUN_INSTALL="/home/luca/.bun"; -GOPROXY="direct" export GOPROXY; -EDITOR="$(which nvim || which vim || which nano || which vi)"; export EDITOR; +export DENO_INSTALL +export DENO_NO_UPDATE_CHECK +export DENO_NO_PROMPT +export DOTNET_CLI_TELEMETRY_OPTOUT +export NEXT_TELEMETRY_DEBUG -BAT="$(which bat || which batcat)" +export GOPROXY +export EDITOR +export GTK_THEME +export TERMINAL + +BAT="$(which bat 2> /dev/null || which batcat 2> /dev/null)" if [ -n $BAT ] then - MANPAGER="sh -c 'col -bx | $BAT -l man -p'"; export MANPAGER; + MANPAGER="sh -c 'col -bx | $BAT -l man -p'" + export MANPAGER fi # Sway specific -SDL_VIDEODRIVER=wayland; export SDL_VIDEODRIVER; -_JAVA_AWT_WM_NONREPARENTING=1; export _JAVA_AWT_WM_NONREPARENTING; -QT_QPA_PLATFORM=wayland; export QT_QPA_PLATFORM; -XDG_CURRENT_DESKTOP=sway; export XDG_CURRENT_DESKTOP; -XDG_SESSION_DESKTOP=sway; export XDG_SESSION_DESKTOP; +SDL_VIDEODRIVER="wayland" +_JAVA_AWT_WM_NONREPARENTING=1 +QT_QPA_PLATFORM="wayland" +XDG_CURRENT_DESKTOP="sway" +XDG_SESSION_DESKTOP="sway" + +export SDL_VIDEODRIVER +export _JAVA_AWT_WM_NONREPARENTING +export QT_QPA_PLATFORM +export XDG_CURRENT_DESKTOP +export XDG_SESSION_DESKTOP -PATH="$HOME/go/bin:$DENO_INSTALL/bin:$BUN_INSTALL/bin:$HOME/.cargo/bin:$HOME/.local/bin:$HOME/.luarocks/bin:$PATH"; +PATH="$HOME/go/bin:$DENO_INSTALL/bin:$BUN_INSTALL/bin:$HOME/.cargo/bin:$HOME/.local/bin:$HOME/.luarocks/bin:$PATH" +export PATH diff --git a/bootstrap.sh b/bootstrap.sh index df2d339..7127570 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -19,17 +19,19 @@ doIt() { -avh --no-perms ./ ~/ } -if [ "$1" = "--force" -o "$1" = "-f" ]; then +if [ "$1" = "--force" ] || [ "$1" = "-f" ] +then doIt; else - printf "This may overwrite existing files in your home directory. Are you sure? (y/n) "; - read REPLY; - echo ""; - if [ "$REPLY" = "y" -o "$REPLY" = "Y" ]; then - doIt; - else exit 1; - fi; -fi; + printf "This may overwrite existing files in your home directory. Are you sure? (y/n) " + read REPLY + echo "" + if [ "$REPLY" = "y" -o "$REPLY" = "Y" ] + then + doIt + else exit 1 + fi +fi -unset doIt; +unset doIt -- cgit v1.2.3