~dvko/dotfiles

fca01a33543196eae7f974ef2810a44d40f3dbf6 — Danny van Kooten 2 months ago 3a8c4da
use POSIX shell for all install scripts
9 files changed, 13 insertions(+), 210 deletions(-)

M .config/fish/config.fish
M apt/install.sh
M apt/packages.txt
M archlinux/install.sh
D bash/bash_profile
D bash/bash_prompt
D bash/bashrc
D bash/install.sh
M install.sh
M .config/fish/config.fish => .config/fish/config.fish +0 -1
@@ 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

M apt/install.sh => apt/install.sh +1 -1
@@ 1,3 1,3 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

xargs sudo apt install < apt/packages.txt 

M apt/packages.txt => apt/packages.txt +2 -0
@@ 17,10 17,12 @@ playerctl
pulseaudio
screenfetch
sed
shellcheck
slurp
sway
swaybg
tar
tidy
tlp
vim
vim

M archlinux/install.sh => archlinux/install.sh +1 -1
@@ 1,3 1,3 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

sudo pacman -S - < archlinux/pkglist.txt 

D bash/bash_profile => bash/bash_profile +0 -58
@@ 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

D bash/bash_prompt => bash/bash_prompt +0 -122
@@ 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;

D bash/bashrc => bash/bashrc +0 -1
@@ 1,1 0,0 @@
[ -n "$PS1" ] && source ~/.bash_profile;

D bash/install.sh => bash/install.sh +0 -12
@@ 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;

M install.sh => install.sh +9 -14
@@ 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