Compare commits

..

13 Commits

4 changed files with 28 additions and 34 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.disabled

View File

@ -7,5 +7,4 @@ This repository contains setup or config files for generic CLI applications, suc
* `vimrc` is ViM config script and should be installed at `~/.vimrc`. * `vimrc` is ViM config script and should be installed at `~/.vimrc`.
* `tmux.conf` is tmux config file and should be installed at `~/.tmux.conf`. * `tmux.conf` is tmux config file and should be installed at `~/.tmux.conf`.
#### Installation #### Installation
* `install.sh` script copies above files to their respective destinations; * `install.sh` script copies above files to their respective destinations.
* can be called with an argument, which will be used as user name (to be used with setup scripts).

12
bashrc
View File

@ -1,3 +1,4 @@
#!/usr/bin/env bash
# ~/.bashrc # ~/.bashrc
# byMasterKTO # byMasterKTO
@ -59,7 +60,7 @@ if [[ $system == "Linux" ]]; then
# Arch family: light blue # Arch family: light blue
Arch | ManjaroLinux | Manjaro-ARM) COLOR=$C_BOLD$C_ARCH;; Arch | ManjaroLinux | Manjaro-ARM) COLOR=$C_BOLD$C_ARCH;;
# Debian family: orange # Debian family: orange
Debian | Ubuntu | Linuxmint | Neon | Raspbian) COLOR=$C_BOLD$C_DEB;; Debian | Ubuntu | Linuxmint | Neon | Raspbian | PureOS) COLOR=$C_BOLD$C_DEB;;
# RedHat family: blue # RedHat family: blue
Fedora) COLOR=$C_BOLD$C_RH;; Fedora) COLOR=$C_BOLD$C_RH;;
# SUSE family: green # SUSE family: green
@ -88,7 +89,7 @@ if [[ $system == "Linux" ]]; then
fi fi
fi fi
# hostname # hostname TODO could we not get rid of hostname command (not always installed)?
# if hostname has 5 parts then host=.secondpart # if hostname has 5 parts then host=.secondpart
if [[ $(hostname | grep -o "\." | wc -l) -eq 4 ]]; then if [[ $(hostname | grep -o "\." | wc -l) -eq 4 ]]; then
host='.'$(hostname | cut -f 2 -d '.') host='.'$(hostname | cut -f 2 -d '.')
@ -145,7 +146,7 @@ unset TMUX
alias touchpad='xinput set-prop 12 "Device Enabled" 1' alias touchpad='xinput set-prop 12 "Device Enabled" 1'
# Set VNC aliases # Set VNC aliases
X_user=$(who | grep \(: | cut -d " " -f1) X_user=$(who | grep -m1 \(: | cut -d " " -f1)
X_display=$(who | grep \(: | cut -d ":" -f2 | cut -b 1) X_display=$(who | grep \(: | cut -d ":" -f2 | cut -b 1)
if id -u gdm > /dev/null 2>&1; then if id -u gdm > /dev/null 2>&1; then
X_gdm_id=$(id -u gdm) X_gdm_id=$(id -u gdm)
@ -160,7 +161,6 @@ alias vnc-gdm="sudo x11vnc -auth /run/user/$X_gdm_id/gdm/Xauthority -localhost -
alias vnc-lightdm='sudo x11vnc -auth /var/run/lightdm/root/:0 -localhost -once -nopw -display :0' alias vnc-lightdm='sudo x11vnc -auth /var/run/lightdm/root/:0 -localhost -once -nopw -display :0'
# load any additional configuration # load any additional configuration
for f in ~/.bashrc-*; do for f in ~/.bashrc.d/bashrc-*; do
[ -e "$f" ] && . ~/.bashrc-* [ -e "$f" ] && source $f
break
done done

28
install.sh Normal file → Executable file
View File

@ -1,14 +1,19 @@
#!/bin/bash #!/usr/bin/env bash
run_directory=$(dirname "$0") run_directory=$(dirname $(readlink -f "$0"))
user=$(whoami)
if [ -z "$1" ]; then if [ -f $run_directory/.disabled ]; then
user=$(whoami) echo "Installation is disabled. Exiting..."
if [[ $user != 'root' ]]; then exit 0
fi
if [[ $user != 'root' ]]; then
echo "Copying rcs to home directory..." echo "Copying rcs to home directory..."
cp $run_directory/bashrc /home/$user/.bashrc cp $run_directory/bashrc /home/$user/.bashrc
cp $run_directory/vimrc /home/$user/.vimrc cp $run_directory/vimrc /home/$user/.vimrc
cp $run_directory/tmux.conf /home/$user/.tmux.conf cp $run_directory/tmux.conf /home/$user/.tmux.conf
if ! command -v sudo &> /dev/null; then if ! command -v sudo &> /dev/null; then
echo "Could not copy to root directory: sudo was not found." echo "Could not copy to root directory: sudo was not found."
else else
@ -17,19 +22,8 @@ if [ -z "$1" ]; then
sudo cp $run_directory/vimrc /root/.vimrc sudo cp $run_directory/vimrc /root/.vimrc
sudo cp $run_directory/tmux.conf /root/.tmux.conf sudo cp $run_directory/tmux.conf /root/.tmux.conf
fi fi
else
echo "Copying rcs to root directory..."
cp $run_directory/bashrc /root/.bashrc
cp $run_directory/vimrc /root/.vimrc
cp $run_directory/tmux.conf /root/.tmux.conf
fi
else # running from a setup script, assuming as root else
user=$1
echo "Copying rcs to home directory..."
sudo -H -u $user cp $run_directory/bashrc /home/$user/.bashrc
sudo -H -u $user cp $run_directory/vimrc /home/$user/.vimrc
sudo -H -u $user cp $run_directory/tmux.conf /home/$user/.tmux.conf
echo "Copying rcs to root directory..." echo "Copying rcs to root directory..."
cp $run_directory/bashrc /root/.bashrc cp $run_directory/bashrc /root/.bashrc
cp $run_directory/vimrc /root/.vimrc cp $run_directory/vimrc /root/.vimrc