Compare commits

..

10 Commits

5 changed files with 134 additions and 75 deletions

View File

@@ -1,6 +1,13 @@
Git repo of my personal shell profile variables
## Installing
### Quick Install
```
curl https://gitlab.com/madumlao/madumlao-profile/-/raw/master/install.sh | bash
```
### Manual Install
Copy this directory somewhere in your home directory. The directory should be persistent, so probably keep this in your "projects" directory or somewhere similar. If in doubt, you can keep this under `.local/share/madumlao-profile`.
Next, run the `install.sh` script. It should backup your existing profile and replace it with symlinks to this version.

85
install-ubuntu.sh Executable file
View File

@@ -0,0 +1,85 @@
#!/bin/bash
# run by install.sh
APP_DIR="$(dirname "$0")"
echo "Run an apt update"
if sudo -l apt > /dev/null; then
sudo apt update
else
echo "Unable to run apt commands, please install manually"
fi
echo "Install git and friends"
if sudo -l apt > /dev/null; then
sudo apt install git
else
echo "Unable to autoinstall git and friends, please install manually"
fi
echo "Install zsh and friends"
if sudo -l apt > /dev/null; then
sudo apt install zsh command-not-found
else
echo "Unable to autoinstall zsh and friends, please install manually"
fi
echo "Install oh-my-zsh and plugins"
if ! [ -d "$HOME/.oh-my-zsh" ]; then
git clone https://github.com/ohmyzsh/ohmyzsh "$HOME/.oh-my-zsh"
fi
(
cd "$HOME/.oh-my-zsh/plugins"
git clone https://github.com/zsh-users/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting
)
echo "Changing default shell"
ZSH_PATH="$(which zsh)"
if [ -x "$ZSH_PATH" ]; then
if sudo -l chsh -s $ZSH_PATH $USER; then
sudo chsh -s $ZSH_PATH $USER
elif sudo -l usermod -s $ZSH_PATH $USER; then
sudo usermod -s $ZSH_PATH $USER
else
echo "Cannot change shell using sudo, trying password"
if ! chsh -s "$ZSH_PATH"; then
echo "Unable to change shell to $ZSH_PATH, please change shell manually"
fi
fi
else
echo "No zsh available"
fi
SKEL_DIR="$APP_DIR/skel"
BACK_DIR="$APP_DIR/backup"
echo "Backing up original profile under $BACK_DIR"
mkdir -pv "$BACK_DIR"
cd "$SKEL_DIR"
OLDIFS="$IFS"
IFS=$'\n'
for x in $(ls -a); do
[ "$x" = '.' ] || [ "$x" = '..' ] && continue;
[ "$x" = '.profile-local' ] || [ "$x" = '.profile-private' ] && continue;
[ -r "$HOME/$x" ] && echo -ne "Backup: " && mv -v "$HOME/$x" "$BACK_DIR"
echo -ne "Linking: " && ln -srv "$(pwd)/$x" "$HOME"
done
IFS="$OLDIFS"
echo "Install vim-nox and friends"
if sudo -l apt > /dev/null; then
sudo apt install vim-nox
else
echo "Unable to autoinstall vim-nox and friends, please install manually"
fi
mkdir -pv "$HOME/.vim/bundle"
git clone https://github.com/VundleVim/Vundle.vim "$HOME/.vim/bundle/Vundle.vim"
vim +PluginInstall +qall
echo "Set vim-nox as the default system editor"
VIM_PATH="$(which vim.nox)"
if [ -x "$VIM_PATH" ]; then
sudo update-alternatives --set editor "$VIM_PATH"
fi

View File

