view setup.sh @ 154:99a7805cb924

Fix Ubuntu's alias shortcomings
author IBBoard <dev@ibboard.co.uk>
date Tue, 30 May 2023 15:20:24 +0100
parents 3448a8c33716
children
line wrap: on
line source

#! /bin/bash

SCRIPTPATH=`dirname $(readlink -f $0)`
create_symlink() {
	SOURCEFILE=$1
	if [ "${SOURCEFILE:0:1}" != "/" ]; then
		SOURCEFILE=$SCRIPTPATH/$1
	fi
	parent_dir=$(dirname "$2")
	if [ ! -d "$parent_dir" ]; then
		mkdir -p "$parent_dir"
	fi
	if [ ! -e $2 ]; then
		ln -s $SOURCEFILE $2
	elif [ "$(readlink $2)" != "$SCRIPTPATH/$1" ]; then
		echo "Unable to link $1 config - $2 already existed" >&2
	fi
	#Else it already existed but was correct
}

add_content() {
	if [ -e $2 ]; then
		grep -F -q "$1" $2 2>&1
	else
		false
	fi
	if [ $? -ne 0 ]; then
		echo "$1" >> $2
	fi
}

# Remove bashrc file - some skeleton home dirs include it
[ -f ~/.bashrc -a ! -h ~/.bashrc ] && rm ~/.bashrc

create_symlink tmux.conf ~/.tmux.conf
create_symlink hgrc ~/.hgrc
create_symlink prompt.py ~/.hg-prompt.py
create_symlink bashrc ~/.bashrc
create_symlink profile ~/.profile
create_symlink inputrc ~/.inputrc
create_symlink /usr/lib/python*/site-packages/hgext/hgview.py ~/.hgview.py
create_symlink gitconfig ~/.gitconfig
create_symlink gitignore ~/.gitignore
create_symlink dircolors ~/.dir_colors
create_symlink nanorc ~/.nanorc
create_symlink nanorc.d ~/.nanorc.d
create_symlink XCompose ~/.XCompose
create_symlink 10-noto-emoji.conf ~/.config/fontconfig/conf.d/10-noto-emoji.conf
create_symlink mime-extra.xml ~/.local/share/mime/packages/IBBoard-extra.xml
update-mime-database ~/.local/share/mime/
mkdir -p ~/.ssh
add_content "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC2c3IUHY02FAJotQKs3x+uGZ+5XpuKbWUENevjTOF1bAGwGqKNSSg5SlsL5C9aHcu6O/eBKWJNpvUa0vcXXP18ddoILq1DvZfQHDylrweGbaRviSCpRZvSKiNREQd+yAQPwGnsfkpQe5RxXjRTsk7B0VKP2LFL5seDuQfQxtGc6AgjF0TMpBoKD3UkUlfqRX7Q0tQwfTgXTNxYyQOgG61bWeUsz0XSZelF1MHsXxLwUUFuZAigwiv9YUlBSAAEwWySyN8RdsJadunKYHbxr9cJfj4T5soKVeDi2n94AScFuokAyDf3MFvJ1PYZ0p4rFzNF2zrOK3rqvA3aGg4Bi+wx ssh@ibboard.co.uk" ~/.ssh/authorized_keys