mirror of
https://gitea.blesmrt.net/mikaela/shell-things.git
synced 2024-11-28 06:09:22 +01:00
rc: retab
This commit is contained in:
parent
5d42ef2539
commit
b2b2689296
382
rc/bashrc
382
rc/bashrc
@ -1,18 +1,18 @@
|
|||||||
UNAME=$(uname)
|
UNAME=$(uname)
|
||||||
# TOC
|
# TOC
|
||||||
# Defaults etc... M0TZLS
|
# Defaults etc... M0TZLS
|
||||||
# Environment 7RS56S
|
# Environment 7RS56S
|
||||||
# Aliases RJ706I
|
# Aliases RJ706I
|
||||||
# Functions ZGC5QQ
|
# Functions ZGC5QQ
|
||||||
|
|
||||||
# enable terminal bell
|
# enable terminal bell
|
||||||
|
|
||||||
if [ -f /usr/bin/xset ];
|
if [ -f /usr/bin/xset ];
|
||||||
then
|
then
|
||||||
(xset b on&)
|
(xset b on&)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##### Defaults etc... M0TZLS #####
|
##### Defaults etc... M0TZLS #####
|
||||||
|
|
||||||
# ~/.bashrc: executed by bash(1) for non-login shells.
|
# ~/.bashrc: executed by bash(1) for non-login shells.
|
||||||
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
|
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
|
||||||
@ -40,76 +40,76 @@ shopt -s checkwinsize
|
|||||||
|
|
||||||
# set variable identifying the chroot you work in (used in the prompt below)
|
# set variable identifying the chroot you work in (used in the prompt below)
|
||||||
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
|
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
|
||||||
debian_chroot=$(cat /etc/debian_chroot)
|
debian_chroot=$(cat /etc/debian_chroot)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# set a fancy prompt (non-color, unless we know we "want" color)
|
# set a fancy prompt (non-color, unless we know we "want" color)
|
||||||
case "$TERM" in
|
case "$TERM" in
|
||||||
xterm-color) color_prompt=yes;;
|
xterm-color) color_prompt=yes;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
force_color_prompt=yes
|
force_color_prompt=yes
|
||||||
|
|
||||||
if [ -n "$force_color_prompt" ]; then
|
if [ -n "$force_color_prompt" ]; then
|
||||||
if which tput >&/dev/null && tput setaf 1 >&/dev/null; then
|
if which tput >&/dev/null && tput setaf 1 >&/dev/null; then
|
||||||
# We have color support; assume it's compliant with Ecma-48
|
# We have color support; assume it's compliant with Ecma-48
|
||||||
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
|
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
|
||||||
# a case would tend to support setf rather than setaf.)
|
# a case would tend to support setf rather than setaf.)
|
||||||
color_prompt=yes
|
color_prompt=yes
|
||||||
else
|
else
|
||||||
color_prompt=
|
color_prompt=
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$color_prompt" = yes ]; then
|
if [ "$color_prompt" = yes ]; then
|
||||||
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
||||||
else
|
else
|
||||||
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
|
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
|
||||||
fi
|
fi
|
||||||
unset color_prompt force_color_prompt
|
unset color_prompt force_color_prompt
|
||||||
|
|
||||||
# Red colour for root, thanks nyuszika7h
|
# Red colour for root, thanks nyuszika7h
|
||||||
# Check if we're root
|
# Check if we're root
|
||||||
if [[ $EUID == 0 ]]; then
|
if [[ $EUID == 0 ]]; then
|
||||||
PS1='\033[1;31m\u@\h:\w\$\033[0m '
|
PS1='\033[1;31m\u@\h:\w\$\033[0m '
|
||||||
else
|
else
|
||||||
PS1='\033[1;32m\u@\h:\w\$\033[0m '
|
PS1='\033[1;32m\u@\h:\w\$\033[0m '
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If this is an xterm set the title to user@host:dir
|
# If this is an xterm set the title to user@host:dir
|
||||||
case "$TERM" in
|
case "$TERM" in
|
||||||
xterm*|*rxvt*)
|
xterm*|*rxvt*)
|
||||||
PS1="\[\e]0;\u@\h: \w\a\]$PS1"
|
PS1="\[\e]0;\u@\h: \w\a\]$PS1"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# enable color support of ls and also add handy aliases
|
# enable color support of ls and also add handy aliases
|
||||||
if [ -x /usr/bin/dircolors ]; then
|
if [ -x /usr/bin/dircolors ]; then
|
||||||
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
||||||
alias ls='ls --color=always'
|
alias ls='ls --color=always'
|
||||||
alias dir='dir --color=always'
|
alias dir='dir --color=always'
|
||||||
alias vdir='vdir --color=always'
|
alias vdir='vdir --color=always'
|
||||||
|
|
||||||
alias grep='grep -i --color=always'
|
alias grep='grep -i --color=always'
|
||||||
alias fgrep='fgrep -i --color=always'
|
alias fgrep='fgrep -i --color=always'
|
||||||
alias egrep='egrep -i --color=always'
|
alias egrep='egrep -i --color=always'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# some more ls aliases
|
# some more ls aliases
|
||||||
if [[ $UNAME != Darwin ]]; then
|
if [[ $UNAME != Darwin ]]; then
|
||||||
alias ll='ls -alFh --color=always' && alias la='ls -A --color=always' && alias l='ls -CF --color=always'
|
alias ll='ls -alFh --color=always' && alias la='ls -A --color=always' && alias l='ls -CF --color=always'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $UNAME = Darwin ]]; then
|
if [[ $UNAME = Darwin ]]; then
|
||||||
alias ls="ls -Gp"
|
alias ls="ls -Gp"
|
||||||
alias ll="ls -alFHGp"
|
alias ll="ls -alFHGp"
|
||||||
alias l="ls -CFGp"
|
alias l="ls -CFGp"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add an "alert" alias for long running commands. Use like so:
|
# Add an "alert" alias for long running commands. Use like so:
|
||||||
# sleep 10; alert
|
# sleep 10; alert
|
||||||
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
|
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
|
||||||
|
|
||||||
# Alias definitions.
|
# Alias definitions.
|
||||||
@ -118,14 +118,14 @@ alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo
|
|||||||
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
|
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
|
||||||
|
|
||||||
if [ -f ~/.bash_aliases ]; then
|
if [ -f ~/.bash_aliases ]; then
|
||||||
. ~/.bash_aliases
|
. ~/.bash_aliases
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# enable programmable completion features (you don't need to enable
|
# enable programmable completion features (you don't need to enable
|
||||||
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
|
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
|
||||||
# sources /etc/bash.bashrc).
|
# sources /etc/bash.bashrc).
|
||||||
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
|
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
|
||||||
. /etc/bash_completion
|
. /etc/bash_completion
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Shopt settings.
|
#Shopt settings.
|
||||||
@ -136,15 +136,15 @@ fi
|
|||||||
(uptime&)
|
(uptime&)
|
||||||
(echo "")
|
(echo "")
|
||||||
if [[ $UNAME != Darwin ]]; then
|
if [[ $UNAME != Darwin ]]; then
|
||||||
(who -H -w -u|head -n10&)
|
(who -H -w -u|head -n10&)
|
||||||
(echo "")
|
(echo "")
|
||||||
# (last -10 -w -x&)
|
# (last -10 -w -x&)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $UNAME = Darwin ]]; then
|
if [[ $UNAME = Darwin ]]; then
|
||||||
(who -H -u|head -n10&)
|
(who -H -u|head -n10&)
|
||||||
(echo "")
|
(echo "")
|
||||||
(last -10&)
|
(last -10&)
|
||||||
fi
|
fi
|
||||||
(printf "Aferoj emas funkcii sin mem.\n\tFaru jogon, sentu, ne provu perfektecon.\n\t\tDancu kiel neniu rigardas.\n" && echo&)
|
(printf "Aferoj emas funkcii sin mem.\n\tFaru jogon, sentu, ne provu perfektecon.\n\t\tDancu kiel neniu rigardas.\n" && echo&)
|
||||||
|
|
||||||
@ -152,31 +152,31 @@ fi
|
|||||||
export LS_COLORS="$LS_COLORS:ow=1;7;34:st=30;44:su=30;41"
|
export LS_COLORS="$LS_COLORS:ow=1;7;34:st=30;44:su=30;41"
|
||||||
|
|
||||||
|
|
||||||
##### Environment 7RS56S #####
|
##### Environment 7RS56S #####
|
||||||
# Environment should be placed to .environment or .bash_environment.
|
# Environment should be placed to .environment or .bash_environment.
|
||||||
|
|
||||||
# Source before mentioned locations if they exist.
|
# Source before mentioned locations if they exist.
|
||||||
|
|
||||||
# .environment
|
# .environment
|
||||||
if [ -f ~/.environment ]; then
|
if [ -f ~/.environment ]; then
|
||||||
source ~/.environment
|
source ~/.environment
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# .bash_environment
|
# .bash_environment
|
||||||
if [ -f ~/.bash_environment ]; then
|
if [ -f ~/.bash_environment ]; then
|
||||||
source ~/.bash_environment
|
source ~/.bash_environment
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Enable core files.
|
# Enable core files.
|
||||||
(ulimit -c unlimited&)
|
(ulimit -c unlimited&)
|
||||||
|
|
||||||
# More colours
|
# More colours
|
||||||
if [[ $TERM == 'xterm' ]]; then
|
if [[ $TERM == 'xterm' ]]; then
|
||||||
export TERM=xterm-256color
|
export TERM=xterm-256color
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $TERM == 'screen' ]]; then
|
if [[ $TERM == 'screen' ]]; then
|
||||||
export TERM=screen-256color
|
export TERM=screen-256color
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Things after this are just examples and should be put to some other file, which is sourced above.
|
# Things after this are just examples and should be put to some other file, which is sourced above.
|
||||||
@ -187,12 +187,12 @@ fi
|
|||||||
# Set TZ to local timezone for sending over SSH
|
# Set TZ to local timezone for sending over SSH
|
||||||
TZ=$(date +%Z)
|
TZ=$(date +%Z)
|
||||||
|
|
||||||
# Sets PATH. To add another path, add :</path/to/new/path> to string below.
|
# Sets PATH. To add another path, add :</path/to/new/path> to string below.
|
||||||
PATH=$HOME/.local/bin:$HOME/bin:$HOME/go/bin:$HOME/.local/share/flatpak/exports/bin:/var/lib/flatpak/exports/bin:/snap/bin:/usr/local/bin:/usr/local/sbin:/usr/local/games:/usr/bin:/usr/sbin:/usr/games:/bin:/sbin:/games:$PATH
|
PATH=$HOME/.local/bin:$HOME/bin:$HOME/go/bin:$HOME/.local/share/flatpak/exports/bin:/var/lib/flatpak/exports/bin:/snap/bin:/usr/local/bin:/usr/local/sbin:/usr/local/games:/usr/bin:/usr/sbin:/usr/games:/bin:/sbin:/games:$PATH
|
||||||
|
|
||||||
# Add RubyGems to PATH
|
# Add RubyGems to PATH
|
||||||
if hash ruby 2>/dev/null; then
|
if hash ruby 2>/dev/null; then
|
||||||
PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH"
|
PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Removes duplicates from $PATH. Copied from https://unix.stackexchange.com/a/14896
|
# Removes duplicates from $PATH. Copied from https://unix.stackexchange.com/a/14896
|
||||||
@ -214,9 +214,9 @@ CPUARCH=$(uname -p)
|
|||||||
|
|
||||||
# If we are on Linux, enable apt progress bar and colours
|
# If we are on Linux, enable apt progress bar and colours
|
||||||
if [[ $USER = "root" ]]; then
|
if [[ $USER = "root" ]]; then
|
||||||
mkdir -p /etc/apt/apt.conf.d/
|
mkdir -p /etc/apt/apt.conf.d/
|
||||||
echo 'Dpkg::Progress-Fancy "1";' > /etc/apt/apt.conf.d/99progressbar
|
echo 'Dpkg::Progress-Fancy "1";' > /etc/apt/apt.conf.d/99progressbar
|
||||||
echo 'APT::Color "1";' > /etc/apt/apt.conf.d/99color
|
echo 'APT::Color "1";' > /etc/apt/apt.conf.d/99color
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# if gpg[-agent] has sshcontrol file, use it as ssh-agent. sshcontrol should
|
# if gpg[-agent] has sshcontrol file, use it as ssh-agent. sshcontrol should
|
||||||
@ -225,14 +225,14 @@ fi
|
|||||||
# Assumption: there is not going to be a sshcontrol file if `gpgconf` is not
|
# Assumption: there is not going to be a sshcontrol file if `gpgconf` is not
|
||||||
# installed or `sshcontrol` is trivial to remove.
|
# installed or `sshcontrol` is trivial to remove.
|
||||||
if [ -f ~/.gnupg/sshcontrol ]; then
|
if [ -f ~/.gnupg/sshcontrol ]; then
|
||||||
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
|
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
|
||||||
gpgconf --launch gpg-agent
|
gpgconf --launch gpg-agent
|
||||||
gpg-connect-agent updatestartuptty /bye >/dev/null 2>&1
|
gpg-connect-agent updatestartuptty /bye >/dev/null 2>&1
|
||||||
# otherwise use the normal ssh-agent
|
# otherwise use the normal ssh-agent
|
||||||
else
|
else
|
||||||
# if the output is going to /dev/null, it's non/existence doesn't matter
|
# if the output is going to /dev/null, it's non/existence doesn't matter
|
||||||
(ssh-agent -a /tmp/$USER.sshagent > /dev/null 2>&1)
|
(ssh-agent -a /tmp/$USER.sshagent > /dev/null 2>&1)
|
||||||
export SSH_AUTH_SOCK=/tmp/$USER.sshagent
|
export SSH_AUTH_SOCK=/tmp/$USER.sshagent
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# OS X ls colours (copied from https://apple.stackexchange.com/questions/33677/
|
# OS X ls colours (copied from https://apple.stackexchange.com/questions/33677/
|
||||||
@ -242,7 +242,7 @@ export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
|
|||||||
# znc uses this variable for figuring out hostname
|
# znc uses this variable for figuring out hostname
|
||||||
#export HOSTNAME=$(hostname --fqdn)
|
#export HOSTNAME=$(hostname --fqdn)
|
||||||
|
|
||||||
##### Aliases RJ706I #####
|
##### Aliases RJ706I #####
|
||||||
|
|
||||||
# To get sudo work with aliases.
|
# To get sudo work with aliases.
|
||||||
alias sudo="sudo "
|
alias sudo="sudo "
|
||||||
@ -252,7 +252,7 @@ alias ..="cd .."
|
|||||||
|
|
||||||
# Use htop instead of top if available
|
# Use htop instead of top if available
|
||||||
if hash htop 2>/dev/null; then
|
if hash htop 2>/dev/null; then
|
||||||
alias top="htop"
|
alias top="htop"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add title to youtube-dl & make yle-dl Windows-friendly
|
# Add title to youtube-dl & make yle-dl Windows-friendly
|
||||||
@ -275,7 +275,7 @@ alias nmap-quick="nmap -T4 -F "
|
|||||||
alias nmap-quick-plus="sudo nmap -sV -T4 -O -F --version-light "
|
alias nmap-quick-plus="sudo nmap -sV -T4 -O -F --version-light "
|
||||||
alias nmap-traceroute="sudo nmap -sP -PE -PS22,25,80 -PA21,23,80,3389 -PU -PO --traceroute "
|
alias nmap-traceroute="sudo nmap -sP -PE -PS22,25,80 -PA21,23,80,3389 -PU -PO --traceroute "
|
||||||
alias nmap-regular="nmap "
|
alias nmap-regular="nmap "
|
||||||
alias nmap-comprehensive="sudo nmap -sS -sU -T4 -A -v -PE -PP -PS21,22,23,25,80,113,31339 -PA80,113,443,10042 -PO --script all "
|
alias nmap-comprehensive="sudo nmap -sS -sU -T4 -A -v -PE -PP -PS21,22,23,25,80,113,31339 -PA80,113,443,10042 -PO --script all "
|
||||||
# Little "safer" scan as connecting to only HTTP and HTTPS ports doesn't look so attacking. Copy-paste to .bash_custom and remove " -p 80,443" if you want to scan all ports which nmap scans by default.
|
# Little "safer" scan as connecting to only HTTP and HTTPS ports doesn't look so attacking. Copy-paste to .bash_custom and remove " -p 80,443" if you want to scan all ports which nmap scans by default.
|
||||||
alias nmap-osscan="sudo nmap -p 80,443 -O -v --osscan-guess --fuzzy "
|
alias nmap-osscan="sudo nmap -p 80,443 -O -v --osscan-guess --fuzzy "
|
||||||
|
|
||||||
@ -303,11 +303,11 @@ alias supybot-generate-messages.pot-mass="find . -type d -exec sh -c '(cd {} &&
|
|||||||
|
|
||||||
# enable color support of ls and also add handy aliases
|
# enable color support of ls and also add handy aliases
|
||||||
if [[ $UNAME != Darwin ]]; then
|
if [[ $UNAME != Darwin ]]; then
|
||||||
alias ls='ls --color=always'
|
alias ls='ls --color=always'
|
||||||
fi
|
fi
|
||||||
# some more ls aliases
|
# some more ls aliases
|
||||||
if [[ $UNAME != Darwin ]]; then
|
if [[ $UNAME != Darwin ]]; then
|
||||||
alias ll='ls -alFh --color=always' && alias la='ls -A --color=always' && alias l='ls -CF --color=always'
|
alias ll='ls -alFh --color=always' && alias la='ls -A --color=always' && alias l='ls -CF --color=always'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## -- End of aliases which are saved from Ubuntu default bashrc. --
|
## -- End of aliases which are saved from Ubuntu default bashrc. --
|
||||||
@ -331,13 +331,13 @@ alias rsync-folder="rsync -h --progress -azvv "
|
|||||||
|
|
||||||
# SSHGuard seems to prefer users to run this always when connecting with keys in ssh-agent...
|
# SSHGuard seems to prefer users to run this always when connecting with keys in ssh-agent...
|
||||||
#if [[ $UNAME != Darwin ]]; then
|
#if [[ $UNAME != Darwin ]]; then
|
||||||
# alias ssh-add="\ssh-add -D && \ssh-add "
|
# alias ssh-add="\ssh-add -D && \ssh-add "
|
||||||
#fi
|
#fi
|
||||||
|
|
||||||
# Use GPG2 instead of GPG!
|
# Use GPG2 instead of GPG!
|
||||||
if hash gpg2 2>/dev/null; then
|
if hash gpg2 2>/dev/null; then
|
||||||
alias gpg=gpg2
|
alias gpg=gpg2
|
||||||
export KEYBASE_GPG=gpg2
|
export KEYBASE_GPG=gpg2
|
||||||
fi
|
fi
|
||||||
alias gpg-fix-tty='export GPG_TTY=$(tty)'
|
alias gpg-fix-tty='export GPG_TTY=$(tty)'
|
||||||
|
|
||||||
@ -462,8 +462,8 @@ alias venv="python3 -m venv"
|
|||||||
# cp/mv using rsync. rcp appears to be link to scp in my system, so I can
|
# cp/mv using rsync. rcp appears to be link to scp in my system, so I can
|
||||||
# safely use this alias.
|
# safely use this alias.
|
||||||
if hash rsync 2>/dev/null; then
|
if hash rsync 2>/dev/null; then
|
||||||
alias rcp="rsync -a --progress"
|
alias rcp="rsync -a --progress"
|
||||||
alias rmv="rsync -a --progress --remove-source-files"
|
alias rmv="rsync -a --progress --remove-source-files"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clear apt list cache
|
# Clear apt list cache
|
||||||
@ -540,20 +540,20 @@ alias ssh-sign-file="ssh-keygen -Y sign -f ~/.ssh/signingkey.pub -n file"
|
|||||||
|
|
||||||
# .aliases
|
# .aliases
|
||||||
if [ -f ~/.aliases ]; then
|
if [ -f ~/.aliases ]; then
|
||||||
source ~/.aliases
|
source ~/.aliases
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# .bash_aliases
|
# .bash_aliases
|
||||||
if [ -f ~/.bash_aliases ]; then
|
if [ -f ~/.bash_aliases ]; then
|
||||||
source ~/.bash_aliases
|
source ~/.bash_aliases
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##### Functions ZGC5QQ #####
|
##### Functions ZGC5QQ #####
|
||||||
|
|
||||||
# GEOIP lookup, improved from the ultimate bashrc https://goo.gl/qGK5j
|
# GEOIP lookup, improved from the ultimate bashrc https://goo.gl/qGK5j
|
||||||
function geoip() {
|
function geoip() {
|
||||||
geoiplookup $1
|
geoiplookup $1
|
||||||
geoiplookup6 $1
|
geoiplookup6 $1
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: Is it bash or zshrc?
|
# TODO: Is it bash or zshrc?
|
||||||
@ -566,55 +566,55 @@ function ex ()
|
|||||||
{
|
{
|
||||||
if [ -f "$1" ] ; then
|
if [ -f "$1" ] ; then
|
||||||
case "$1" in
|
case "$1" in
|
||||||
*.tar) tar xvf $1 ;;
|
*.tar) tar xvf $1 ;;
|
||||||
*.tar.bz2 | *.tbz2 ) tar xjvf $1 ;;
|
*.tar.bz2 | *.tbz2 ) tar xjvf $1 ;;
|
||||||
*.tar.gz | *.tgz ) tar xzvf $1 ;;
|
*.tar.gz | *.tgz ) tar xzvf $1 ;;
|
||||||
*.bz2) bunzip2 $1 ;;
|
*.bz2) bunzip2 $1 ;;
|
||||||
*.rar) unrar x $1 ;;
|
*.rar) unrar x $1 ;;
|
||||||
*.gz) gunzip $1 ;;
|
*.gz) gunzip $1 ;;
|
||||||
*.zip) unzip $1 ;;
|
*.zip) unzip $1 ;;
|
||||||
*.Z) uncompress $1 ;;
|
*.Z) uncompress $1 ;;
|
||||||
*.7z) 7z x $1 ;;
|
*.7z) 7z x $1 ;;
|
||||||
*.xz) tar xJvf $1 ;;
|
*.xz) tar xJvf $1 ;;
|
||||||
*.deb)
|
*.deb)
|
||||||
DIR=${1%%_*.deb}
|
DIR=${1%%_*.deb}
|
||||||
ar xv $1
|
ar xv $1
|
||||||
mkdir ${DIR}
|
mkdir ${DIR}
|
||||||
tar -C ${DIR} -xzvf data.tar.gz ;;
|
tar -C ${DIR} -xzvf data.tar.gz ;;
|
||||||
*.rpm) rpm2cpio $1 | cpio -vid ;;
|
*.rpm) rpm2cpio $1 | cpio -vid ;;
|
||||||
*) echo ""${1}" cannot be extracted via extract()"
|
*) echo ""${1}" cannot be extracted via extract()"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
echo ""${1}" is not a valid file"
|
echo ""${1}" is not a valid file"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Given by nyuszika7h. Shortens GitHub URLs with git.io
|
# Given by nyuszika7h. Shortens GitHub URLs with git.io
|
||||||
function gitio() {
|
function gitio() {
|
||||||
curl -s -i https://git.io -F "url=$1" | grep --color=never -P '^Location: ' | awk '{ print $2 }'
|
curl -s -i https://git.io -F "url=$1" | grep --color=never -P '^Location: ' | awk '{ print $2 }'
|
||||||
}
|
}
|
||||||
|
|
||||||
function mkcd() {
|
function mkcd() {
|
||||||
if [[ $# -gt 1 ]]; then
|
if [[ $# -gt 1 ]]; then
|
||||||
echo 'Warning: All directories will be created, but will change to first specified directory.' 1>&2
|
echo 'Warning: All directories will be created, but will change to first specified directory.' 1>&2
|
||||||
fi
|
fi
|
||||||
mkdir -p "$*" && cd "$1"
|
mkdir -p "$*" && cd "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
function gribble-gpg-everify() {
|
function gribble-gpg-everify() {
|
||||||
# Set which command to use for gpg. You
|
# Set which command to use for gpg. You
|
||||||
# probably want to use gpg2 here.
|
# probably want to use gpg2 here.
|
||||||
local gpg=gpg2
|
local gpg=gpg2
|
||||||
|
|
||||||
echo -n 'Enter Bitcoin OTC URL: '
|
echo -n 'Enter Bitcoin OTC URL: '
|
||||||
read REPLY
|
read REPLY
|
||||||
lynx -hiddenlinks=ignore -dump $REPLY > bitcoin_otc.txt.asc
|
lynx -hiddenlinks=ignore -dump $REPLY > bitcoin_otc.txt.asc
|
||||||
$gpg --decrypt-file bitcoin_otc.txt.asc
|
$gpg --decrypt-file bitcoin_otc.txt.asc
|
||||||
echo -en '\e[1;32m;;everify '
|
echo -en '\e[1;32m;;everify '
|
||||||
cat bitcoin_otc.txt
|
cat bitcoin_otc.txt
|
||||||
echo -e '\e[0m'
|
echo -e '\e[0m'
|
||||||
rm -rf bitcoin_otc.txt bitcoin_otc.txt.asc
|
rm -rf bitcoin_otc.txt bitcoin_otc.txt.asc
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will install/upgrade shell-things.
|
# This function will install/upgrade shell-things.
|
||||||
@ -625,28 +625,28 @@ export SHELL_THINGS_REPO=$HOME/.shell-things
|
|||||||
|
|
||||||
# Check if ~/.shell-things exists and cd and pull.
|
# Check if ~/.shell-things exists and cd and pull.
|
||||||
if [ -d $SHELL_THINGS_REPO ]; then
|
if [ -d $SHELL_THINGS_REPO ]; then
|
||||||
echo "shell-things: $SHELL_THINGS_REPO exists, git pulling..."
|
echo "shell-things: $SHELL_THINGS_REPO exists, git pulling..."
|
||||||
echo ""
|
echo ""
|
||||||
cd $SHELL_THINGS_REPO
|
cd $SHELL_THINGS_REPO
|
||||||
git remote set-url origin https://gitea.blesmrt.net/Mikaela/shell-things.git
|
git remote set-url origin https://gitea.blesmrt.net/Mikaela/shell-things.git
|
||||||
git fetch --all
|
git fetch --all
|
||||||
git pull
|
git pull
|
||||||
git verify-commit HEAD
|
git verify-commit HEAD
|
||||||
sleep 10
|
sleep 10
|
||||||
echo ""
|
echo ""
|
||||||
echo "shell-things: Installing/Upgrading..."
|
echo "shell-things: Installing/Upgrading..."
|
||||||
echo ""
|
echo ""
|
||||||
# If it doesn't exist...
|
# If it doesn't exist...
|
||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
echo "shell-things: $SHELL_THINGS_REPO doesn't exist, cloning..."
|
echo "shell-things: $SHELL_THINGS_REPO doesn't exist, cloning..."
|
||||||
echo ""
|
echo ""
|
||||||
git clone https://gitea.blesmrt.net/Mikaela/shell-things.git $SHELL_THINGS_REPO
|
git clone https://gitea.blesmrt.net/Mikaela/shell-things.git $SHELL_THINGS_REPO
|
||||||
cd $SHELL_THINGS_REPO
|
cd $SHELL_THINGS_REPO
|
||||||
sleep 10
|
sleep 10
|
||||||
echo ""
|
echo ""
|
||||||
echo "shell-things: Installing/Upgrading..."
|
echo "shell-things: Installing/Upgrading..."
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Installing...
|
# Installing...
|
||||||
@ -666,142 +666,142 @@ cd
|
|||||||
# This function fixes nodejs on Debian based systems.
|
# This function fixes nodejs on Debian based systems.
|
||||||
# (Everything expects nodejs to be called as node, but it's not with Debian.)
|
# (Everything expects nodejs to be called as node, but it's not with Debian.)
|
||||||
fix-node () {
|
fix-node () {
|
||||||
if [[ $USER = "root" && -f /usr/bin/nodejs && ! -f /usr/bin/node && ! -f /usr/local/bin/node ]]
|
if [[ $USER = "root" && -f /usr/bin/nodejs && ! -f /usr/bin/node && ! -f /usr/local/bin/node ]]
|
||||||
then
|
then
|
||||||
ln -s /usr/bin/nodejs /usr/local/bin/node
|
ln -s /usr/bin/nodejs /usr/local/bin/node
|
||||||
fi
|
fi
|
||||||
mkdir -p $HOME/.local/bin
|
mkdir -p $HOME/.local/bin
|
||||||
if [[ -f /usr/bin/nodejs && ! -f /usr/bin/node && ! -f /usr/local/bin/node && ! -f $HOME/.local/bin/node ]]
|
if [[ -f /usr/bin/nodejs && ! -f /usr/bin/node && ! -f /usr/local/bin/node && ! -f $HOME/.local/bin/node ]]
|
||||||
then
|
then
|
||||||
ln -s /usr/bin/nodejs $HOME/.local/bin/node
|
ln -s /usr/bin/nodejs $HOME/.local/bin/node
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function removes and regenerates ssh host keys.
|
# This function removes and regenerates ssh host keys.
|
||||||
|
|
||||||
#ssh-regen-host-keys () {
|
#ssh-regen-host-keys () {
|
||||||
# rm /etc/ssh/ssh_host_*
|
# rm /etc/ssh/ssh_host_*
|
||||||
# ssh-keygen -t rsa -N "" -f /etc/ssh/ssh_host_rsa_key
|
# ssh-keygen -t rsa -N "" -f /etc/ssh/ssh_host_rsa_key
|
||||||
# ssh-keygen -t ed25519 -N "" -f /etc/ssh/ssh_host_ed25519_key
|
# ssh-keygen -t ed25519 -N "" -f /etc/ssh/ssh_host_ed25519_key
|
||||||
#}
|
#}
|
||||||
|
|
||||||
# This function erases Master Boot Record from device
|
# This function erases Master Boot Record from device
|
||||||
# Note: this is dangerous so this function will echo the command
|
# Note: this is dangerous so this function will echo the command
|
||||||
# instad of running it!
|
# instad of running it!
|
||||||
#erase-mbr() {
|
#erase-mbr() {
|
||||||
# echo dd if=/dev/zero of=$1 bs=512 count=2
|
# echo dd if=/dev/zero of=$1 bs=512 count=2
|
||||||
#}
|
#}
|
||||||
|
|
||||||
# Use clang if installed. It seems interesting and this is probably good
|
# Use clang if installed. It seems interesting and this is probably good
|
||||||
# way to test it. This might not be a function, but I don't have any better
|
# way to test it. This might not be a function, but I don't have any better
|
||||||
# place for this.
|
# place for this.
|
||||||
if hash clang 2>/dev/null; then
|
if hash clang 2>/dev/null; then
|
||||||
export CC=clang
|
export CC=clang
|
||||||
export HOMEBREW_CC=clang
|
export HOMEBREW_CC=clang
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if hash clang++ 2>/dev/null; then
|
if hash clang++ 2>/dev/null; then
|
||||||
export CXX=clang++
|
export CXX=clang++
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add GitHub pull requests to fetched things via https://git.io/-C-0oQ
|
# Add GitHub pull requests to fetched things via https://git.io/-C-0oQ
|
||||||
github-add-pulls() {
|
github-add-pulls() {
|
||||||
git config --add remote.origin.fetch '+refs/pull/*/head:refs/remotes/origin/pr/*'
|
git config --add remote.origin.fetch '+refs/pull/*/head:refs/remotes/origin/pr/*'
|
||||||
git config --add remote.upstream.fetch '+refs/pull/*/head:refs/remotes/upstream/-pr/*'
|
git config --add remote.upstream.fetch '+refs/pull/*/head:refs/remotes/upstream/-pr/*'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get server SSL certificate fingerprint in MD5, SHA1 and SHA256.
|
# Get server SSL certificate fingerprint in MD5, SHA1 and SHA256.
|
||||||
# Note that OpenSSL doesn't support IPv6 at time of writing (2015-01-13).
|
# Note that OpenSSL doesn't support IPv6 at time of writing (2015-01-13).
|
||||||
serversslcertfp () {
|
serversslcertfp () {
|
||||||
SSSLCFFN=$(openssl s_client -showcerts -connect $1 < /dev/null)
|
SSSLCFFN=$(openssl s_client -showcerts -connect $1 < /dev/null)
|
||||||
# To see all validity information
|
# To see all validity information
|
||||||
echo "$SSSLCFFN"
|
echo "$SSSLCFFN"
|
||||||
# For getting the fingerprints
|
# For getting the fingerprints
|
||||||
echo "$SSSLCFFN" | openssl x509 -md5 -fingerprint -noout
|
echo "$SSSLCFFN" | openssl x509 -md5 -fingerprint -noout
|
||||||
echo "$SSSLCFFN" | openssl x509 -sha1 -fingerprint -noout
|
echo "$SSSLCFFN" | openssl x509 -sha1 -fingerprint -noout
|
||||||
echo "$SSSLCFFN" | openssl x509 -sha256 -fingerprint -noout
|
echo "$SSSLCFFN" | openssl x509 -sha256 -fingerprint -noout
|
||||||
echo "$SSSLCFFN" | openssl x509 -sha512 -fingerprint -noout
|
echo "$SSSLCFFN" | openssl x509 -sha512 -fingerprint -noout
|
||||||
unset SSSLCFFN
|
unset SSSLCFFN
|
||||||
}
|
}
|
||||||
|
|
||||||
# The same for local certificate file
|
# The same for local certificate file
|
||||||
sslcertfp () {
|
sslcertfp () {
|
||||||
cat $1 | openssl x509 -md5 -fingerprint -noout
|
cat $1 | openssl x509 -md5 -fingerprint -noout
|
||||||
cat $1 | openssl x509 -sha1 -fingerprint -noout
|
cat $1 | openssl x509 -sha1 -fingerprint -noout
|
||||||
cat $1 | openssl x509 -sha256 -fingerprint -noout
|
cat $1 | openssl x509 -sha256 -fingerprint -noout
|
||||||
cat $1 | openssl x509 -sha512 -fingerprint -noout
|
cat $1 | openssl x509 -sha512 -fingerprint -noout
|
||||||
}
|
}
|
||||||
|
|
||||||
# Usage: serversslciphers hostname port
|
# Usage: serversslciphers hostname port
|
||||||
serversslciphers() {
|
serversslciphers() {
|
||||||
nmap -Pn $1 -p $2 --script +ssl-enum-ciphers
|
nmap -Pn $1 -p $2 --script +ssl-enum-ciphers
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generate SSL certificate
|
# Generate SSL certificate
|
||||||
sslgenpem () {
|
sslgenpem () {
|
||||||
openssl req -nodes -newkey rsa:4096 -keyout $1.pem -x509 -days 3650 -out $1.pem -subj "/CN=$2"
|
openssl req -nodes -newkey rsa:4096 -keyout $1.pem -x509 -days 3650 -out $1.pem -subj "/CN=$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Managing SSL certificates of Google Chrome
|
# Managing SSL certificates of Google Chrome
|
||||||
chrome-add-cert () {
|
chrome-add-cert () {
|
||||||
echo "Please ensure that either libnss3-tools or nss-tools is installed."
|
echo "Please ensure that either libnss3-tools or nss-tools is installed."
|
||||||
certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n $1 -i $1
|
certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n $1 -i $1
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome-list-certs () {
|
chrome-list-certs () {
|
||||||
echo "Please ensure that either libnss3-tools or nss-tools is installed."
|
echo "Please ensure that either libnss3-tools or nss-tools is installed."
|
||||||
certutil -d sql:$HOME/.pki/nssdb -L # add '-h all' to see all built-in certs
|
certutil -d sql:$HOME/.pki/nssdb -L # add '-h all' to see all built-in certs
|
||||||
}
|
}
|
||||||
|
|
||||||
ssldownloadcert () {
|
ssldownloadcert () {
|
||||||
echo "Please ensure that either libnss3-tools or nss-tools is installed."
|
echo "Please ensure that either libnss3-tools or nss-tools is installed."
|
||||||
echo QUIT | openssl s_client -connect $1:443 | sed -ne '/BEGIN CERT/,/END CERT/p' | tee $1.pem
|
echo QUIT | openssl s_client -connect $1:443 | sed -ne '/BEGIN CERT/,/END CERT/p' | tee $1.pem
|
||||||
}
|
}
|
||||||
|
|
||||||
# Getting magnet from transmission-daemon
|
# Getting magnet from transmission-daemon
|
||||||
transmission-torrents () {
|
transmission-torrents () {
|
||||||
transmission-remote -l
|
transmission-remote -l
|
||||||
}
|
}
|
||||||
transmission-magnet () {
|
transmission-magnet () {
|
||||||
transmission-remote -l -t $1 -i | \grep magnet | awk -F': ' '{print $2}'
|
transmission-remote -l -t $1 -i | \grep magnet | awk -F': ' '{print $2}'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Merges the last $1 commits into one
|
# Merges the last $1 commits into one
|
||||||
git-squash () {
|
git-squash () {
|
||||||
git reset --soft HEAD~$1
|
git reset --soft HEAD~$1
|
||||||
git commit
|
git commit
|
||||||
}
|
}
|
||||||
|
|
||||||
# Combining mtrp4 & mtrp6
|
# Combining mtrp4 & mtrp6
|
||||||
mtrp() {
|
mtrp() {
|
||||||
mtrp4 $@
|
mtrp4 $@
|
||||||
mtrp6 $@
|
mtrp6 $@
|
||||||
}
|
}
|
||||||
|
|
||||||
# My IPv4 address
|
# My IPv4 address
|
||||||
myip4 () {
|
myip4 () {
|
||||||
if hash dig 2>/dev/null; then
|
if hash dig 2>/dev/null; then
|
||||||
dig +short myip.opendns.com. A @208.67.222.222
|
dig +short myip.opendns.com. A @208.67.222.222
|
||||||
else
|
else
|
||||||
curl -L4s https://icanhazip.com/
|
curl -L4s https://icanhazip.com/
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# My IPv6 address
|
# My IPv6 address
|
||||||
myip6 () {
|
myip6 () {
|
||||||
if hash dig 2>/dev/null; then
|
if hash dig 2>/dev/null; then
|
||||||
dig +short myip.opendns.com. AAAA @2620:0:ccc::2
|
dig +short myip.opendns.com. AAAA @2620:0:ccc::2
|
||||||
else
|
else
|
||||||
curl -L6s https://icanhazip.com/
|
curl -L6s https://icanhazip.com/
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Easier verifying of SSH signed files: ssh-verify-file whatever@mikaela.info file.txt
|
# Easier verifying of SSH signed files: ssh-verify-file whatever@mikaela.info file.txt
|
||||||
# It's assumed that signature of file.txt is called as file.txt.sig
|
# It's assumed that signature of file.txt is called as file.txt.sig
|
||||||
sshAllowedSigners=$HOME/src/gitea.blesmrt.net/Mikaela/ssh-allowed_signers/allowed_signers
|
sshAllowedSigners=$HOME/src/gitea.blesmrt.net/Mikaela/ssh-allowed_signers/allowed_signers
|
||||||
ssh-verify-file () {
|
ssh-verify-file () {
|
||||||
echo "$1 ${2:?Usage: ssh-verify-file <email> <file-to-verify>}" > /dev/null
|
echo "$1 ${2:?Usage: ssh-verify-file <email> <file-to-verify>}" > /dev/null
|
||||||
ssh-keygen -Y verify -f $sshAllowedSigners -I $1 -n file -s $2.sig < $2
|
ssh-keygen -Y verify -f $sshAllowedSigners -I $1 -n file -s $2.sig < $2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -809,15 +809,15 @@ ssh-verify-file () {
|
|||||||
|
|
||||||
# acme.sh
|
# acme.sh
|
||||||
if [ -f ~/.acme.sh/acme.sh.env ]; then
|
if [ -f ~/.acme.sh/acme.sh.env ]; then
|
||||||
source ~/.acme.sh/acme.sh.env
|
source ~/.acme.sh/acme.sh.env
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# .custom
|
# .custom
|
||||||
if [ -f ~/.custom ]; then
|
if [ -f ~/.custom ]; then
|
||||||
source ~/.custom
|
source ~/.custom
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# .bash_custom
|
# .bash_custom
|
||||||
if [ -f ~/.bash_custom ]; then
|
if [ -f ~/.bash_custom ]; then
|
||||||
source ~/.bash_custom
|
source ~/.bash_custom
|
||||||
fi
|
fi
|
||||||
|
@ -3,7 +3,7 @@ PATH=$HOME/.local/bin:$HOME/bin:$HOME/go/bin:$HOME/.local/share/flatpak/exports/
|
|||||||
|
|
||||||
# Add RubyGems to PATH
|
# Add RubyGems to PATH
|
||||||
if hash ruby 2>/dev/null; then
|
if hash ruby 2>/dev/null; then
|
||||||
PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH"
|
PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set compose to menu, kill X with ctrl-alt-backspace,
|
# Set compose to menu, kill X with ctrl-alt-backspace,
|
||||||
@ -22,7 +22,7 @@ ulimit -c unlimited
|
|||||||
|
|
||||||
# Numlock on at boot
|
# Numlock on at boot
|
||||||
if hash numlockx 2>/dev/null; then
|
if hash numlockx 2>/dev/null; then
|
||||||
numlockx on
|
numlockx on
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Workaround disappearing cursors, probably no harm in any case
|
# Workaround disappearing cursors, probably no harm in any case
|
||||||
@ -30,10 +30,10 @@ export XCURSOR_DISCOVER=1
|
|||||||
|
|
||||||
# The environment was set to ~/.environment according to other files...
|
# The environment was set to ~/.environment according to other files...
|
||||||
if [ -f ~/.environment ]; then
|
if [ -f ~/.environment ]; then
|
||||||
. ~/.environment
|
. ~/.environment
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Something that scripts here won't attempt to overwrite
|
# Something that scripts here won't attempt to overwrite
|
||||||
if [ -f ~/.environment2 ]; then
|
if [ -f ~/.environment2 ]; then
|
||||||
. ~/.environment2
|
. ~/.environment2
|
||||||
fi
|
fi
|
||||||
|
344
rc/zshrc
344
rc/zshrc
@ -1,10 +1,10 @@
|
|||||||
# TOC
|
# TOC
|
||||||
# Defaults etc... M0TZLS
|
# Defaults etc... M0TZLS
|
||||||
# Environment 7RS56S
|
# Environment 7RS56S
|
||||||
# Aliases RJ706I
|
# Aliases RJ706I
|
||||||
# Functions ZGC5QQ
|
# Functions ZGC5QQ
|
||||||
|
|
||||||
# uname should be readable in $uname
|
# uname should be readable in $uname
|
||||||
uname=$(uname)
|
uname=$(uname)
|
||||||
UNAME=$(uname)
|
UNAME=$(uname)
|
||||||
|
|
||||||
@ -13,16 +13,16 @@ UNAME=$(uname)
|
|||||||
#case $TERM in
|
#case $TERM in
|
||||||
# (*xterm* | *rxvt*)
|
# (*xterm* | *rxvt*)
|
||||||
|
|
||||||
# Write some info to terminal title.
|
# Write some info to terminal title.
|
||||||
# This is seen when the shell prompts for input.
|
# This is seen when the shell prompts for input.
|
||||||
# function precmd {
|
# function precmd {
|
||||||
# print -Pn "\e]0;zsh%L %(1j,%j job%(2j|s|); ,)%~\a"
|
# print -Pn "\e]0;zsh%L %(1j,%j job%(2j|s|); ,)%~\a"
|
||||||
# }
|
# }
|
||||||
# Write command and args to terminal title.
|
# Write command and args to terminal title.
|
||||||
# This is seen while the shell waits for a command to complete.
|
# This is seen while the shell waits for a command to complete.
|
||||||
# function preexec {
|
# function preexec {
|
||||||
# printf "\033]0;%s\a" "$1"
|
# printf "\033]0;%s\a" "$1"
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
# ;;
|
# ;;
|
||||||
#esac
|
#esac
|
||||||
@ -31,10 +31,10 @@ UNAME=$(uname)
|
|||||||
|
|
||||||
if [[ -f /usr/bin/xset ]];
|
if [[ -f /usr/bin/xset ]];
|
||||||
then
|
then
|
||||||
(xset b on&)
|
(xset b on&)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##### Defaults etc... M0TZLS #####
|
##### Defaults etc... M0TZLS #####
|
||||||
|
|
||||||
# This is based on zshrc which came with Debian (Third option in wizard for new users.)
|
# This is based on zshrc which came with Debian (Third option in wizard for new users.)
|
||||||
|
|
||||||
@ -53,9 +53,9 @@ autoload -Uz promptinit
|
|||||||
promptinit
|
promptinit
|
||||||
|
|
||||||
if [ $USER = "root" ]; then
|
if [ $USER = "root" ]; then
|
||||||
prompt elite2 red
|
prompt elite2 red
|
||||||
else
|
else
|
||||||
prompt elite2 green
|
prompt elite2 green
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use emacs keybindings even if our EDITOR is set to vi
|
# Use emacs keybindings even if our EDITOR is set to vi
|
||||||
@ -71,7 +71,7 @@ zstyle ':completion:*' format 'Completing %d'
|
|||||||
zstyle ':completion:*' group-name ''
|
zstyle ':completion:*' group-name ''
|
||||||
zstyle ':completion:*' menu select=2
|
zstyle ':completion:*' menu select=2
|
||||||
if [[ $UNAME != Darwin ]]; then
|
if [[ $UNAME != Darwin ]]; then
|
||||||
eval "$(dircolors -b)"
|
eval "$(dircolors -b)"
|
||||||
fi
|
fi
|
||||||
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
|
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
|
||||||
zstyle ':completion:*' list-colors ''
|
zstyle ':completion:*' list-colors ''
|
||||||
@ -90,52 +90,52 @@ zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
|
|||||||
(uptime&)
|
(uptime&)
|
||||||
(echo "")
|
(echo "")
|
||||||
|
|
||||||
if [[ $UNAME != Darwin ]] then;
|
if [[ $UNAME != Darwin ]] then;
|
||||||
(who -H -w -u|head -n10&)
|
(who -H -w -u|head -n10&)
|
||||||
(echo "")
|
(echo "")
|
||||||
# (last -10 -w -x&)
|
# (last -10 -w -x&)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $UNAME = Darwin ]]; then
|
if [[ $UNAME = Darwin ]]; then
|
||||||
(who -H -u|head -n10&)
|
(who -H -u|head -n10&)
|
||||||
(echo "")
|
(echo "")
|
||||||
(last -10&)
|
(last -10&)
|
||||||
fi
|
fi
|
||||||
(printf "Aferoj emas funkcii sin mem.\n\tFaru jogon, sentu, ne provu perfektecon.\n\t\tDancu kiel neniu rigardas.\n" && echo&)
|
(printf "Aferoj emas funkcii sin mem.\n\tFaru jogon, sentu, ne provu perfektecon.\n\t\tDancu kiel neniu rigardas.\n" && echo&)
|
||||||
|
|
||||||
# fix dircolors for Selenized https://github.com/jan-warchol/selenized/blob/master/other-apps/dircolors/README.md
|
# fix dircolors for Selenized https://github.com/jan-warchol/selenized/blob/master/other-apps/dircolors/README.md
|
||||||
export LS_COLORS="$LS_COLORS:ow=1;7;34:st=30;44:su=30;41"
|
export LS_COLORS="$LS_COLORS:ow=1;7;34:st=30;44:su=30;41"
|
||||||
|
|
||||||
##### Environment 7RS56S #####
|
##### Environment 7RS56S #####
|
||||||
# Environment should be placed to .environment or .zsh_environment (or .zshenv).
|
# Environment should be placed to .environment or .zsh_environment (or .zshenv).
|
||||||
|
|
||||||
# Source before mentioned locations if they exist.
|
# Source before mentioned locations if they exist.
|
||||||
|
|
||||||
# .environment
|
# .environment
|
||||||
if [ -f ~/.environment ]; then
|
if [ -f ~/.environment ]; then
|
||||||
source ~/.environment
|
source ~/.environment
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# .zsh_environment
|
# .zsh_environment
|
||||||
if [ -f ~/.zsh_environment ]; then
|
if [ -f ~/.zsh_environment ]; then
|
||||||
source ~/.zsh_environment
|
source ~/.zsh_environment
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# .zshenv (Yes, I know that this is sourced by every zsh session even if this isn't here, but I just want to write it).
|
# .zshenv (Yes, I know that this is sourced by every zsh session even if this isn't here, but I just want to write it).
|
||||||
if [ -f ~/.zshenv ]; then
|
if [ -f ~/.zshenv ]; then
|
||||||
source ~/.zshenv
|
source ~/.zshenv
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Enable core files.
|
# Enable core files.
|
||||||
(ulimit -c unlimited&)
|
(ulimit -c unlimited&)
|
||||||
|
|
||||||
# More colours
|
# More colours
|
||||||
if [[ $TERM == 'xterm' ]]; then
|
if [[ $TERM == 'xterm' ]]; then
|
||||||
export TERM=xterm-256color
|
export TERM=xterm-256color
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $TERM == 'screen' ]]; then
|
if [[ $TERM == 'screen' ]]; then
|
||||||
export TERM=screen-256color
|
export TERM=screen-256color
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Sets the default editor.
|
# Sets the default editor.
|
||||||
@ -144,12 +144,12 @@ fi
|
|||||||
# Set TZ to local timezone for sending over SSH
|
# Set TZ to local timezone for sending over SSH
|
||||||
TZ=$(date +%Z)
|
TZ=$(date +%Z)
|
||||||
|
|
||||||
# Sets PATH. To add another path, add :</path/to/new/path> to string below.
|
# Sets PATH. To add another path, add :</path/to/new/path> to string below.
|
||||||
PATH=$HOME/.local/bin:$HOME/bin:$HOME/go/bin:$HOME/.local/share/flatpak/exports/bin:/var/lib/flatpak/exports/bin:/snap/bin:/usr/local/bin:/usr/local/sbin:/usr/local/games:/usr/bin:/usr/sbin:/usr/games:/bin:/sbin:/games:$PATH
|
PATH=$HOME/.local/bin:$HOME/bin:$HOME/go/bin:$HOME/.local/share/flatpak/exports/bin:/var/lib/flatpak/exports/bin:/snap/bin:/usr/local/bin:/usr/local/sbin:/usr/local/games:/usr/bin:/usr/sbin:/usr/games:/bin:/sbin:/games:$PATH
|
||||||
|
|
||||||
# Add RubyGems to PATH
|
# Add RubyGems to PATH
|
||||||
if hash ruby 2>/dev/null; then
|
if hash ruby 2>/dev/null; then
|
||||||
PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH"
|
PATH="$(ruby -e 'print Gem.user_dir')/bin:$PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Removes duplicates from $PATH. Copied from https://unix.stackexchange.com/a/14896
|
# Removes duplicates from $PATH. Copied from https://unix.stackexchange.com/a/14896
|
||||||
@ -174,21 +174,21 @@ CPUARCH=$(uname -p)
|
|||||||
# Assumption: there is not going to be a sshcontrol file if `gpgconf` is not
|
# Assumption: there is not going to be a sshcontrol file if `gpgconf` is not
|
||||||
# installed or `sshcontrol` is trivial to remove.
|
# installed or `sshcontrol` is trivial to remove.
|
||||||
if [ -f ~/.gnupg/sshcontrol ]; then
|
if [ -f ~/.gnupg/sshcontrol ]; then
|
||||||
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
|
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
|
||||||
gpgconf --launch gpg-agent
|
gpgconf --launch gpg-agent
|
||||||
gpg-connect-agent updatestartuptty /bye >/dev/null 2>&1
|
gpg-connect-agent updatestartuptty /bye >/dev/null 2>&1
|
||||||
# otherwise use the normal ssh-agent
|
# otherwise use the normal ssh-agent
|
||||||
else
|
else
|
||||||
# if the output is going to /dev/null, it's non/existence doesn't matter
|
# if the output is going to /dev/null, it's non/existence doesn't matter
|
||||||
(ssh-agent -a /tmp/$USER.sshagent > /dev/null 2>&1)
|
(ssh-agent -a /tmp/$USER.sshagent > /dev/null 2>&1)
|
||||||
export SSH_AUTH_SOCK=/tmp/$USER.sshagent
|
export SSH_AUTH_SOCK=/tmp/$USER.sshagent
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If we are on Linux, enable apt progress bar and colours
|
# If we are on Linux, enable apt progress bar and colours
|
||||||
if [[ $USER = "root" ]]; then
|
if [[ $USER = "root" ]]; then
|
||||||
mkdir -p /etc/apt/apt.conf.d/
|
mkdir -p /etc/apt/apt.conf.d/
|
||||||
echo 'Dpkg::Progress-Fancy "1";' > /etc/apt/apt.conf.d/99progressbar
|
echo 'Dpkg::Progress-Fancy "1";' > /etc/apt/apt.conf.d/99progressbar
|
||||||
echo 'APT::Color "1";' > /etc/apt/apt.conf.d/99color
|
echo 'APT::Color "1";' > /etc/apt/apt.conf.d/99color
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# OS X ls colours (copied from https://apple.stackexchange.com/questions/33677/
|
# OS X ls colours (copied from https://apple.stackexchange.com/questions/33677/
|
||||||
@ -198,7 +198,7 @@ export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
|
|||||||
# znc uses this variable for figuring out hostname
|
# znc uses this variable for figuring out hostname
|
||||||
#export HOSTNAME=$(hostname --fqdn)
|
#export HOSTNAME=$(hostname --fqdn)
|
||||||
|
|
||||||
##### Aliases RJ706I #####
|
##### Aliases RJ706I #####
|
||||||
|
|
||||||
# To get sudo work with aliases.
|
# To get sudo work with aliases.
|
||||||
alias sudo="sudo "
|
alias sudo="sudo "
|
||||||
@ -208,7 +208,7 @@ alias ..="cd .."
|
|||||||
|
|
||||||
# Use htop instead of top if available
|
# Use htop instead of top if available
|
||||||
if hash htop 2>/dev/null; then
|
if hash htop 2>/dev/null; then
|
||||||
alias top="htop"
|
alias top="htop"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add title to youtube-dl & make yle-dl Windows-friendly
|
# Add title to youtube-dl & make yle-dl Windows-friendly
|
||||||
@ -231,7 +231,7 @@ alias nmap-quick="nmap -T4 -F "
|
|||||||
alias nmap-quick-plus="sudo nmap -sV -T4 -O -F --version-light "
|
alias nmap-quick-plus="sudo nmap -sV -T4 -O -F --version-light "
|
||||||
alias nmap-traceroute="sudo nmap -sP -PE -PS22,25,80 -PA21,23,80,3389 -PU -PO --traceroute "
|
alias nmap-traceroute="sudo nmap -sP -PE -PS22,25,80 -PA21,23,80,3389 -PU -PO --traceroute "
|
||||||
alias nmap-regular="nmap "
|
alias nmap-regular="nmap "
|
||||||
alias nmap-comprehensive="sudo nmap -sS -sU -T4 -A -v -PE -PP -PS21,22,23,25,80,113,31339 -PA80,113,443,10042 -PO --script all "
|
alias nmap-comprehensive="sudo nmap -sS -sU -T4 -A -v -PE -PP -PS21,22,23,25,80,113,31339 -PA80,113,443,10042 -PO --script all "
|
||||||
# Little "safer" scan as connecting to only HTTP and HTTPS ports doesn't look so attacking. Copy-paste to .zsh_custom and remove " -p 80,443" if you want to scan all ports which nmap scans by default.
|
# Little "safer" scan as connecting to only HTTP and HTTPS ports doesn't look so attacking. Copy-paste to .zsh_custom and remove " -p 80,443" if you want to scan all ports which nmap scans by default.
|
||||||
alias nmap-osscan="sudo nmap -p 80,443 -O -v --osscan-guess --fuzzy "
|
alias nmap-osscan="sudo nmap -p 80,443 -O -v --osscan-guess --fuzzy "
|
||||||
|
|
||||||
@ -263,7 +263,7 @@ alias theme="prompt "
|
|||||||
|
|
||||||
# enable color support of ls and also add handy aliases
|
# enable color support of ls and also add handy aliases
|
||||||
if [[ $UNAME != Darwin ]]; then
|
if [[ $UNAME != Darwin ]]; then
|
||||||
alias ls='ls --color=always'
|
alias ls='ls --color=always'
|
||||||
fi
|
fi
|
||||||
alias dir='dir --color=always'
|
alias dir='dir --color=always'
|
||||||
alias vdir='vdir --color=always'
|
alias vdir='vdir --color=always'
|
||||||
@ -272,13 +272,13 @@ alias fgrep='fgrep -i --color=always'
|
|||||||
alias egrep='egrep -i --color=always'
|
alias egrep='egrep -i --color=always'
|
||||||
# some more ls aliases
|
# some more ls aliases
|
||||||
if [[ "$UNAME" != "Darwin" ]]; then
|
if [[ "$UNAME" != "Darwin" ]]; then
|
||||||
alias ll='ls -alFh --color=always' && alias la='ls -A --color=always' && alias l='ls -CF --color=always'
|
alias ll='ls -alFh --color=always' && alias la='ls -A --color=always' && alias l='ls -CF --color=always'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $UNAME = Darwin ]]; then
|
if [[ $UNAME = Darwin ]]; then
|
||||||
alias ls="ls -Gp"
|
alias ls="ls -Gp"
|
||||||
alias ll="ls -alFHGp"
|
alias ll="ls -alFHGp"
|
||||||
alias l="ls -CFGp"
|
alias l="ls -CFGp"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add an "alert" alias for long running commands. Use like so:
|
# Add an "alert" alias for long running commands. Use like so:
|
||||||
@ -305,13 +305,13 @@ alias rsync-folder="rsync -h --progress -azvv "
|
|||||||
|
|
||||||
# SSHGuard seems to prefer users to run this always when connecting with keys in ssh-agent...
|
# SSHGuard seems to prefer users to run this always when connecting with keys in ssh-agent...
|
||||||
#if [[ $UNAME != Darwin ]]; then
|
#if [[ $UNAME != Darwin ]]; then
|
||||||
# alias ssh-add="\ssh-add -D && \ssh-add "
|
# alias ssh-add="\ssh-add -D && \ssh-add "
|
||||||
#fi
|
#fi
|
||||||
|
|
||||||
# Use GPG2 instead of GPG!
|
# Use GPG2 instead of GPG!
|
||||||
if hash gpg2 2>/dev/null; then
|
if hash gpg2 2>/dev/null; then
|
||||||
alias gpg=gpg2
|
alias gpg=gpg2
|
||||||
export KEYBASE_GPG=gpg2
|
export KEYBASE_GPG=gpg2
|
||||||
fi
|
fi
|
||||||
alias gpg-fix-tty='export GPG_TTY=$(tty)'
|
alias gpg-fix-tty='export GPG_TTY=$(tty)'
|
||||||
|
|
||||||
@ -439,8 +439,8 @@ alias venv="python3 -m venv"
|
|||||||
# cp/mv using rsync. rcp appears to be link to scp in my system, so I can
|
# cp/mv using rsync. rcp appears to be link to scp in my system, so I can
|
||||||
# safely use this alias.
|
# safely use this alias.
|
||||||
if hash rsync 2>/dev/null; then
|
if hash rsync 2>/dev/null; then
|
||||||
alias rcp="rsync -a --progress"
|
alias rcp="rsync -a --progress"
|
||||||
alias rmv="rsync -a --progress --remove-source-files"
|
alias rmv="rsync -a --progress --remove-source-files"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clear apt list cache
|
# Clear apt list cache
|
||||||
@ -517,20 +517,20 @@ alias ssh-sign-file="ssh-keygen -Y sign -f ~/.ssh/signingkey.pub -n file"
|
|||||||
|
|
||||||
# .aliases
|
# .aliases
|
||||||
if [ -f ~/.aliases ]; then
|
if [ -f ~/.aliases ]; then
|
||||||
source ~/.aliases
|
source ~/.aliases
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# .zsh_aliases
|
# .zsh_aliases
|
||||||
if [ -f ~/.zsh_aliases ]; then
|
if [ -f ~/.zsh_aliases ]; then
|
||||||
source ~/.zsh_aliases
|
source ~/.zsh_aliases
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##### Functions ZGC5QQ #####
|
##### Functions ZGC5QQ #####
|
||||||
|
|
||||||
# GEOIP lookup, improved from the ultimate bashrc https://goo.gl/qGK5j
|
# GEOIP lookup, improved from the ultimate bashrc https://goo.gl/qGK5j
|
||||||
function geoip() {
|
function geoip() {
|
||||||
geoiplookup $1
|
geoiplookup $1
|
||||||
geoiplookup6 $1
|
geoiplookup6 $1
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: Is it bash or zshrc?
|
# TODO: Is it bash or zshrc?
|
||||||
@ -543,55 +543,55 @@ function ex ()
|
|||||||
{
|
{
|
||||||
if [ -f "$1" ] ; then
|
if [ -f "$1" ] ; then
|
||||||
case "$1" in
|
case "$1" in
|
||||||
*.tar) tar xvf $1 ;;
|
*.tar) tar xvf $1 ;;
|
||||||
*.tar.bz2 | *.tbz2 ) tar xjvf $1 ;;
|
*.tar.bz2 | *.tbz2 ) tar xjvf $1 ;;
|
||||||
*.tar.gz | *.tgz ) tar xzvf $1 ;;
|
*.tar.gz | *.tgz ) tar xzvf $1 ;;
|
||||||
*.bz2) bunzip2 $1 ;;
|
*.bz2) bunzip2 $1 ;;
|
||||||
*.rar) unrar x $1 ;;
|
*.rar) unrar x $1 ;;
|
||||||
*.gz) gunzip $1 ;;
|
*.gz) gunzip $1 ;;
|
||||||
*.zip) unzip $1 ;;
|
*.zip) unzip $1 ;;
|
||||||
*.Z) uncompress $1 ;;
|
*.Z) uncompress $1 ;;
|
||||||
*.7z) 7z x $1 ;;
|
*.7z) 7z x $1 ;;
|
||||||
*.xz) tar xJvf $1 ;;
|
*.xz) tar xJvf $1 ;;
|
||||||
*.deb)
|
*.deb)
|
||||||
DIR=${1%%_*.deb}
|
DIR=${1%%_*.deb}
|
||||||
ar xv $1
|
ar xv $1
|
||||||
mkdir ${DIR}
|
mkdir ${DIR}
|
||||||
tar -C ${DIR} -xzvf data.tar.gz ;;
|
tar -C ${DIR} -xzvf data.tar.gz ;;
|
||||||
*.rpm) rpm2cpio $1 | cpio -vid ;;
|
*.rpm) rpm2cpio $1 | cpio -vid ;;
|
||||||
*) echo ""${1}" cannot be extracted via extract()"
|
*) echo ""${1}" cannot be extracted via extract()"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
echo ""${1}" is not a valid file"
|
echo ""${1}" is not a valid file"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Given by nyuszika7h. Shortens GitHub URLs with git.io
|
# Given by nyuszika7h. Shortens GitHub URLs with git.io
|
||||||
function gitio() {
|
function gitio() {
|
||||||
curl -s -i https://git.io -F "url=$1" | grep --color=never -P '^Location: ' | awk '{ print $2 }'
|
curl -s -i https://git.io -F "url=$1" | grep --color=never -P '^Location: ' | awk '{ print $2 }'
|
||||||
}
|
}
|
||||||
|
|
||||||
function mkcd() {
|
function mkcd() {
|
||||||
if [[ $# -gt 1 ]]; then
|
if [[ $# -gt 1 ]]; then
|
||||||
echo 'Warning: All directories will be created, but will change to first specified directory.' 1>&2
|
echo 'Warning: All directories will be created, but will change to first specified directory.' 1>&2
|
||||||
fi
|
fi
|
||||||
mkdir -p "$*" && cd "$1"
|
mkdir -p "$*" && cd "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
function gribble-gpg-everify() {
|
function gribble-gpg-everify() {
|
||||||
# Set which command to use for gpg. You
|
# Set which command to use for gpg. You
|
||||||
# probably want to use gpg2 here.
|
# probably want to use gpg2 here.
|
||||||
local gpg=gpg2
|
local gpg=gpg2
|
||||||
|
|
||||||
echo -n 'Enter Bitcoin OTC URL: '
|
echo -n 'Enter Bitcoin OTC URL: '
|
||||||
read REPLY
|
read REPLY
|
||||||
lynx -hiddenlinks=ignore -dump $REPLY > bitcoin_otc.txt.asc
|
lynx -hiddenlinks=ignore -dump $REPLY > bitcoin_otc.txt.asc
|
||||||
$gpg --decrypt-file bitcoin_otc.txt.asc
|
$gpg --decrypt-file bitcoin_otc.txt.asc
|
||||||
echo -en '\e[1;32m;;everify '
|
echo -en '\e[1;32m;;everify '
|
||||||
cat bitcoin_otc.txt
|
cat bitcoin_otc.txt
|
||||||
echo -e '\e[0m'
|
echo -e '\e[0m'
|
||||||
rm -rf bitcoin_otc.txt bitcoin_otc.txt.asc
|
rm -rf bitcoin_otc.txt bitcoin_otc.txt.asc
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will install/upgrade shell-things.
|
# This function will install/upgrade shell-things.
|
||||||
@ -602,28 +602,28 @@ export SHELL_THINGS_REPO=$HOME/.shell-things
|
|||||||
|
|
||||||
# Check if ~/.shell-things exists and cd and pull.
|
# Check if ~/.shell-things exists and cd and pull.
|
||||||
if [ -d $SHELL_THINGS_REPO ]; then
|
if [ -d $SHELL_THINGS_REPO ]; then
|
||||||
echo "shell-things: $SHELL_THINGS_REPO exists, git pulling..."
|
echo "shell-things: $SHELL_THINGS_REPO exists, git pulling..."
|
||||||
echo ""
|
echo ""
|
||||||
cd $SHELL_THINGS_REPO
|
cd $SHELL_THINGS_REPO
|
||||||
git remote set-url origin https://gitea.blesmrt.net/Mikaela/shell-things.git
|
git remote set-url origin https://gitea.blesmrt.net/Mikaela/shell-things.git
|
||||||
git fetch --all
|
git fetch --all
|
||||||
git pull
|
git pull
|
||||||
git verify-commit HEAD
|
git verify-commit HEAD
|
||||||
sleep 10
|
sleep 10
|
||||||
echo ""
|
echo ""
|
||||||
echo "shell-things: Installing/Upgrading..."
|
echo "shell-things: Installing/Upgrading..."
|
||||||
echo ""
|
echo ""
|
||||||
# If it doesn't exist...
|
# If it doesn't exist...
|
||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
echo "shell-things: $SHELL_THINGS_REPO doesn't exist, cloning..."
|
echo "shell-things: $SHELL_THINGS_REPO doesn't exist, cloning..."
|
||||||
echo ""
|
echo ""
|
||||||
git clone https://gitea.blesmrt.net/Mikaela/shell-things.git $SHELL_THINGS_REPO
|
git clone https://gitea.blesmrt.net/Mikaela/shell-things.git $SHELL_THINGS_REPO
|
||||||
cd $SHELL_THINGS_REPO
|
cd $SHELL_THINGS_REPO
|
||||||
sleep 10
|
sleep 10
|
||||||
echo ""
|
echo ""
|
||||||
echo "shell-things: Installing/Upgrading..."
|
echo "shell-things: Installing/Upgrading..."
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Installing...
|
# Installing...
|
||||||
@ -645,13 +645,13 @@ cd
|
|||||||
function fix-node {
|
function fix-node {
|
||||||
|
|
||||||
if [[ $USER = "root" && -f /usr/bin/nodejs && ! -f /usr/bin/node && ! -f /usr/local/bin/node ]] then;
|
if [[ $USER = "root" && -f /usr/bin/nodejs && ! -f /usr/bin/node && ! -f /usr/local/bin/node ]] then;
|
||||||
ln -s /usr/bin/nodejs /usr/local/bin/node
|
ln -s /usr/bin/nodejs /usr/local/bin/node
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p $HOME/.local/bin
|
mkdir -p $HOME/.local/bin
|
||||||
|
|
||||||
if [[ -f /usr/bin/nodejs && ! -f /usr/bin/node && ! -f /usr/local/bin/node && ! -f $HOME/.local/bin/node ]] then;
|
if [[ -f /usr/bin/nodejs && ! -f /usr/bin/node && ! -f /usr/local/bin/node && ! -f $HOME/.local/bin/node ]] then;
|
||||||
ln -s /usr/bin/nodejs $HOME/.local/bin/node
|
ln -s /usr/bin/nodejs $HOME/.local/bin/node
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -659,128 +659,128 @@ fi
|
|||||||
# This function removes and regenerates ssh host keys.
|
# This function removes and regenerates ssh host keys.
|
||||||
|
|
||||||
#ssh-regen-host-keys () {
|
#ssh-regen-host-keys () {
|
||||||
# rm /etc/ssh/ssh_host_*
|
# rm /etc/ssh/ssh_host_*
|
||||||
# ssh-keygen -t rsa -N "" -f /etc/ssh/ssh_host_rsa_key
|
# ssh-keygen -t rsa -N "" -f /etc/ssh/ssh_host_rsa_key
|
||||||
# ssh-keygen -t ed25519 -N "" -f /etc/ssh/ssh_host_ed25519_key
|
# ssh-keygen -t ed25519 -N "" -f /etc/ssh/ssh_host_ed25519_key
|
||||||
#}
|
#}
|
||||||
|
|
||||||
# This function erases Master Boot Record from device
|
# This function erases Master Boot Record from device
|
||||||
# Note: this is dangerous so this function will echo the command
|
# Note: this is dangerous so this function will echo the command
|
||||||
# instad of running it!
|
# instad of running it!
|
||||||
#erase-mbr() {
|
#erase-mbr() {
|
||||||
# echo dd if=/dev/zero of=$1 bs=512 count=2
|
# echo dd if=/dev/zero of=$1 bs=512 count=2
|
||||||
#}
|
#}
|
||||||
|
|
||||||
# Use clang if installed. It seems interesting and this is probably good
|
# Use clang if installed. It seems interesting and this is probably good
|
||||||
# way to test it. This might not be a function, but I don't have any better
|
# way to test it. This might not be a function, but I don't have any better
|
||||||
# place for this.
|
# place for this.
|
||||||
if hash clang 2>/dev/null; then
|
if hash clang 2>/dev/null; then
|
||||||
export CC=clang
|
export CC=clang
|
||||||
export HOMEBREW_CC=clang
|
export HOMEBREW_CC=clang
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if hash clang++ 2>/dev/null; then
|
if hash clang++ 2>/dev/null; then
|
||||||
export CXX=clang++
|
export CXX=clang++
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add GitHub pull requests to fetched things via https://git.io/-C-0oQ
|
# Add GitHub pull requests to fetched things via https://git.io/-C-0oQ
|
||||||
github-add-pulls() {
|
github-add-pulls() {
|
||||||
git config --add remote.origin.fetch '+refs/pull/*/head:refs/remotes/origin/pr/*'
|
git config --add remote.origin.fetch '+refs/pull/*/head:refs/remotes/origin/pr/*'
|
||||||
git config --add remote.upstream.fetch '+refs/pull/*/head:refs/remotes/upstream/-pr/*'
|
git config --add remote.upstream.fetch '+refs/pull/*/head:refs/remotes/upstream/-pr/*'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get server SSL certificate fingerprint in MD5, SHA1 and SHA256.
|
# Get server SSL certificate fingerprint in MD5, SHA1 and SHA256.
|
||||||
# Note that OpenSSL doesn't support IPv6 at time of writing (2015-01-13).
|
# Note that OpenSSL doesn't support IPv6 at time of writing (2015-01-13).
|
||||||
serversslcertfp () {
|
serversslcertfp () {
|
||||||
SSSLCFFN=$(openssl s_client -showcerts -connect $1 < /dev/null)
|
SSSLCFFN=$(openssl s_client -showcerts -connect $1 < /dev/null)
|
||||||
# To see all validity information
|
# To see all validity information
|
||||||
echo "$SSSLCFFN"
|
echo "$SSSLCFFN"
|
||||||
# For getting the fingerprints
|
# For getting the fingerprints
|
||||||
echo "$SSSLCFFN" | openssl x509 -md5 -fingerprint -noout
|
echo "$SSSLCFFN" | openssl x509 -md5 -fingerprint -noout
|
||||||
echo "$SSSLCFFN" | openssl x509 -sha1 -fingerprint -noout
|
echo "$SSSLCFFN" | openssl x509 -sha1 -fingerprint -noout
|
||||||
echo "$SSSLCFFN" | openssl x509 -sha256 -fingerprint -noout
|
echo "$SSSLCFFN" | openssl x509 -sha256 -fingerprint -noout
|
||||||
echo "$SSSLCFFN" | openssl x509 -sha512 -fingerprint -noout
|
echo "$SSSLCFFN" | openssl x509 -sha512 -fingerprint -noout
|
||||||
unset SSSLCFFN
|
unset SSSLCFFN
|
||||||
}
|
}
|
||||||
|
|
||||||
# The same for local certificate file
|
# The same for local certificate file
|
||||||
sslcertfp () {
|
sslcertfp () {
|
||||||
cat $1 | openssl x509 -md5 -fingerprint -noout
|
cat $1 | openssl x509 -md5 -fingerprint -noout
|
||||||
cat $1 | openssl x509 -sha1 -fingerprint -noout
|
cat $1 | openssl x509 -sha1 -fingerprint -noout
|
||||||
cat $1 | openssl x509 -sha256 -fingerprint -noout
|
cat $1 | openssl x509 -sha256 -fingerprint -noout
|
||||||
cat $1 | openssl x509 -sha512 -fingerprint -noout
|
cat $1 | openssl x509 -sha512 -fingerprint -noout
|
||||||
}
|
}
|
||||||
|
|
||||||
# Usage: serversslciphers hostname port
|
# Usage: serversslciphers hostname port
|
||||||
serversslciphers() {
|
serversslciphers() {
|
||||||
nmap -Pn $1 -p $2 --script +ssl-enum-ciphers
|
nmap -Pn $1 -p $2 --script +ssl-enum-ciphers
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generate SSL certificate
|
# Generate SSL certificate
|
||||||
sslgenpem () {
|
sslgenpem () {
|
||||||
openssl req -nodes -newkey rsa:4096 -keyout $1.pem -x509 -days 3650 -out $1.pem -subj "/CN=$2"
|
openssl req -nodes -newkey rsa:4096 -keyout $1.pem -x509 -days 3650 -out $1.pem -subj "/CN=$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Managing SSL certificates of Google Chrome
|
# Managing SSL certificates of Google Chrome
|
||||||
chrome-add-cert () {
|
chrome-add-cert () {
|
||||||
echo "Please ensure that either libnss3-tools or nss-tools is installed."
|
echo "Please ensure that either libnss3-tools or nss-tools is installed."
|
||||||
certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n $1 -i $1
|
certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n $1 -i $1
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome-list-certs () {
|
chrome-list-certs () {
|
||||||
echo "Please ensure that either libnss3-tools or nss-tools is installed."
|
echo "Please ensure that either libnss3-tools or nss-tools is installed."
|
||||||
certutil -d sql:$HOME/.pki/nssdb -L # add '-h all' to see all built-in certs
|
certutil -d sql:$HOME/.pki/nssdb -L # add '-h all' to see all built-in certs
|
||||||
}
|
}
|
||||||
|
|
||||||
ssldownloadcert () {
|
ssldownloadcert () {
|
||||||
echo "Please ensure that either libnss3-tools or nss-tools is installed."
|
echo "Please ensure that either libnss3-tools or nss-tools is installed."
|
||||||
echo QUIT | openssl s_client -connect $1:443 | sed -ne '/BEGIN CERT/,/END CERT/p' | tee $1.pem
|
echo QUIT | openssl s_client -connect $1:443 | sed -ne '/BEGIN CERT/,/END CERT/p' | tee $1.pem
|
||||||
}
|
}
|
||||||
|
|
||||||
# Getting magnet from transmission-daemon
|
# Getting magnet from transmission-daemon
|
||||||
transmission-torrents () {
|
transmission-torrents () {
|
||||||
transmission-remote -l
|
transmission-remote -l
|
||||||
}
|
}
|
||||||
transmission-magnet () {
|
transmission-magnet () {
|
||||||
transmission-remote -l -t $1 -i | \grep magnet | awk -F': ' '{print $2}'
|
transmission-remote -l -t $1 -i | \grep magnet | awk -F': ' '{print $2}'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Merges the last $1 commits into one
|
# Merges the last $1 commits into one
|
||||||
git-squash () {
|
git-squash () {
|
||||||
git reset --soft HEAD~$1
|
git reset --soft HEAD~$1
|
||||||
git commit
|
git commit
|
||||||
}
|
}
|
||||||
|
|
||||||
# Combining mtrp4 & mtrp6
|
# Combining mtrp4 & mtrp6
|
||||||
mtrp() {
|
mtrp() {
|
||||||
mtrp4 $@
|
mtrp4 $@
|
||||||
mtrp6 $@
|
mtrp6 $@
|
||||||
}
|
}
|
||||||
|
|
||||||
# My IPv4 address
|
# My IPv4 address
|
||||||
myip4 () {
|
myip4 () {
|
||||||
if hash dig 2>/dev/null; then
|
if hash dig 2>/dev/null; then
|
||||||
dig +short myip.opendns.com. A @208.67.222.222
|
dig +short myip.opendns.com. A @208.67.222.222
|
||||||
else
|
else
|
||||||
curl -L4s https://icanhazip.com/
|
curl -L4s https://icanhazip.com/
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# My IPv6 address
|
# My IPv6 address
|
||||||
myip6 () {
|
myip6 () {
|
||||||
if hash dig 2>/dev/null; then
|
if hash dig 2>/dev/null; then
|
||||||
dig +short myip.opendns.com. AAAA @2620:0:ccc::2
|
dig +short myip.opendns.com. AAAA @2620:0:ccc::2
|
||||||
else
|
else
|
||||||
curl -L6s https://icanhazip.com/
|
curl -L6s https://icanhazip.com/
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Easier verifying of SSH signed files: ssh-verify-file whatever@mikaela.info file.txt
|
# Easier verifying of SSH signed files: ssh-verify-file whatever@mikaela.info file.txt
|
||||||
# It's assumed that signature of file.txt is called as file.txt.sig
|
# It's assumed that signature of file.txt is called as file.txt.sig
|
||||||
sshAllowedSigners=$HOME/src/gitea.blesmrt.net/Mikaela/ssh-allowed_signers/allowed_signers
|
sshAllowedSigners=$HOME/src/gitea.blesmrt.net/Mikaela/ssh-allowed_signers/allowed_signers
|
||||||
ssh-verify-file () {
|
ssh-verify-file () {
|
||||||
echo "$1 ${2:?Usage: ssh-verify-file <email> <file-to-verify>}" > /dev/null
|
echo "$1 ${2:?Usage: ssh-verify-file <email> <file-to-verify>}" > /dev/null
|
||||||
ssh-keygen -Y verify -f $sshAllowedSigners -I $1 -n file -s $2.sig < $2
|
ssh-keygen -Y verify -f $sshAllowedSigners -I $1 -n file -s $2.sig < $2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -788,20 +788,20 @@ ssh-verify-file () {
|
|||||||
|
|
||||||
# acme.sh
|
# acme.sh
|
||||||
if [ -f ~/.acme.sh/acme.sh.env ]; then
|
if [ -f ~/.acme.sh/acme.sh.env ]; then
|
||||||
source ~/.acme.sh/acme.sh.env
|
source ~/.acme.sh/acme.sh.env
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# .custom
|
# .custom
|
||||||
if [ -f ~/.custom ]; then
|
if [ -f ~/.custom ]; then
|
||||||
source ~/.custom
|
source ~/.custom
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# .zsh_custom
|
# .zsh_custom
|
||||||
if [ -f ~/.zsh_custom ]; then
|
if [ -f ~/.zsh_custom ]; then
|
||||||
source ~/.zsh_custom
|
source ~/.zsh_custom
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Warnings
|
# Warnings
|
||||||
if [ -f ~/.warnings ]; then
|
if [ -f ~/.warnings ]; then
|
||||||
source ~/.warnings
|
source ~/.warnings
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user