@@ -1,72 +1,35 @@
#!/bin/bash
if ! [ -t 0 ]; then
echo "exec from pipe"
DOWNLOAD_APP=y
APP_DIR="$HOME/.local/share/madumlao-profile"
else
DOWNLOAD_APP=
APP_DIR="$(dirname "$0")"
fi
if [ "$DOWNLOAD_APP" ]; then
echo "Downloading master copy"
PARENT_DIR="$(dirname "$APP_DIR")"
mkdir -pv "$PARENT_DIR"
if [ -x git ]; then
cd "$PARENT_DIR"
git clone https://gitlab.com/madumlao/madumlao-profile
else
curl -O https://gitlab.com/madumlao/madumlao-profile/-/archive/master/madumlao-profile-master.tar.gz
tar -zxf madumlao-profile-master.tar.gz -C "$PARENT_DIR"
fi
fi
echo "Set pwd to $APP_DIR"
cd "$APP_DIR"
APP_DIR="$(pwd)"
echo "Install zsh and friends"
if sudo -l apt; then
sudo apt install zsh command-not-found
if [ "$(uname)" == "Linux" ]; then
# TODO: add support for different distributions
./install-ubuntu.sh
elif [ "$(uname)" == "Darwin" ]; then
echo TODO: install-macos.sh
else
echo "Unable to autoinstall zsh and friends, please install manually"
fi
echo "Install oh-my-zsh and plugins"
if ! [ -d "$HOME/.oh-my-zsh" ]; then
git clone https://github.com/ohmyzsh/ohmyzsh "$HOME/.oh-my-zsh"
fi
(
cd "$HOME/.oh-my-zsh/plugins"
git clone https://github.com/zsh-users/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting
)
echo "Changing default shell"
ZSH_PATH="$(which zsh)"
if [ -x "$ZSH_PATH" ]; then
if sudo -l chsh -s $ZSH_PATH $USER; then
sudo chsh -s $ZSH_PATH $USER
elif sudo -l usermod -s $ZSH_PATH $USER; then
sudo usermod -s $ZSH_PATH $USER
else
echo "Cannot change shell using sudo, trying password"
if ! chsh -s "$ZSH_PATH"; then
echo "Unable to change shell to $ZSH_PATH, please change shell manually"
fi
fi
else
echo "No zsh available"
fi
SKEL_DIR="$APP_DIR/skel"
BACK_DIR="$APP_DIR/backup"
echo "Backing up original profile under $BACK_DIR"
mkdir -pv "$BACK_DIR"
cd "$SKEL_DIR"
OLDIFS="$IFS"
IFS=$'\n'
for x in $(ls -a); do
[ "$x" = '.' ] || [ "$x" = '..' ] && continue;
[ "$x" = '.profile-local' ] || [ "$x" = '.profile-private' ] && continue;
[ -r "$HOME/$x" ] && echo -ne "Backup: " && mv -v "$HOME/$x" "$BACK_DIR"
echo -ne "Linking: " && ln -srv "$(pwd)/$x" "$HOME"
done
IFS="$OLDIFS"
echo "Install vim-nox and friends"
if sudo -l apt; then
sudo apt install vim-nox git
else
echo "Unable to autoinstall vim-nox and friends, please install manually"
fi
mkdir -pv "$HOME/.vim/bundle"
git clone https://github.com/VundleVim/Vundle.vim "$HOME/.vim/bundle/Vundle.vim"
vim +PluginInstall +qall
echo "Set vim-nox as the default system editor"
VIM_PATH="$(which vim.nox)"
if [ -x "$VIM_PATH" ]; then
sudo update-alternatives --set editor "$VIM_PATH"
echo Unsupported environment, need to manual install
fi

View File

@@ -16,8 +16,8 @@ HISTCONTROL=ignoreboth
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
HISTSIZE=-1
HISTFILESIZE=-1
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.

View File

@@ -2,6 +2,7 @@
export TZ="Asia/Manila"
export PATH="/usr/local/bin:$PATH"
export PATH="$HOME/bin:$PATH"
export PATH="$HOME/.local/bin:$PATH"
export PATH="$HOME/.crypt/bin:$PATH"
# set your umask
@@ -58,7 +59,7 @@ if [ -z "$PHPENV_DISABLE" ] && [ -d "$PHPENV_ROOT/bin" ]; then
eval "$(phpenv init -)"
# php-build
export PHP_BUILD_CONFIGURE_OPTS="--with-libdir=lib --with-pear --with-ldap --with-ldap-sasl --with-mhash --with-mysql-sock=/run/mysqld/mysqld.sock"
export PHP_BUILD_CONFIGURE_OPTS="--with-libdir=lib --with-pear --with-ldap --with-ldap-sasl --with-mhash --with-sodium --with-gmp --with-mysql-sock=/run/mysqld/mysqld.sock"
export PHP_BUILD_KEEP_OBJECT_FILES=y
fi
@@ -76,11 +77,11 @@ if [ -z "$JENV_DISABLE" ] && [ -d "$JENV_ROOT/bin" ]; then
eval "$(jenv init -)"
fi
# nenv
NENV_ROOT="${NENV_ROOT:-${HOME}/.nenv}"
if [ -z "$NENV_DISABLE" ] && [ -d "$NENV_ROOT/bin" ]; then
export PATH="$HOME/.nenv/bin:$PATH"
eval "$(nenv init -)"
# nodenv
NODENV_ROOT="${NODENV_ROOT:-$HOME/.nodenv}"
if [ -z "$NODENV_DISABLE" ] && [ -d "$NODENV_ROOT/bin" ]; then
export PATH="$HOME/.nodenv/bin:$PATH"
eval "$(nodenv init -)"
fi
# pyenv
@@ -92,7 +93,7 @@ if [ -z "$PYENV_DISABLE" ] && [ -d "$PYENV_ROOT/bin" ]; then
if [ "$PYENV_MAJOR_VERSION" -gt 1 ]; then
eval "$(pyenv init --path)"
fi
eval "$(pyenv init -|grep -v '^echo')"
eval "$(pyenv init -)"
fi
# perl
@@ -101,3 +102,6 @@ export PERL5LIB="/home/madumlao/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; expor
export PERL_LOCAL_LIB_ROOT="/home/madumlao/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
export PERL_MB_OPT="--install_base \"/home/madumlao/perl5\""; export PERL_MB_OPT;
export PERL_MM_OPT="INSTALL_BASE=/home/madumlao/perl5"; export PERL_MM_OPT;
# aliases
alias less='less -i -r'