Skip to content

Instantly share code, notes, and snippets.

@appins
Last active December 19, 2019 22:21
Show Gist options
  • Save appins/ff9ee26225d78fa04136b8613fa933f4 to your computer and use it in GitHub Desktop.
Save appins/ff9ee26225d78fa04136b8613fa933f4 to your computer and use it in GitHub Desktop.
A nice bash_profile script
#!/bin/bash
# Alex Anderson (c) 2016-2019, public domain
clear
#source ~/.bashrc
# Go to home dir
#cd ~
# Get name if first time use
if [ ! -e ~/.bash_profile_name ]
then
echo -e "No file found at ~/.bash_profile_name \n"
echo "What is your name?"
echo -n "Enter it here: "
read name
echo $name > ~/.bash_profile_name
clear
echo $name "has been stored to ~/.bash_profile_name"
read -p "Press enter to contine..." I
bash ~/.bash_profile
else
# Text greeting
echo -e "\e[37m$(date +%H:%M\ %b\ %e)\e[0m \e[91m\e[2m@\e[0m \e[37m$(uname) $(uname -r)\e[0m"
echo -e "\e[1mWelcome back, \e[38;5;$((($RANDOM % 256) + 1))m$(cat ~/.bash_profile_name)!\e[0m"
echo ""
echo -e "\e[37mThe system has been \e[0m$(uptime -p)"
echo ""
fi
# Aliases
alias cd..="cd .."
alias sbp="source ~/.bash_profile"
# Uncomment to use nvim instead of vim
# Normal vim can still be accessed with \vim
#alias vim="nvim"
# Just for fun
alias greet='echo -e "\e[1mWelcome back, \e[38;5;$((($RANDOM % 256) + 1))m$(cat ~/.bash_profile_name)!\e[0m"'
# My favorite PS1 (Only works on bash)
export PS1="\[\033[38;5;6m\][\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]\[\033[38;5;3m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]\[\033[38;5;4m\]@\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]\[\033[38;5;2m\]\h\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]\[\033[38;5;6m\]]\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput bold)\]\[$(tput sgr0)\]\[\033[38;5;1m\]\u\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput bold)\]\[$(tput sgr0)\]\[\033[38;5;4m\]\\$\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]"
# Function to run a command forever, try forever echo hello
function forever(){
while true; do "$@"; done
}
# Use vim bash mode & set bashes editor to vim
#set -o vi
export EDITOR='vim'
# Add this somewhere in the file
bash ~/.bash_profile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment