Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
added some config/dotfile options
Browse files Browse the repository at this point in the history
  • Loading branch information
snwh committed Jun 14, 2018
1 parent edf8de0 commit 8436388
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 12 deletions.
10 changes: 8 additions & 2 deletions data/aliases.list → data/config/bash_aliases.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Bash Aliases
# custom ~/.bash_aliases

# fancy listing
# use color
alias ls="ls --color=auto"
alias dir="dir --color=auto"
alias grep="grep --color=auto"
alias dmesg='dmesg --color'

# extended listing
alias ll='ls -halF'
alias la='ls -A'
alias l='ls -CF'
Expand Down
50 changes: 50 additions & 0 deletions data/config/bashrc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# custom ~/.bashrc

# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac

# don't put duplicate lines or lines starting with space in the history.
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=20000
HISTFILESIZE=20000

# Alias definitions.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

# keep environment pollution down
unset safe_term match_lhs

# use colours in the prompt
[[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
[[ -z ${match_lhs} ]] \
&& type -P dircolors >/dev/null \
&& match_lhs=$(dircolors --print-database)

if [[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] ; then

if type -P dircolors >/dev/null ; then
if [[ -f ~/.dir_colors ]] ; then
eval $(dircolors -b ~/.dir_colors)
elif [[ -f /etc/DIR_COLORS ]] ; then
eval $(dircolors -b /etc/DIR_COLORS)
fi
fi

PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$([[ \$? != 0 ]] && echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")\\$\[\033[00m\] "

else

PS1="\u@\h \w \$([[ \$? != 0 ]] && echo \":( \")\$ "

fi
19 changes: 19 additions & 0 deletions data/config/profile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# custom ~/.profile

# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi

# include .local/bin
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi

# include .bin
if [ -d "$HOME/.bin" ] ; then
PATH="$HOME/.bin:$PATH"
fi
64 changes: 54 additions & 10 deletions functions/system_configure
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Automatically set preferred gsettings keys as outlined in the 'gsettings.list' file
# 'gsettings' can be obtained by executing "dconf watch /" and then manually changing settings
function set_preferences {
function gsettings_config {
echo_message info "Setting preferred application-specific & desktop settings..."
# Variables
LIST=$(dirname "$0")'/data/gsettings.list'
Expand All @@ -16,19 +16,19 @@ function set_preferences {
system_configure
}

# Set preferred bash aliased by copying the 'aliases.list' file to ~/.bash_aliases
function set_bash_aliases {
# Set preferred bash aliased by copying the 'bash_aliases.in' file to ~/.bash_aliases
function write_bash_aliases {
# Check list
LIST=$(dirname "$0")'/data/aliases.list'
INPUT=$(dirname "$0")'/data/config/bash_aliases.in'
# Draw window
if (eval `resize` && whiptail \
--title "Preferred Bash Aliases" \
--yesno "Current list of preferred bash aliases: \n\n$(while read LINE; do echo " "$LINE; done < $LIST) \n\nProceed?" \
--yesno "Current list of preferred bash aliases: \n\n$(while read LINE; do echo " "$LINE; done < $INPUT) \n\nProceed?" \
$LINES $COLUMNS $(( $LINES - 12 )) \
--scrolltext) then
echo_message info "Setting bash aliases..."
# simply copy the list file to the aliases file
cp $LIST ~/.bash_aliases
cp $INPUT ~/.bash_aliases
echo_message success "Bash aliases set successfully."
whiptail --title "Finished" --msgbox "Bash aliases set successfully." 8 56
system_configure
Expand All @@ -37,6 +37,48 @@ function set_bash_aliases {
fi
}

# Configure environment variables by copying the 'profile.in' file to ~/.profile
function set_env_variables {
# Check list
INPUT=$(dirname "$0")'/data/config/profile.in'
# Draw window
if (eval `resize` && whiptail \
--title "Configure Environment Variables" \
--yesno "Custom config file contains the following: \n\n$(while read LINE; do echo " "$LINE; done < $INPUT) \n\nOverwrite existing config?" \
$LINES $COLUMNS $(( $LINES - 12 )) \
--scrolltext) then
echo_message info "Overwriting ~/.profile..."
# simply copy the list file to the aliases file
cp $INPUT ~/.profile
echo_message success "Environment variables successfully configured."
whiptail --title "Finished" --msgbox "Environment variables successfully configured." 8 56
system_configure
else
system_configure
fi
}

# Configure bash profile by copying the 'bashrc.in' file to ~/.bashrc
function write_bash_config {
# Check list
INPUT=$(dirname "$0")'/data/config/bashrc.in'
# Draw window
if (eval `resize` && whiptail \
--title "Configure Bash" \
--yesno "Custom config file contains the following: \n\n$(while read LINE; do echo " "$LINE; done < $INPUT) \n\nOverwrite existing config?" \
$LINES $COLUMNS $(( $LINES - 12 )) \
--scrolltext) then
echo_message info "Overwriting ~/.bashrc..."
# simply copy the list file to the aliases file
cp $INPUT ~/.bashrc
echo_message success "Bash successfully configured."
whiptail --title "Finished" --msgbox "Bash successfully configured." 8 56
system_configure
else
system_configure
fi
}

# Disable apport crash dialogs
function disable_crash_dialogs {
# Check if apport is aleady disabled.
Expand Down Expand Up @@ -84,10 +126,12 @@ function system_configure {
--menu "\nWhat would you like to do?" \
--cancel-button "Go Back" \
$LINES $COLUMNS $(( $LINES - 12 )) \
'set_preferences' 'Set preferred application-specific & desktop settings' \
'set_bash_aliases' 'Set preferred bash aliases' \
'hide_snap_folder' 'Hide the snap folder in user home' \
'disable_crash_dialogs' 'Disable Apport crash dialogs' \
'disable_crash_dialogs' 'Disable error report dialogs (apport)' \
'gsettings_config' 'Set preferred application & desktop settings' \
'hide_snap_folder' 'Hide the snap folder in user home' \
'set_env_variables' 'Configure environment variables' \
'write_bash_aliases' 'Set custom Bash aliases' \
'write_bash_config' 'Set custom Bash preferences' \
3>&1 1>&2 2>&3)
# check exit status
if [ $? = 0 ]; then
Expand Down

0 comments on commit 8436388

Please sign in to comment.