Skip to content

Commit

Permalink
Merge pull request #47 from MANICX100/main
Browse files Browse the repository at this point in the history
Fix interactive shell, add nala and rg
  • Loading branch information
ChrisTitusTech authored Jun 29, 2024
2 parents 2b536c8 + ef4ae1e commit 28de371
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 18 deletions.
17 changes: 15 additions & 2 deletions .bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,15 @@ fi
export CLICOLOR=1
export LS_COLORS='no=00:fi=00:di=00;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:*.xml=00;31:'
#export GREP_OPTIONS='--color=auto' #deprecated
alias grep="/usr/bin/grep $GREP_OPTIONS"

# Check if ripgrep is installed
if command -v rg &> /dev/null; then
# Alias grep to rg if ripgrep is installed
alias grep='rg'
else
# Alias grep to /usr/bin/grep with GREP_OPTIONS if ripgrep is not installed
alias grep="/usr/bin/grep $GREP_OPTIONS"
fi
unset GREP_OPTIONS

# Color for manpages in less makes manpages a little easier to read
Expand Down Expand Up @@ -573,7 +581,12 @@ function hb {
#######################################################

alias hug="hugo server -F --bind=10.0.0.97 --baseURL=http://10.0.0.97"
bind '"\C-f":"zi\n"'

# Check if the shell is interactive
if [[ $- == *i* ]]; then
# Bind Ctrl+f to insert 'zi' followed by a newline
bind '"\C-f":"zi\n"'
fi

export PATH=$PATH:"$HOME/.local/bin:$HOME/.cargo/bin:/var/lib/flatpak/exports/bin:/.local/share/flatpak/exports/bin"

Expand Down
43 changes: 27 additions & 16 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,32 @@ fi
cd "$LINUXTOOLBOXDIR/mybash" || exit

command_exists() {
command -v $1 >/dev/null 2>&1
command -v "$1" >/dev/null 2>&1
}

checkEnv() {
## Check for requirements.
REQUIREMENTS='curl groups sudo'
if ! command_exists ${REQUIREMENTS}; then
echo -e "${RED}To run me, you need: ${REQUIREMENTS}${RC}"
exit 1
fi
for req in ${REQUIREMENTS}; do
if ! command_exists ${req}; then
echo -e "${RED}To run me, you need: ${REQUIREMENTS}${RC}"
exit 1
fi
done

## Check Package Handeler
PACKAGEMANAGER='apt yum dnf pacman zypper emerge xbps-install nix-env'
PACKAGEMANAGER='nala apt yum dnf pacman zypper emerge xbps-install nix-env'

for pgm in ${PACKAGEMANAGER}; do
if command_exists ${pgm}; then
PACKAGER=${pgm}
echo -e "Using ${pgm}"
break
fi
done

if [ -z "${PACKAGER}" ]; then
echo -e "${RED}Can't find a supported package manager"
echo -e "${RED}Can't find a supported package manager${RC}"
exit 1
fi

Expand All @@ -74,23 +78,27 @@ checkEnv() {
## Check SuperUser Group
SUPERUSERGROUP='wheel sudo root'
for sug in ${SUPERUSERGROUP}; do
if groups | grep ${sug}; then
if groups | (command_exists rg && rg -q ${sug} || grep -q ${sug}); then
SUGROUP=${sug}
echo -e "Super user group ${SUGROUP}"
break
fi
done

## Check if member of the sudo group.
if ! groups | grep ${SUGROUP} >/dev/null; then
echo -e "${RED}You need to be a member of the sudo group to run me!"
if ! groups | (command_exists rg && rg -q ${SUGROUP} || grep -q ${SUGROUP}); then
echo -e "${RED}You need to be a member of the sudo group to run me!${RC}"
exit 1
fi

}

installDepend() {
## Check for dependencies.
DEPENDENCIES='bash bash-completion tar neovim bat tree multitail fastfetch'
DEPENDENCIES='bash bash-completion tar bat tree multitail fastfetch'
if ! command_exists nvim; then
DEPENDENCIES="${DEPENDENCIES} neovim"
fi

echo -e "${YELLOW}Installing dependencies...${RC}"
if [[ $PACKAGER == "pacman" ]]; then
if ! command_exists yay && ! command_exists paru; then
Expand All @@ -110,12 +118,14 @@ installDepend() {
exit 1
fi
${AUR_HELPER} --noconfirm -S ${DEPENDENCIES}
elif [[ $PACKAGER == "nala" ]]; then
${SUDO_CMD} ${PACKAGER} install -y ${DEPENDENCIES}
elif [[ $PACKAGER == "emerge" ]]; then
${PACKAGER} -v app-shells/bash app-shells/bash-completion app-arch/tar app-editors/neovim sys-apps/bat app-text/tree app-text/multitail app-misc/fastfetch
${SUDO_CMD} ${PACKAGER} -v app-shells/bash app-shells/bash-completion app-arch/tar app-editors/neovim sys-apps/bat app-text/tree app-text/multitail app-misc/fastfetch
elif [[ $PACKAGER == "xbps-install" ]]; then
${PACKAGER} -v ${DEPENDENCIES}
${SUDO_CMD} ${PACKAGER} -v ${DEPENDENCIES}
elif [[ $PACKAGER == "nix-env" ]]; then
${PACKAGER} -iA nixos.bash nixos.bash-completion nixos.gnutar nixos.neovim nixos.bat nixos.tree nixos.multitail nixos.fastfetch
${SUDO_CMD} ${PACKAGER} -iA nixos.bash nixos.bash-completion nixos.gnutar nixos.neovim nixos.bat nixos.tree nixos.multitail nixos.fastfetch
else
${SUDO_CMD} ${PACKAGER} install -yq ${DEPENDENCIES}
fi
Expand Down Expand Up @@ -205,7 +215,8 @@ installZoxide
install_additional_dependencies

if linkConfig; then
echo -e "${GREEN}Done!\nrestart your shell to see the changes.${RC}"
echo -e "${GREEN}Done!\nRestart your shell to see the changes.${RC}"
else
echo -e "${RED}Something went wrong!${RC}"
fi

0 comments on commit 28de371

Please sign in to comment.