From fca01a33543196eae7f974ef2810a44d40f3dbf6 Mon Sep 17 00:00:00 2001 From: Danny van Kooten Date: Mon, 2 Jan 2023 16:32:55 +0100 Subject: [PATCH] use POSIX shell for all install scripts --- .config/fish/config.fish | 1 - apt/install.sh | 2 +- apt/packages.txt | 2 + archlinux/install.sh | 2 +- bash/bash_profile | 58 ------------------- bash/bash_prompt | 122 --------------------------------------- bash/bashrc | 1 - bash/install.sh | 12 ---- install.sh | 23 +++----- 9 files changed, 13 insertions(+), 210 deletions(-) delete mode 100755 bash/bash_profile delete mode 100644 bash/bash_prompt delete mode 100644 bash/bashrc delete mode 100755 bash/install.sh diff --git a/.config/fish/config.fish b/.config/fish/config.fish index 256c318..e21da8d 100644 --- a/.config/fish/config.fish +++ b/.config/fish/config.fish @@ -1,5 +1,4 @@ if status is-interactive - set -gx EDITOR vim set -gx _JAVA_AWT_WM_NONREPARENTING 1 set -gx MOZ_ENABLE_WAYLAND 1 diff --git a/apt/install.sh b/apt/install.sh index dc53a35..613fb1c 100755 --- a/apt/install.sh +++ b/apt/install.sh @@ -1,3 +1,3 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh xargs sudo apt install < apt/packages.txt diff --git a/apt/packages.txt b/apt/packages.txt index 66a8d93..4ef5dc8 100644 --- a/apt/packages.txt +++ b/apt/packages.txt @@ -17,10 +17,12 @@ playerctl pulseaudio screenfetch sed +shellcheck slurp sway swaybg tar +tidy tlp vim vim diff --git a/archlinux/install.sh b/archlinux/install.sh index 1a7abff..3dff420 100755 --- a/archlinux/install.sh +++ b/archlinux/install.sh @@ -1,3 +1,3 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh sudo pacman -S - < archlinux/pkglist.txt diff --git a/bash/bash_profile b/bash/bash_profile deleted file mode 100755 index 48ac8a2..0000000 --- a/bash/bash_profile +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env bash - -if [[ -z "$DOTFILES_DIR" ]]; then - echo "DOTFILES_DIR variable is not set. Set it manually or use bootstrap.sh to install these dotfiles." - exit 1; -fi; - -alias grep='grep --color=auto' -alias diff='diff --color=auto' -alias dmesg="dmesg --color=always" -alias radio10="mplayer http://stream.radio10.nl/radio10" - - -# Environment vars -PATH="$PATH:$DOTFILES_DIR/bin" -PATH="$PATH:$HOME/.local/bin" -PATH="$PATH:$HOME/.cargo/bin" - -if [[ -d "$HOME/.gem/ruby/2.7.0/bin" ]]; then - PATH="$PATH:$HOME/.gem/ruby/2.7.0/bin" -fi; -if [[ -d "$HOME/.gem/ruby/3.0.0/bin" ]]; then - PATH="$PATH:$HOME/.gem/ruby/3.0.0/bin" -fi; - -# Pretty bash prompt -source "$DOTFILES_DIR/bash/bash_prompt" - -# Case-insensitive globbing (used in pathname expansion) -shopt -s nocaseglob; - -# Append to the Bash history file, rather than overwriting it -shopt -s histappend; - -# Expand variables on TAB -shopt -s direxpand - -# Autocorrect typos in path names when using `cd` -shopt -s cdspell; - -# Enable some Bash 4 features when possible: -# * `autocd`, e.g. `**/qux` will enter `./foo/bar/baz/qux` -# * Recursive globbing, e.g. `echo **/*.txt` -for option in autocd globstar; do - shopt -s "$option" 2> /dev/null; -done; - -# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards -[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2- | tr ' ' '\n')" scp sftp ssh; - -# Source autojump - https://github.com/wting/autojump -[ -e "/etc/profile.d/autojump.bash" ] && source /etc/profile.d/autojump.bash - -# Fix for PHPStorm on Sway - export _JAVA_AWT_WM_NONREPARENTING=1 - -# Run weekly Pacman update check -pacmansyu \ No newline at end of file diff --git a/bash/bash_prompt b/bash/bash_prompt deleted file mode 100644 index 3ff63eb..0000000 --- a/bash/bash_prompt +++ /dev/null @@ -1,122 +0,0 @@ -#!/usr/bin/env bash - -# Shell prompt based on the Solarized Dark theme. -# Screenshot: http://i.imgur.com/EkEtphC.png -# Heavily inspired by @necolas’s prompt: https://github.com/necolas/dotfiles -# iTerm → Profiles → Text → use 13pt Monaco with 1.1 vertical spacing. - -if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then - export TERM='gnome-256color'; -elif infocmp xterm-256color >/dev/null 2>&1; then - export TERM='xterm-256color'; -fi; - -prompt_git() { - local s=''; - local branchName=''; - - # Check if the current directory is in a Git repository. - if [ $(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}") == '0' ]; then - - # check if the current directory is in .git before running git checks - if [ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == 'false' ]; then - - # Ensure the index is up to date. - git update-index --really-refresh -q &>/dev/null; - - # Check for uncommitted changes in the index. - if ! $(git diff --quiet --ignore-submodules --cached); then - s+='+'; - fi; - - # Check for unstaged changes. - if ! $(git diff-files --quiet --ignore-submodules --); then - s+='!'; - fi; - - # Check for untracked files. - if [ -n "$(git ls-files --others --exclude-standard)" ]; then - s+='?'; - fi; - - # Check for stashed files. - if $(git rev-parse --verify refs/stash &>/dev/null); then - s+='$'; - fi; - - fi; - - # Get the short symbolic ref. - # If HEAD isn’t a symbolic ref, get the short SHA for the latest commit - # Otherwise, just give up. - branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \ - git rev-parse --short HEAD 2> /dev/null || \ - echo '(unknown)')"; - - [ -n "${s}" ] && s=" [${s}]"; - - echo -e "${1}${branchName}${2}${s}"; - else - return; - fi; -} - -if tput setaf 1 &> /dev/null; then - tput sgr0; # reset colors - bold=$(tput bold); - reset=$(tput sgr0); - # Solarized colors, taken from http://git.io/solarized-colors. - black=$(tput setaf 0); - blue=$(tput setaf 33); - cyan=$(tput setaf 37); - green=$(tput setaf 64); - orange=$(tput setaf 166); - purple=$(tput setaf 125); - red=$(tput setaf 124); - violet=$(tput setaf 61); - white=$(tput setaf 15); - yellow=$(tput setaf 136); -else - bold=''; - reset="\e[0m"; - black="\e[1;30m"; - blue="\e[1;34m"; - cyan="\e[1;36m"; - green="\e[1;32m"; - orange="\e[1;33m"; - purple="\e[1;35m"; - red="\e[1;31m"; - violet="\e[1;35m"; - white="\e[1;37m"; - yellow="\e[1;33m"; -fi; - -# Highlight the user name when logged in as root. -if [[ "${USER}" == "root" ]]; then - userStyle="${red}"; -else - userStyle="${orange}"; -fi; - -# Highlight the hostname when connected via SSH. -if [[ "${SSH_TTY}" ]]; then - hostStyle="${bold}${red}"; -else - hostStyle="${yellow}"; -fi; - -# Set the terminal title and prompt. -PS1="\[\033]0;\W\007\]"; # working directory base name -PS1+="\[${bold}\]\n"; # newline -PS1+="\[${userStyle}\]\u"; # username -PS1+="\[${white}\] at "; -PS1+="\[${hostStyle}\]\h"; # host -PS1+="\[${white}\] in "; -PS1+="\[${green}\]\w"; # working directory full path -PS1+="\$(prompt_git \"\[${white}\] on \[${violet}\]\" \"\[${blue}\]\")"; # Git repository details -PS1+="\n"; -PS1+="\[${white}\]\$ \[${reset}\]"; # `$` (and reset color) -export PS1; - -PS2="\[${yellow}\]→ \[${reset}\]"; -export PS2; diff --git a/bash/bashrc b/bash/bashrc deleted file mode 100644 index 1257002..0000000 --- a/bash/bashrc +++ /dev/null @@ -1 +0,0 @@ -[ -n "$PS1" ] && source ~/.bash_profile; diff --git a/bash/install.sh b/bash/install.sh deleted file mode 100755 index 8a20c9c..0000000 --- a/bash/install.sh +++ /dev/null @@ -1,12 +0,0 @@ -#/usr/bin/env bash - -set -e - -# Put Bash config files into place -cp "bash/bashrc" $HOME/.bashrc - -# Add PWD to $HOME/.bash_profile as DOTFILES_DIR so we can use it to reference other files from this directory -echo -e "$(head -n 1 bash/bash_profile)\nDOTFILES_DIR=$PWD\n\n$(tail -n +2 bash/bash_profile)" > $HOME/.bash_profile - -# Source our new bash file -source $HOME/.bash_profile; diff --git a/install.sh b/install.sh index ac32ca5..4cd7663 100755 --- a/install.sh +++ b/install.sh @@ -1,7 +1,4 @@ -#!/usr/bin/env fish - -# Install bash configuration -#./bash/install.sh +#!/usr/bin/env sh # Copy vimrc cp .vimrc $HOME/.vimrc @@ -9,26 +6,24 @@ cp .vimrc $HOME/.vimrc # Copy git configuration cp .gitconfig $HOME/.gitconfig -cp -r .ssh $HOME/.ssh - # Copy other configuration files into ~/.config +cp -r .ssh $HOME/.ssh cp -r .config/* $HOME/.config/ - cp .editorconfig $HOME/.editorconfig -# Source new configuration -source $HOME/.config/fish/config.fish - # Install APT packages if on Debian/Ubuntu -if type -q apt +if command -v apt +then ./apt/install.sh -end +fi # Install Pacman packages if on Arch -if type -q pacman +if command -v pacman +then ./archlinux/install.sh -end +fi # Install fonts (nerd fonts + fontawesome) cp -r .fonts $HOME/.fonts fc-cache + -- 2.38.5