Clean up .bash* and add some new aliases.
This commit is contained in:
parent
626fb43ec5
commit
2880b02fcf
2 changed files with 25 additions and 35 deletions
|
|
@ -8,9 +8,9 @@ export LC_COLLATE="POSIX" # 'C' causes issues with some applications
|
||||||
# export LC_CTYPE="POSIX" # Not sure why I set this in the first place...
|
# export LC_CTYPE="POSIX" # Not sure why I set this in the first place...
|
||||||
export LESS="-RM -j.5 -i -PM?f%F:stdin. -- Page %dt of %D -- %lt/%L (%Pt\%)$"
|
export LESS="-RM -j.5 -i -PM?f%F:stdin. -- Page %dt of %D -- %lt/%L (%Pt\%)$"
|
||||||
export PAGER="less"
|
export PAGER="less"
|
||||||
export PATH="/usr/local/sbin:/usr/sbin:/opt/sbin:/sbin:$PATH"
|
export PATH="/opt/sbin:/usr/local/sbin:/usr/sbin:/sbin:$PATH"
|
||||||
export VISUAL="$EDITOR"
|
export VISUAL="$EDITOR"
|
||||||
[[ -x /usr/bin/lesspipe ]] && eval "$(SHELL=/bin/sh lesspipe)"
|
hash lesspipe >/dev/null 2>&1 && eval "$(SHELL=/bin/sh lesspipe)"
|
||||||
|
|
||||||
# Platform specific set up.
|
# Platform specific set up.
|
||||||
PLATFORM="$(uname -s)"
|
PLATFORM="$(uname -s)"
|
||||||
|
|
@ -32,9 +32,9 @@ fi
|
||||||
unset PLATFORM
|
unset PLATFORM
|
||||||
|
|
||||||
# Add bin directories to PATH.
|
# Add bin directories to PATH.
|
||||||
[[ -d "$HOME/files/bin" ]] && export PATH="$HOME/files/bin:$PATH"
|
|
||||||
[[ -d "$HOME/.local/bin" ]] && export PATH="$HOME/.local/bin:$PATH"
|
[[ -d "$HOME/.local/bin" ]] && export PATH="$HOME/.local/bin:$PATH"
|
||||||
[[ -d "$HOME/bin" ]] && export PATH="$HOME/bin:$PATH"
|
[[ -d "$HOME/bin" ]] && export PATH="$HOME/bin:$PATH"
|
||||||
|
[[ -d "$HOME/files/bin" ]] && export PATH="$HOME/files/bin:$PATH"
|
||||||
|
|
||||||
# Screen.
|
# Screen.
|
||||||
hash screen >/dev/null 2>&1 && {
|
hash screen >/dev/null 2>&1 && {
|
||||||
|
|
@ -45,7 +45,7 @@ hash screen >/dev/null 2>&1 && {
|
||||||
echo "Screen $STY, window $WINDOW."
|
echo "Screen $STY, window $WINDOW."
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
SCREENS="$(screen -ls | grep '[[:alpha:]]' | egrep -v '^([[:digit:]]+|No) Socket(s)?')"
|
SCREENS="$(screen -ls | grep '[[:alpha:]]' | grep -E -v '^([[:digit:]]+|No) Socket(s)?')"
|
||||||
if [[ -n "$SCREENS" ]]; then
|
if [[ -n "$SCREENS" ]]; then
|
||||||
echo "$SCREENS"
|
echo "$SCREENS"
|
||||||
echo
|
echo
|
||||||
|
|
@ -60,8 +60,8 @@ hash screen >/dev/null 2>&1 && {
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
TTY="$(tty | cut -d/ -f3-)"
|
TTY="$(tty | cut -d/ -f3-)"
|
||||||
SCREENS="$(screen -list | fgrep "${HOSTNAME%%.*}" | fgrep "${TTY//\//-}")"
|
SCREENS="$(screen -list | grep -F "${HOSTNAME%%.*}" | grep -F "${TTY//\//-}")"
|
||||||
case "$(echo "${SCREENS:--n}" | wc -l)" in
|
case "$(echo ${SCREENS:--n} | wc -l)" in
|
||||||
0)
|
0)
|
||||||
# No screens found - start a new instance, if on a tty.
|
# No screens found - start a new instance, if on a tty.
|
||||||
[[ "$TTY" == *tty* ]] && screen
|
[[ "$TTY" == *tty* ]] && screen
|
||||||
|
|
@ -84,19 +84,3 @@ hash screen >/dev/null 2>&1 && {
|
||||||
unset SCREENS
|
unset SCREENS
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Mail check.
|
|
||||||
[[ ! -z "$SSH_CONNECTION" ]] && {
|
|
||||||
if [[ -s /var/spool/mail/$USER ]]; then
|
|
||||||
if [[ -N /var/spool/mail/$USER ]]; then
|
|
||||||
echo "You have new mail."
|
|
||||||
echo
|
|
||||||
else
|
|
||||||
echo "You have mail."
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
# else
|
|
||||||
# echo "No mail."
|
|
||||||
# echo
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
|
||||||
32
.bashrc
32
.bashrc
|
|
@ -50,8 +50,8 @@ unset COLOUR
|
||||||
|
|
||||||
# Set the debugger prompt.
|
# Set the debugger prompt.
|
||||||
# PS4="+(\\\$? = \$?) \${BASH_SOURCE##*/}\${FUNCNAME:+(\$FUNCNAME)}:\$LINENO: "
|
# PS4="+(\\\$? = \$?) \${BASH_SOURCE##*/}\${FUNCNAME:+(\$FUNCNAME)}:\$LINENO: "
|
||||||
# PS4="+(\[\e[33m\]\\\$? = \$?\[$(tput sgr0)\]) \[$(tput bold)$(tput setaf 4)\]\${BASH_SOURCE##*/}\[$(tput sgr0)\]\${FUNCNAME:+(\[$(tput bold)$(tput setaf 2)\]\$FUNCNAME\[$(tput sgr0)\])}:\[$(tput bold)$(tput setaf 1)\]\$LINENO\[$(tput sgr0)\]: "
|
# PS4="+(\[\e[1;33;40m\]\\\$? = \$?\[$(tput sgr0)\]) \[$(tput bold)$(tput setaf 4)\]\${BASH_SOURCE##*/}\[$(tput sgr0)\]\${FUNCNAME:+(\[$(tput bold)$(tput setaf 2)\]\$FUNCNAME\[$(tput sgr0)\])}:\[$(tput bold)$(tput setaf 1)\]\$LINENO\[$(tput sgr0)\]: "
|
||||||
export PS4="+(\[\e[33m\]\$?\[$(tput sgr0)\]) \[$(tput bold)$(tput setaf 4)\]\${BASH_SOURCE##*/}\[$(tput sgr0)\]\${FUNCNAME:+(\[$(tput bold)$(tput setaf 2)\]\$FUNCNAME\[$(tput sgr0)\])}:\[$(tput bold)$(tput setaf 1)\]\$LINENO\[$(tput sgr0)\]: "
|
export PS4="+(\[\e[1;33;40m\]\$?\[$(tput sgr0)\]) \[$(tput bold)$(tput setaf 4)\]\${BASH_SOURCE##*/}\[$(tput sgr0)\]\${FUNCNAME:+(\[$(tput bold)$(tput setaf 2)\]\$FUNCNAME\[$(tput sgr0)\])}:\[$(tput bold)$(tput setaf 1)\]\$LINENO\[$(tput sgr0)\]: "
|
||||||
|
|
||||||
# The commands to execute before the prompt is displayed.
|
# The commands to execute before the prompt is displayed.
|
||||||
# PROMPT_COMMAND=""
|
# PROMPT_COMMAND=""
|
||||||
|
|
@ -59,21 +59,22 @@ export PS4="+(\[\e[33m\]\$?\[$(tput sgr0)\]) \[$(tput bold)$(tput setaf 4)\]\${B
|
||||||
# Platform specific set up.
|
# Platform specific set up.
|
||||||
PLATFORM="$(uname -s)"
|
PLATFORM="$(uname -s)"
|
||||||
if [[ "$PLATFORM" = "Linux" ]]; then
|
if [[ "$PLATFORM" = "Linux" ]]; then
|
||||||
|
# Linux specific functions.
|
||||||
|
psgrep() {
|
||||||
|
[[ -z "$1" ]] && { printf "%s: %s\\n" "Usage" "$FUNCNAME <something>" >&2; return 1; }
|
||||||
|
ps -auwwx | command grep -E --color=always -- "(.*RSS.*|$1)" | grep -F -v "(.*RSS.*|"
|
||||||
|
}
|
||||||
|
|
||||||
# Linux specific aliases.
|
# Linux specific aliases.
|
||||||
hash ftpwho >/dev/null 2>&1 && alias ftpwho='ftpwho -v'
|
hash ftpwho >/dev/null 2>&1 && alias ftpwho='ftpwho -v'
|
||||||
hash iftop >/dev/null 2>&1 && alias iftop='TERM=vt100 iftop'
|
hash iftop >/dev/null 2>&1 && alias iftop='TERM=vt100 iftop'
|
||||||
hash last less >/dev/null 2>&1 && alias laston='last -a | less'
|
hash last less >/dev/null 2>&1 && alias laston='last -a | less'
|
||||||
hash ls >/dev/null 2>&1 && alias ls='ls -bFv --color=auto'
|
hash ls >/dev/null 2>&1 && alias ls='ls -bFv --color=auto'
|
||||||
hash minicom >/dev/null 2>&1 && alias minicom='minicom -m -c on'
|
hash minicom >/dev/null 2>&1 && alias minicom='minicom -m -c on'
|
||||||
|
hash mkpasswd >/dev/null 2>&1 && alias mkpasswd='mkpasswd -m sha512crypt'
|
||||||
hash mkpasswd >/dev/null 2>&1 && alias pwgen='mkpasswd -m sha512crypt'
|
hash mkpasswd >/dev/null 2>&1 && alias pwgen='mkpasswd -m sha512crypt'
|
||||||
#hash pine >/dev/null 2>&1 && alias pine='pine -p "{mail.opensourcerers.net/Service=IMAP/User=darren@afterdark.org.uk/TLS/NoValidate-Cert/NoRsh}.pinerc"'
|
|
||||||
hash pinfo >/dev/null 2>&1 && alias info='pinfo'
|
hash pinfo >/dev/null 2>&1 && alias info='pinfo'
|
||||||
hash ping >/dev/null 2>&1 && alias ping='ping -b'
|
hash ping >/dev/null 2>&1 && alias ping='ping -b'
|
||||||
|
|
||||||
# Linux specific functions.
|
|
||||||
psgrep() {
|
|
||||||
ps -auwwx | command egrep --color=always -- "(.*RSS.*|$1)" | fgrep -v "(.*RSS.*|"
|
|
||||||
}
|
|
||||||
elif [[ "$PLATFORM" = "Darwin" ]]; then
|
elif [[ "$PLATFORM" = "Darwin" ]]; then
|
||||||
# Darwin specific aliases.
|
# Darwin specific aliases.
|
||||||
hash df >/dev/null 2>&1 && alias df='df -P'
|
hash df >/dev/null 2>&1 && alias df='df -P'
|
||||||
|
|
@ -84,13 +85,18 @@ else
|
||||||
fi
|
fi
|
||||||
unset PLATFORM
|
unset PLATFORM
|
||||||
|
|
||||||
|
# Common functions.
|
||||||
|
imagebin() {
|
||||||
|
[[ -z "$1" ]] && { printf "%s: %s\\n" "Usage" "$FUNCNAME <filename>" >&2; return 1; }
|
||||||
|
curl -F file="@${1:-}" https://imagebin.ca/upload.php | grep ^url: | cut -d: -f2-
|
||||||
|
}
|
||||||
|
|
||||||
# Common aliases.
|
# Common aliases.
|
||||||
hash bc >/dev/null 2>&1 && alias bc='bc -lq'
|
hash bc >/dev/null 2>&1 && alias bc='bc -lq'
|
||||||
#hash curl >/dev/null 2>&1 && alias pastebin="curl -F 'sprunge=<-' http://sprunge.us"
|
hash diff >/dev/null 2>&1 && alias diff='diff --color=auto -u'
|
||||||
hash curl >/dev/null 2>&1 && imagebin() { curl -F file="@${1:-}" https://imagebin.ca/upload.php | grep ^url: | cut -d: -f2-; }
|
hash grep >/dev/null 2>&1 && alias egrep='grep -E --color=auto'
|
||||||
hash diff >/dev/null 2>&1 && alias diff='diff -u'
|
hash grep >/dev/null 2>&1 && alias fgrep='grep -E --color=auto'
|
||||||
hash egrep >/dev/null 2>&1 && alias egrep='egrep --color=auto'
|
|
||||||
hash fgrep >/dev/null 2>&1 && alias fgrep='fgrep --color=auto'
|
|
||||||
hash grep >/dev/null 2>&1 && alias grep='grep --color=auto'
|
hash grep >/dev/null 2>&1 && alias grep='grep --color=auto'
|
||||||
hash nc >/dev/null 2>&1 && alias pastebin='nc termbin.com 9999'
|
hash nc >/dev/null 2>&1 && alias pastebin='nc termbin.com 9999'
|
||||||
hash screen >/dev/null 2>&1 && alias screen='screen -Ua'
|
hash screen >/dev/null 2>&1 && alias screen='screen -Ua'
|
||||||
|
hash shellcheck >/dev/null 2>&1 && alias shellcheck='shellcheck -x'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue