NOTE, lines or sections preceded by "#" are comments and nothing to the right will work.
COPY STARTING HERE:
################################## john's .bashrc 27 Jul 2023 ###################
# the .bashrc file sets useful user configurations related to:
# Path, Prompt, Permissions, History, Editor, Alias, Shell options and Functions
# http://johnmeister.com/linux/bashrc-basic.html
###################################################################################
# PATH:
#
export PATH=$PATH:~/bin:~:.
#
## from /etc/login.defs: ## *REQUIRED* The default PATH settings, for superuser and normal users.
## NO NEED TO ADD THE PATHS FOUND in ENV_PATH which are: PATH=/usr/local/bin:/usr/bin:/bin
## ENV_SUPATH PATH=/sbin:/bin:/usr/sbin:/usr/bin #
# FOR BASIC USER: NOTE: CHECK THE "tilde" (~) it does NOT always copy over, replace it with the path!
# recommended only for more ADVANCED users: (NOTE THE TILDE - it might not copy correctly!)
# export PATH=$PATH:~/bin:/sbin:/usr/sbin:/usr/local/sbin:~:.
#======================================================================================
# PROMPT:
#
export PS1="
------------------------------------------------
$(whoami)@`hostname` [\$PWD]
------------------------------------------------
--> "
#
#======================================================================================
# PERMISSIONS:
#
umask 022
#
# note: umask 022 sets new files: 644 & dirs: 755
#======================================================================================
# HISTORY: (suggest replacing the tilda (~) with the full path!)
#
if [ ! -d ~/.History ]
# note: tests for directory, if not, then...
then
mkdir ~/.History
echo "history directory made"
fi
#
#======================================================================================
# note: creates a history file for each instance e.g.: 2017_10_Oct_01_1515.history
#======================================================================================
#
HISTFILE="~/.History/`date '+%Y_%m_%b_%d_%H:%M'.history`" ; export HISTFILE
HISTSIZE=2048; export HISTSIZE # default is usually 1024, acceptable
#
#======================================================================================
# note: on MacOSx, block appendable history: SHELL_SESSION_HISTORY=0
#======================================================================================
# EDITOR:
#
set -o vi
#
#======================================================================================
# note: using set -o vi allows recall of commands via vi commands and inline editing
#======================================================================================
# note: verify location by typing: which vi (often systems will link /bin to /usr/bin)
# not resolving the path to commands will work ok. NOT all systems have VIM
# see: http://johnmeister.com/linux/FileSystems/Linux-bashrc-vim-differences.jpg
#======================================================================================
#
EDITOR=vi; export EDITOR
VISUAL=vi; export VISUAL
#
#======================================================================================
# note optional aliases - use to create simple commands or alternate OS commands
#======================================================================================
# ALIAS:
#
alias l="ls -al" ; alias ll="ls -l" # NOTE: you can separate commands with ; (semicolon)
alias lm="ls -l | more"
alias md="mkdir -p" ## creates full path
alias mv="mv -i" ## -i prevents overwriting files, use full path or \ to override
alias cp="cp -i" ## -i prevents overwriting files, use full path to override
alias rm="rm -i" ## -i prevents overwriting files, use full path to override
alias dfh='df -h | grep disk' ## modify to show primary file systems, YMMV - test
alias vi="vim" ## type which vi or which vim, set accordingly (not on Cygwin and Debian)
alias mroe=more ## add any other words you mistype often
#
#=======================================================================================
# SHELL OPTIONS:
#
shopt -s histverify ## allows recall historical commands, edit, then use, type: history
shopt -s checkwinsize ## checks and adjusts window size
#
#==========================================================================================
# FUNCTIONS:
# creates a directory structure and changes to the lowest level - be aware of KEYWORDS and COMMANDS
#
function dir-mkcd () { mkdir -p "$@" && eval cd "\"\$$#\""; }
#
#==========================================================================================
# ADDITIONAL NOTES - for user configuration
# 1) setup: create .exrc (or .vimrc) (configuratin file for the vi editor - ex is an editor in vi)
# set tabstop=4 shiftwidth=4 expandtab
# syntax off
# set ruler
# -----------------------------------
# tabstops - determines how many spaces per tab (normal is 5)
# shiftwidth - determines shift width, on type writers there were tabs, and tabstops, manually set
# rule - provides digital count of lines and spaces in lower right - very useful!
# -------
# norule - (: set norule ) turns off lines, characters and page %
# number - (: set nu) puts line numbers on left (not included in print or file save)
# nonumber - (: set nonu )
# -----------------------------------
# 2) FIVE BASIC COMMANDS:
# 1) man (also: --help, e.g. man --help )
# 2) ls (also: ls -al and ls -Al) (note: 26 letters, upper and lower case)
# 3) cd (type: which cd ) (NOTE: this is not a command, but a shell built-in)
# 4) pwd (print working director)
# 5) more (more is recommened, but less is more, both better than cat, because...)
# -----------------------------------
# 3) configure .ssh if using more than one Linux or MacOSX system
# see http://johnmeister.com/linux/Notes/SSH/quick-ssh.html
# mkdir .ssh ; cd .ssh ; ssh-keygen ; cp id_rsa.pub id_rsa.HOSTNAME
# -----------------------------------
# 4) some useful commands:
# 1) When copying a file, append the date: cp FILE FILE-`date +'%Y-%m-%b-%d'`
# 2) Use rsync to completely replace a local directory with that from another system as a backup
# use trailing "/" to prevent creating a new directory structure, and only use --delete if you want
# to remove old files locally. This is a very dangerous command - useful if you use more than one system
# rsync -av --delete --progress :/home/luser/somedir/ /home/luser/localdir/
# e.g.# rsync -av --delete --progress 192.168.11.99:/home/luser/files/ /home/luser/files/
#==========================================================================================
STOP COPYING AT LAST COMMENT ABOVE
for additional functions for searching text files with REGular EXpressions,
see also:
http://johnmeister.com/linux/REGEX for useful functions for searching text files with REGular EXpressions.
additional notes:
# to source, or update configuration, type: . ~/.bashrc or from home dir: . ./.bashrc
#
# adjusted for Win10 BASH - 19 July 2017 - works for all Unix-like shells - check paths
#=========================================================================================
# setup: Path, Prompt, Permissions, History, Editor, Alias, Shell options and Functions
#=========================================================================================
# do NOT use ~(tilde) .(period) for root user. To overwrite default PATH, remove $PATH
#
# W10 BASH DEFAULT=($PATH): /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
JohnMeister.com Today's Date:
|