rc: retab

This commit is contained in:
Aminda Suomalainen 2023-02-15 13:29:55 +02:00
parent 5d42ef2539
commit b2b2689296
Signed by: Mikaela
SSH Key Fingerprint: SHA256:CXLULpqNBdUKB6E6fLA1b/4SzG0HvKD19PbIePU175Q
3 changed files with 367 additions and 367 deletions

382
rc/bashrc
View File

@ -1,18 +1,18 @@
UNAME=$(uname)
# TOC
# Defaults etc... M0TZLS
# Environment 7RS56S
# Aliases RJ706I
# Functions ZGC5QQ
# Defaults etc... M0TZLS
# Environment 7RS56S
# Aliases RJ706I
# Functions ZGC5QQ
# enable terminal bell
if [ -f /usr/bin/xset ];
then
(xset b on&)
(xset b on&)
fi
##### Defaults etc... M0TZLS #####
##### Defaults etc... M0TZLS #####
# ~/.bashrc: executed by bash(1) for non-login shells.
# 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)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
xterm-color) color_prompt=yes;;
esac
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if which tput >&/dev/null && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
if which tput >&/dev/null && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
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
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# Red colour for root, thanks nyuszika7h
# Red colour for root, thanks nyuszika7h
# Check if we're root
if [[ $EUID == 0 ]]; then
PS1='\033[1;31m\u@\h:\w\$\033[0m '
PS1='\033[1;31m\u@\h:\w\$\033[0m '
else
PS1='\033[1;32m\u@\h:\w\$\033[0m '
PS1='\033[1;32m\u@\h:\w\$\033[0m '
fi
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|*rxvt*)
PS1="\[\e]0;\u@\h: \w\a\]$PS1"
;;
PS1="\[\e]0;\u@\h: \w\a\]$PS1"
;;
*)
;;
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=always'
alias dir='dir --color=always'
alias vdir='vdir --color=always'
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=always'
alias dir='dir --color=always'
alias vdir='vdir --color=always'
alias grep='grep -i --color=always'
alias fgrep='fgrep -i --color=always'
alias egrep='egrep -i --color=always'
alias grep='grep -i --color=always'
alias fgrep='fgrep -i --color=always'
alias egrep='egrep -i --color=always'
fi
# some more ls aliases
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
if [[ $UNAME = Darwin ]]; then
alias ls="ls -Gp"
alias ll="ls -alFHGp"
alias l="ls -CFGp"
alias ls="ls -Gp"
alias ll="ls -alFHGp"
alias l="ls -CFGp"
fi
# 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 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.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
. /etc/bash_completion
fi
#Shopt settings.
@ -136,15 +136,15 @@ fi
(uptime&)
(echo "")
if [[ $UNAME != Darwin ]]; then
(who -H -w -u|head -n10&)
(echo "")
# (last -10 -w -x&)
(who -H -w -u|head -n10&)
(echo "")
# (last -10 -w -x&)
fi
if [[ $UNAME = Darwin ]]; then
(who -H -u|head -n10&)
(echo "")
(last -10&)
(who -H -u|head -n10&)
(echo "")
(last -10&)
fi
(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"
##### Environment 7RS56S #####
##### Environment 7RS56S #####
# Environment should be placed to .environment or .bash_environment.
# Source before mentioned locations if they exist.
# .environment
if [ -f ~/.environment ]; then
source ~/.environment
source ~/.environment
fi
# .bash_environment
if [ -f ~/.bash_environment ]; then
source ~/.bash_environment
source ~/.bash_environment
fi
# Enable core files.
(ulimit -c unlimited&)
# More colours
# More colours
if [[ $TERM == 'xterm' ]]; then
export TERM=xterm-256color
fi
if [[ $TERM == 'screen' ]]; then
export TERM=screen-256color
if [[ $TERM == 'screen' ]]; then
export TERM=screen-256color
fi
# 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
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
# Add RubyGems to PATH
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
# 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 [[ $USER = "root" ]]; then
mkdir -p /etc/apt/apt.conf.d/
echo 'Dpkg::Progress-Fancy "1";' > /etc/apt/apt.conf.d/99progressbar
echo 'APT::Color "1";' > /etc/apt/apt.conf.d/99color
mkdir -p /etc/apt/apt.conf.d/
echo 'Dpkg::Progress-Fancy "1";' > /etc/apt/apt.conf.d/99progressbar
echo 'APT::Color "1";' > /etc/apt/apt.conf.d/99color
fi
# 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
# installed or `sshcontrol` is trivial to remove.
if [ -f ~/.gnupg/sshcontrol ]; then
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent
gpg-connect-agent updatestartuptty /bye >/dev/null 2>&1
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent
gpg-connect-agent updatestartuptty /bye >/dev/null 2>&1
# otherwise use the normal ssh-agent
else
# 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)
export SSH_AUTH_SOCK=/tmp/$USER.sshagent
# 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)
export SSH_AUTH_SOCK=/tmp/$USER.sshagent
fi
# 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
#export HOSTNAME=$(hostname --fqdn)
##### Aliases RJ706I #####
##### Aliases RJ706I #####
# To get sudo work with aliases.
alias sudo="sudo "
@ -252,7 +252,7 @@ alias ..="cd .."
# Use htop instead of top if available
if hash htop 2>/dev/null; then
alias top="htop"
alias top="htop"
fi
# 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-traceroute="sudo nmap -sP -PE -PS22,25,80 -PA21,23,80,3389 -PU -PO --traceroute "
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.
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
if [[ $UNAME != Darwin ]]; then
alias ls='ls --color=always'
alias ls='ls --color=always'
fi
# some more ls aliases
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
## -- 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...
#if [[ $UNAME != Darwin ]]; then
# alias ssh-add="\ssh-add -D && \ssh-add "
# alias ssh-add="\ssh-add -D && \ssh-add "
#fi
# Use GPG2 instead of GPG!
if hash gpg2 2>/dev/null; then
alias gpg=gpg2
export KEYBASE_GPG=gpg2
alias gpg=gpg2
export KEYBASE_GPG=gpg2
fi
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
# safely use this alias.
if hash rsync 2>/dev/null; then
alias rcp="rsync -a --progress"
alias rmv="rsync -a --progress --remove-source-files"
alias rcp="rsync -a --progress"
alias rmv="rsync -a --progress --remove-source-files"
fi
# Clear apt list cache
@ -540,20 +540,20 @@ alias ssh-sign-file="ssh-keygen -Y sign -f ~/.ssh/signingkey.pub -n file"
# .aliases
if [ -f ~/.aliases ]; then
source ~/.aliases
source ~/.aliases
fi
# .bash_aliases
if [ -f ~/.bash_aliases ]; then
source ~/.bash_aliases
source ~/.bash_aliases
fi
##### Functions ZGC5QQ #####
##### Functions ZGC5QQ #####
# GEOIP lookup, improved from the ultimate bashrc https://goo.gl/qGK5j
function geoip() {
geoiplookup $1
geoiplookup6 $1
geoiplookup $1
geoiplookup6 $1
}
# TODO: Is it bash or zshrc?
@ -566,55 +566,55 @@ function ex ()
{
if [ -f "$1" ] ; then
case "$1" in
*.tar) tar xvf $1 ;;
*.tar.bz2 | *.tbz2 ) tar xjvf $1 ;;
*.tar.gz | *.tgz ) tar xzvf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*.xz) tar xJvf $1 ;;
*.deb)
DIR=${1%%_*.deb}
ar xv $1
mkdir ${DIR}
tar -C ${DIR} -xzvf data.tar.gz ;;
*.rpm) rpm2cpio $1 | cpio -vid ;;
*) echo ""${1}" cannot be extracted via extract()"
*.tar) tar xvf $1 ;;
*.tar.bz2 | *.tbz2 ) tar xjvf $1 ;;
*.tar.gz | *.tgz ) tar xzvf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*.xz) tar xJvf $1 ;;
*.deb)
DIR=${1%%_*.deb}
ar xv $1
mkdir ${DIR}
tar -C ${DIR} -xzvf data.tar.gz ;;
*.rpm) rpm2cpio $1 | cpio -vid ;;
*) echo ""${1}" cannot be extracted via extract()"
;;
esac
esac
else
echo ""${1}" is not a valid file"
echo ""${1}" is not a valid file"
fi
}
# Given by nyuszika7h. Shortens GitHub URLs with git.io
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() {
if [[ $# -gt 1 ]]; then
echo 'Warning: All directories will be created, but will change to first specified directory.' 1>&2
fi
mkdir -p "$*" && cd "$1"
if [[ $# -gt 1 ]]; then
echo 'Warning: All directories will be created, but will change to first specified directory.' 1>&2
fi
mkdir -p "$*" && cd "$1"
}
function gribble-gpg-everify() {
# Set which command to use for gpg. You
# probably want to use gpg2 here.
local gpg=gpg2
# Set which command to use for gpg. You
# probably want to use gpg2 here.
local gpg=gpg2
echo -n 'Enter Bitcoin OTC URL: '
read REPLY
lynx -hiddenlinks=ignore -dump $REPLY > bitcoin_otc.txt.asc
$gpg --decrypt-file bitcoin_otc.txt.asc
echo -en '\e[1;32m;;everify '
cat bitcoin_otc.txt
echo -e '\e[0m'
rm -rf bitcoin_otc.txt bitcoin_otc.txt.asc
echo -n 'Enter Bitcoin OTC URL: '
read REPLY
lynx -hiddenlinks=ignore -dump $REPLY > bitcoin_otc.txt.asc
$gpg --decrypt-file bitcoin_otc.txt.asc
echo -en '\e[1;32m;;everify '
cat bitcoin_otc.txt
echo -e '\e[0m'
rm -rf bitcoin_otc.txt bitcoin_otc.txt.asc
}
# 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.
if [ -d $SHELL_THINGS_REPO ]; then
echo "shell-things: $SHELL_THINGS_REPO exists, git pulling..."
echo ""
cd $SHELL_THINGS_REPO
git remote set-url origin https://gitea.blesmrt.net/Mikaela/shell-things.git
git fetch --all
git pull
git verify-commit HEAD
sleep 10
echo ""
echo "shell-things: Installing/Upgrading..."
echo ""
echo "shell-things: $SHELL_THINGS_REPO exists, git pulling..."
echo ""
cd $SHELL_THINGS_REPO
git remote set-url origin https://gitea.blesmrt.net/Mikaela/shell-things.git
git fetch --all
git pull
git verify-commit HEAD
sleep 10
echo ""
echo "shell-things: Installing/Upgrading..."
echo ""
# If it doesn't exist...
else
echo ""
echo "shell-things: $SHELL_THINGS_REPO doesn't exist, cloning..."
echo ""
git clone https://gitea.blesmrt.net/Mikaela/shell-things.git $SHELL_THINGS_REPO
cd $SHELL_THINGS_REPO
sleep 10
echo ""
echo "shell-things: Installing/Upgrading..."
echo ""
echo ""
echo "shell-things: $SHELL_THINGS_REPO doesn't exist, cloning..."
echo ""
git clone https://gitea.blesmrt.net/Mikaela/shell-things.git $SHELL_THINGS_REPO
cd $SHELL_THINGS_REPO
sleep 10
echo ""
echo "shell-things: Installing/Upgrading..."
echo ""
fi
# Installing...
@ -666,142 +666,142 @@ cd
# This function fixes nodejs on Debian based systems.
# (Everything expects nodejs to be called as node, but it's not with Debian.)
fix-node () {
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
fi
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
ln -s /usr/bin/nodejs $HOME/.local/bin/node
fi
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
fi
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
ln -s /usr/bin/nodejs $HOME/.local/bin/node
fi
}
# This function removes and regenerates ssh host keys.
#ssh-regen-host-keys () {
# rm /etc/ssh/ssh_host_*
# ssh-keygen -t rsa -N "" -f /etc/ssh/ssh_host_rsa_key
# ssh-keygen -t ed25519 -N "" -f /etc/ssh/ssh_host_ed25519_key
# rm /etc/ssh/ssh_host_*
# ssh-keygen -t rsa -N "" -f /etc/ssh/ssh_host_rsa_key
# ssh-keygen -t ed25519 -N "" -f /etc/ssh/ssh_host_ed25519_key
#}
# This function erases Master Boot Record from device
# Note: this is dangerous so this function will echo the command
# instad of running it!
#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
# way to test it. This might not be a function, but I don't have any better
# place for this.
if hash clang 2>/dev/null; then
export CC=clang
export HOMEBREW_CC=clang
export CC=clang
export HOMEBREW_CC=clang
fi
if hash clang++ 2>/dev/null; then
export CXX=clang++
export CXX=clang++
fi
# Add GitHub pull requests to fetched things via https://git.io/-C-0oQ
github-add-pulls() {
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.origin.fetch '+refs/pull/*/head:refs/remotes/origin/pr/*'
git config --add remote.upstream.fetch '+refs/pull/*/head:refs/remotes/upstream/-pr/*'
}
# Get server SSL certificate fingerprint in MD5, SHA1 and SHA256.
# Note that OpenSSL doesn't support IPv6 at time of writing (2015-01-13).
serversslcertfp () {
SSSLCFFN=$(openssl s_client -showcerts -connect $1 < /dev/null)
# To see all validity information
echo "$SSSLCFFN"
# For getting the fingerprints
echo "$SSSLCFFN" | openssl x509 -md5 -fingerprint -noout
echo "$SSSLCFFN" | openssl x509 -sha1 -fingerprint -noout
echo "$SSSLCFFN" | openssl x509 -sha256 -fingerprint -noout
echo "$SSSLCFFN" | openssl x509 -sha512 -fingerprint -noout
unset SSSLCFFN
SSSLCFFN=$(openssl s_client -showcerts -connect $1 < /dev/null)
# To see all validity information
echo "$SSSLCFFN"
# For getting the fingerprints
echo "$SSSLCFFN" | openssl x509 -md5 -fingerprint -noout
echo "$SSSLCFFN" | openssl x509 -sha1 -fingerprint -noout
echo "$SSSLCFFN" | openssl x509 -sha256 -fingerprint -noout
echo "$SSSLCFFN" | openssl x509 -sha512 -fingerprint -noout
unset SSSLCFFN
}
# The same for local certificate file
sslcertfp () {
cat $1 | openssl x509 -md5 -fingerprint -noout
cat $1 | openssl x509 -sha1 -fingerprint -noout
cat $1 | openssl x509 -sha256 -fingerprint -noout
cat $1 | openssl x509 -sha512 -fingerprint -noout
cat $1 | openssl x509 -md5 -fingerprint -noout
cat $1 | openssl x509 -sha1 -fingerprint -noout
cat $1 | openssl x509 -sha256 -fingerprint -noout
cat $1 | openssl x509 -sha512 -fingerprint -noout
}
# Usage: serversslciphers hostname port
serversslciphers() {
nmap -Pn $1 -p $2 --script +ssl-enum-ciphers
nmap -Pn $1 -p $2 --script +ssl-enum-ciphers
}
# Generate SSL certificate
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
chrome-add-cert () {
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
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
}
chrome-list-certs () {
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
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
}
ssldownloadcert () {
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 "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
}
# Getting magnet from transmission-daemon
transmission-torrents () {
transmission-remote -l
transmission-remote -l
}
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
git-squash () {
git reset --soft HEAD~$1
git commit
git reset --soft HEAD~$1
git commit
}
# Combining mtrp4 & mtrp6
mtrp() {
mtrp4 $@
mtrp6 $@
mtrp4 $@
mtrp6 $@
}
# My IPv4 address
myip4 () {
if hash dig 2>/dev/null; then
dig +short myip.opendns.com. A @208.67.222.222
else
curl -L4s https://icanhazip.com/
fi
if hash dig 2>/dev/null; then
dig +short myip.opendns.com. A @208.67.222.222
else
curl -L4s https://icanhazip.com/
fi
}
# My IPv6 address
myip6 () {
if hash dig 2>/dev/null; then
dig +short myip.opendns.com. AAAA @2620:0:ccc::2
else
curl -L6s https://icanhazip.com/
fi
if hash dig 2>/dev/null; then
dig +short myip.opendns.com. AAAA @2620:0:ccc::2
else
curl -L6s https://icanhazip.com/
fi
}
# 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
sshAllowedSigners=$HOME/src/gitea.blesmrt.net/Mikaela/ssh-allowed_signers/allowed_signers
ssh-verify-file () {
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
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
}
@ -809,15 +809,15 @@ ssh-verify-file () {
# acme.sh
if [ -f ~/.acme.sh/acme.sh.env ]; then
source ~/.acme.sh/acme.sh.env
source ~/.acme.sh/acme.sh.env
fi
# .custom
if [ -f ~/.custom ]; then
source ~/.custom
source ~/.custom
fi
# .bash_custom
if [ -f ~/.bash_custom ]; then
source ~/.bash_custom
source ~/.bash_custom
fi

View File

@ -3,7 +3,7 @@ PATH=$HOME/.local/bin:$HOME/bin:$HOME/go/bin:$HOME/.local/share/flatpak/exports/
# Add RubyGems to PATH
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
# Set compose to menu, kill X with ctrl-alt-backspace,
@ -22,7 +22,7 @@ ulimit -c unlimited
# Numlock on at boot
if hash numlockx 2>/dev/null; then
numlockx on
numlockx on
fi
# 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...
if [ -f ~/.environment ]; then
. ~/.environment
. ~/.environment
fi
# Something that scripts here won't attempt to overwrite
if [ -f ~/.environment2 ]; then
. ~/.environment2
. ~/.environment2
fi

344
rc/zshrc
View File

@ -1,10 +1,10 @@
# TOC
# Defaults etc... M0TZLS
# Environment 7RS56S
# Aliases RJ706I
# Functions ZGC5QQ
# Defaults etc... M0TZLS
# Environment 7RS56S
# Aliases RJ706I
# Functions ZGC5QQ
# uname should be readable in $uname
# uname should be readable in $uname
uname=$(uname)
UNAME=$(uname)
@ -13,16 +13,16 @@ UNAME=$(uname)
#case $TERM in
# (*xterm* | *rxvt*)
# Write some info to terminal title.
# This is seen when the shell prompts for input.
# function precmd {
# print -Pn "\e]0;zsh%L %(1j,%j job%(2j|s|); ,)%~\a"
# }
# Write command and args to terminal title.
# This is seen while the shell waits for a command to complete.
# function preexec {
# printf "\033]0;%s\a" "$1"
# }
# Write some info to terminal title.
# This is seen when the shell prompts for input.
# function precmd {
# print -Pn "\e]0;zsh%L %(1j,%j job%(2j|s|); ,)%~\a"
# }
# Write command and args to terminal title.
# This is seen while the shell waits for a command to complete.
# function preexec {
# printf "\033]0;%s\a" "$1"
# }
#
# ;;
#esac
@ -31,10 +31,10 @@ UNAME=$(uname)
if [[ -f /usr/bin/xset ]];
then
(xset b on&)
(xset b on&)
fi
##### Defaults etc... M0TZLS #####
##### Defaults etc... M0TZLS #####
# This is based on zshrc which came with Debian (Third option in wizard for new users.)
@ -53,9 +53,9 @@ autoload -Uz promptinit
promptinit
if [ $USER = "root" ]; then
prompt elite2 red
prompt elite2 red
else
prompt elite2 green
prompt elite2 green
fi
# 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:*' menu select=2
if [[ $UNAME != Darwin ]]; then
eval "$(dircolors -b)"
eval "$(dircolors -b)"
fi
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-colors ''
@ -90,52 +90,52 @@ zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
(uptime&)
(echo "")
if [[ $UNAME != Darwin ]] then;
(who -H -w -u|head -n10&)
(echo "")
# (last -10 -w -x&)
if [[ $UNAME != Darwin ]] then;
(who -H -w -u|head -n10&)
(echo "")
# (last -10 -w -x&)
fi
if [[ $UNAME = Darwin ]]; then
(who -H -u|head -n10&)
(echo "")
(last -10&)
(who -H -u|head -n10&)
(echo "")
(last -10&)
fi
(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
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).
# Source before mentioned locations if they exist.
# .environment
if [ -f ~/.environment ]; then
source ~/.environment
source ~/.environment
fi
# .zsh_environment
if [ -f ~/.zsh_environment ]; then
source ~/.zsh_environment
source ~/.zsh_environment
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).
if [ -f ~/.zshenv ]; then
source ~/.zshenv
source ~/.zshenv
fi
# Enable core files.
(ulimit -c unlimited&)
# More colours
# More colours
if [[ $TERM == 'xterm' ]]; then
export TERM=xterm-256color
fi
if [[ $TERM == 'screen' ]]; then
export TERM=screen-256color
if [[ $TERM == 'screen' ]]; then
export TERM=screen-256color
fi
# Sets the default editor.
@ -144,12 +144,12 @@ fi
# Set TZ to local timezone for sending over SSH
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
# Add RubyGems to PATH
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
# 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
# installed or `sshcontrol` is trivial to remove.
if [ -f ~/.gnupg/sshcontrol ]; then
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent
gpg-connect-agent updatestartuptty /bye >/dev/null 2>&1
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent
gpg-connect-agent updatestartuptty /bye >/dev/null 2>&1
# otherwise use the normal ssh-agent
else
# 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)
export SSH_AUTH_SOCK=/tmp/$USER.sshagent
# 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)
export SSH_AUTH_SOCK=/tmp/$USER.sshagent
fi
# If we are on Linux, enable apt progress bar and colours
if [[ $USER = "root" ]]; then
mkdir -p /etc/apt/apt.conf.d/
echo 'Dpkg::Progress-Fancy "1";' > /etc/apt/apt.conf.d/99progressbar
echo 'APT::Color "1";' > /etc/apt/apt.conf.d/99color
mkdir -p /etc/apt/apt.conf.d/
echo 'Dpkg::Progress-Fancy "1";' > /etc/apt/apt.conf.d/99progressbar
echo 'APT::Color "1";' > /etc/apt/apt.conf.d/99color
fi
# 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
#export HOSTNAME=$(hostname --fqdn)
##### Aliases RJ706I #####
##### Aliases RJ706I #####
# To get sudo work with aliases.
alias sudo="sudo "
@ -208,7 +208,7 @@ alias ..="cd .."
# Use htop instead of top if available
if hash htop 2>/dev/null; then
alias top="htop"
alias top="htop"
fi
# 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-traceroute="sudo nmap -sP -PE -PS22,25,80 -PA21,23,80,3389 -PU -PO --traceroute "
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.
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
if [[ $UNAME != Darwin ]]; then
alias ls='ls --color=always'
alias ls='ls --color=always'
fi
alias dir='dir --color=always'
alias vdir='vdir --color=always'
@ -272,13 +272,13 @@ alias fgrep='fgrep -i --color=always'
alias egrep='egrep -i --color=always'
# some more ls aliases
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
if [[ $UNAME = Darwin ]]; then
alias ls="ls -Gp"
alias ll="ls -alFHGp"
alias l="ls -CFGp"
alias ls="ls -Gp"
alias ll="ls -alFHGp"
alias l="ls -CFGp"
fi
# 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...
#if [[ $UNAME != Darwin ]]; then
# alias ssh-add="\ssh-add -D && \ssh-add "
# alias ssh-add="\ssh-add -D && \ssh-add "
#fi
# Use GPG2 instead of GPG!
if hash gpg2 2>/dev/null; then
alias gpg=gpg2
export KEYBASE_GPG=gpg2
alias gpg=gpg2
export KEYBASE_GPG=gpg2
fi
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
# safely use this alias.
if hash rsync 2>/dev/null; then
alias rcp="rsync -a --progress"
alias rmv="rsync -a --progress --remove-source-files"
alias rcp="rsync -a --progress"
alias rmv="rsync -a --progress --remove-source-files"
fi
# Clear apt list cache
@ -517,20 +517,20 @@ alias ssh-sign-file="ssh-keygen -Y sign -f ~/.ssh/signingkey.pub -n file"
# .aliases
if [ -f ~/.aliases ]; then
source ~/.aliases
source ~/.aliases
fi
# .zsh_aliases
if [ -f ~/.zsh_aliases ]; then
source ~/.zsh_aliases
source ~/.zsh_aliases
fi
##### Functions ZGC5QQ #####
##### Functions ZGC5QQ #####
# GEOIP lookup, improved from the ultimate bashrc https://goo.gl/qGK5j
function geoip() {
geoiplookup $1
geoiplookup6 $1
geoiplookup $1
geoiplookup6 $1
}
# TODO: Is it bash or zshrc?
@ -543,55 +543,55 @@ function ex ()
{
if [ -f "$1" ] ; then
case "$1" in
*.tar) tar xvf $1 ;;
*.tar.bz2 | *.tbz2 ) tar xjvf $1 ;;
*.tar.gz | *.tgz ) tar xzvf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*.xz) tar xJvf $1 ;;
*.deb)
DIR=${1%%_*.deb}
ar xv $1
mkdir ${DIR}
tar -C ${DIR} -xzvf data.tar.gz ;;
*.rpm) rpm2cpio $1 | cpio -vid ;;
*) echo ""${1}" cannot be extracted via extract()"
*.tar) tar xvf $1 ;;
*.tar.bz2 | *.tbz2 ) tar xjvf $1 ;;
*.tar.gz | *.tgz ) tar xzvf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*.xz) tar xJvf $1 ;;
*.deb)
DIR=${1%%_*.deb}
ar xv $1
mkdir ${DIR}
tar -C ${DIR} -xzvf data.tar.gz ;;
*.rpm) rpm2cpio $1 | cpio -vid ;;
*) echo ""${1}" cannot be extracted via extract()"
;;
esac
esac
else
echo ""${1}" is not a valid file"
echo ""${1}" is not a valid file"
fi
}
# Given by nyuszika7h. Shortens GitHub URLs with git.io
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() {
if [[ $# -gt 1 ]]; then
echo 'Warning: All directories will be created, but will change to first specified directory.' 1>&2
fi
mkdir -p "$*" && cd "$1"
if [[ $# -gt 1 ]]; then
echo 'Warning: All directories will be created, but will change to first specified directory.' 1>&2
fi
mkdir -p "$*" && cd "$1"
}
function gribble-gpg-everify() {
# Set which command to use for gpg. You
# probably want to use gpg2 here.
local gpg=gpg2
# Set which command to use for gpg. You
# probably want to use gpg2 here.
local gpg=gpg2
echo -n 'Enter Bitcoin OTC URL: '
read REPLY
lynx -hiddenlinks=ignore -dump $REPLY > bitcoin_otc.txt.asc
$gpg --decrypt-file bitcoin_otc.txt.asc
echo -en '\e[1;32m;;everify '
cat bitcoin_otc.txt
echo -e '\e[0m'
rm -rf bitcoin_otc.txt bitcoin_otc.txt.asc
echo -n 'Enter Bitcoin OTC URL: '
read REPLY
lynx -hiddenlinks=ignore -dump $REPLY > bitcoin_otc.txt.asc
$gpg --decrypt-file bitcoin_otc.txt.asc
echo -en '\e[1;32m;;everify '
cat bitcoin_otc.txt
echo -e '\e[0m'
rm -rf bitcoin_otc.txt bitcoin_otc.txt.asc
}
# 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.
if [ -d $SHELL_THINGS_REPO ]; then
echo "shell-things: $SHELL_THINGS_REPO exists, git pulling..."
echo ""
cd $SHELL_THINGS_REPO
git remote set-url origin https://gitea.blesmrt.net/Mikaela/shell-things.git
git fetch --all
git pull
git verify-commit HEAD
sleep 10
echo ""
echo "shell-things: Installing/Upgrading..."
echo ""
echo "shell-things: $SHELL_THINGS_REPO exists, git pulling..."
echo ""
cd $SHELL_THINGS_REPO
git remote set-url origin https://gitea.blesmrt.net/Mikaela/shell-things.git
git fetch --all
git pull
git verify-commit HEAD
sleep 10
echo ""
echo "shell-things: Installing/Upgrading..."
echo ""
# If it doesn't exist...
else
echo ""
echo "shell-things: $SHELL_THINGS_REPO doesn't exist, cloning..."
echo ""
git clone https://gitea.blesmrt.net/Mikaela/shell-things.git $SHELL_THINGS_REPO
cd $SHELL_THINGS_REPO
sleep 10
echo ""
echo "shell-things: Installing/Upgrading..."
echo ""
echo ""
echo "shell-things: $SHELL_THINGS_REPO doesn't exist, cloning..."
echo ""
git clone https://gitea.blesmrt.net/Mikaela/shell-things.git $SHELL_THINGS_REPO
cd $SHELL_THINGS_REPO
sleep 10
echo ""
echo "shell-things: Installing/Upgrading..."
echo ""
fi
# Installing...
@ -645,13 +645,13 @@ cd
function fix-node {
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
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;
ln -s /usr/bin/nodejs $HOME/.local/bin/node
ln -s /usr/bin/nodejs $HOME/.local/bin/node
fi
}
@ -659,128 +659,128 @@ fi
# This function removes and regenerates ssh host keys.
#ssh-regen-host-keys () {
# rm /etc/ssh/ssh_host_*
# ssh-keygen -t rsa -N "" -f /etc/ssh/ssh_host_rsa_key
# ssh-keygen -t ed25519 -N "" -f /etc/ssh/ssh_host_ed25519_key
# rm /etc/ssh/ssh_host_*
# ssh-keygen -t rsa -N "" -f /etc/ssh/ssh_host_rsa_key
# ssh-keygen -t ed25519 -N "" -f /etc/ssh/ssh_host_ed25519_key
#}
# This function erases Master Boot Record from device
# Note: this is dangerous so this function will echo the command
# instad of running it!
#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
# way to test it. This might not be a function, but I don't have any better
# place for this.
if hash clang 2>/dev/null; then
export CC=clang
export HOMEBREW_CC=clang
export CC=clang
export HOMEBREW_CC=clang
fi
if hash clang++ 2>/dev/null; then
export CXX=clang++
export CXX=clang++
fi
# Add GitHub pull requests to fetched things via https://git.io/-C-0oQ
github-add-pulls() {
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.origin.fetch '+refs/pull/*/head:refs/remotes/origin/pr/*'
git config --add remote.upstream.fetch '+refs/pull/*/head:refs/remotes/upstream/-pr/*'
}
# Get server SSL certificate fingerprint in MD5, SHA1 and SHA256.
# Note that OpenSSL doesn't support IPv6 at time of writing (2015-01-13).
serversslcertfp () {
SSSLCFFN=$(openssl s_client -showcerts -connect $1 < /dev/null)
# To see all validity information
echo "$SSSLCFFN"
# For getting the fingerprints
echo "$SSSLCFFN" | openssl x509 -md5 -fingerprint -noout
echo "$SSSLCFFN" | openssl x509 -sha1 -fingerprint -noout
echo "$SSSLCFFN" | openssl x509 -sha256 -fingerprint -noout
echo "$SSSLCFFN" | openssl x509 -sha512 -fingerprint -noout
unset SSSLCFFN
SSSLCFFN=$(openssl s_client -showcerts -connect $1 < /dev/null)
# To see all validity information
echo "$SSSLCFFN"
# For getting the fingerprints
echo "$SSSLCFFN" | openssl x509 -md5 -fingerprint -noout
echo "$SSSLCFFN" | openssl x509 -sha1 -fingerprint -noout
echo "$SSSLCFFN" | openssl x509 -sha256 -fingerprint -noout
echo "$SSSLCFFN" | openssl x509 -sha512 -fingerprint -noout
unset SSSLCFFN
}
# The same for local certificate file
sslcertfp () {
cat $1 | openssl x509 -md5 -fingerprint -noout
cat $1 | openssl x509 -sha1 -fingerprint -noout
cat $1 | openssl x509 -sha256 -fingerprint -noout
cat $1 | openssl x509 -sha512 -fingerprint -noout
cat $1 | openssl x509 -md5 -fingerprint -noout
cat $1 | openssl x509 -sha1 -fingerprint -noout
cat $1 | openssl x509 -sha256 -fingerprint -noout
cat $1 | openssl x509 -sha512 -fingerprint -noout
}
# Usage: serversslciphers hostname port
serversslciphers() {
nmap -Pn $1 -p $2 --script +ssl-enum-ciphers
nmap -Pn $1 -p $2 --script +ssl-enum-ciphers
}
# Generate SSL certificate
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
chrome-add-cert () {
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
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
}
chrome-list-certs () {
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
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
}
ssldownloadcert () {
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 "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
}
# Getting magnet from transmission-daemon
transmission-torrents () {
transmission-remote -l
transmission-remote -l
}
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
git-squash () {
git reset --soft HEAD~$1
git commit
git reset --soft HEAD~$1
git commit
}
# Combining mtrp4 & mtrp6
mtrp() {
mtrp4 $@
mtrp6 $@
mtrp4 $@
mtrp6 $@
}
# My IPv4 address
myip4 () {
if hash dig 2>/dev/null; then
dig +short myip.opendns.com. A @208.67.222.222
else
curl -L4s https://icanhazip.com/
fi
if hash dig 2>/dev/null; then
dig +short myip.opendns.com. A @208.67.222.222
else
curl -L4s https://icanhazip.com/
fi
}
# My IPv6 address
myip6 () {
if hash dig 2>/dev/null; then
dig +short myip.opendns.com. AAAA @2620:0:ccc::2
else
curl -L6s https://icanhazip.com/
fi
if hash dig 2>/dev/null; then
dig +short myip.opendns.com. AAAA @2620:0:ccc::2
else
curl -L6s https://icanhazip.com/
fi
}
# 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
sshAllowedSigners=$HOME/src/gitea.blesmrt.net/Mikaela/ssh-allowed_signers/allowed_signers
ssh-verify-file () {
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
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
}
@ -788,20 +788,20 @@ ssh-verify-file () {
# acme.sh
if [ -f ~/.acme.sh/acme.sh.env ]; then
source ~/.acme.sh/acme.sh.env
source ~/.acme.sh/acme.sh.env
fi
# .custom
if [ -f ~/.custom ]; then
source ~/.custom
source ~/.custom
fi
# .zsh_custom
if [ -f ~/.zsh_custom ]; then
source ~/.zsh_custom
source ~/.zsh_custom
fi
# Warnings
if [ -f ~/.warnings ]; then
source ~/.warnings
source ~/.warnings
fi