mirror of
https://gitea.blesmrt.net/mikaela/shell-things.git
synced 2024-11-25 20:59:23 +01:00
6b58452ff1
Also copied full comments, which bioterror had added. Also (what is "omistuskirjoitus" in English) was copied.
89 lines
2.8 KiB
Plaintext
89 lines
2.8 KiB
Plaintext
# This file contains functions of my zshrc. You probably don't need to edit anything here.
|
|
#
|
|
# Most of things here are originally from bash.
|
|
#
|
|
# To disable function, just comment everything after description.
|
|
|
|
# GEOIP lookup, copied from the ultimate bashrc http://goo.gl/qGK5j
|
|
function geoip() {
|
|
geoiplookup $1
|
|
}
|
|
|
|
# MYIP, copied from the ultimate bashrc http://goo.gl/qGK5j . I think that it requires lynx.
|
|
function myip()
|
|
{
|
|
lynx -dump -hiddenlinks=ignore -nolist http://checkip.dyndns.org:8245/ | awk '{ print $4 }' | sed '/^$/d; s/^[ ]*//g; s/[ ]*$//g'
|
|
}
|
|
|
|
# Checks which package the command comes from. Copied from the ultimate bashrc http://goo.gl/qGK5j
|
|
function cmdpkg() { PACKAGE=$(dpkg -S $(which $1) | cut -d':' -f1); echo "[${PACKAGE}]"; dpkg -s "${PACKAGE}" ;}
|
|
|
|
# ROT13, copied from the ultimate bashrc http://goo.gl/qGK5j
|
|
function rot13()
|
|
{
|
|
if [ $# -lt 1 ] || [ $# -gt 1 ]; then
|
|
echo "Seriously? You don't know what rot13 does?"
|
|
else
|
|
echo $@ | tr A-Za-z N-ZA-Mn-za-m
|
|
fi
|
|
}
|
|
|
|
# Down for everyone or just me? Copied from the ultimate bashrc http://goo.gl/qGK5j
|
|
function downforme() {
|
|
RED='\e[1;31m'
|
|
GREEN='\e[1;32m'
|
|
YELLOW='\e[1;33m'
|
|
NC='\e[0m'
|
|
if [ $# = 0 ]
|
|
then
|
|
echo -e "${YELLOW}usage:${NC} downforme website_url"
|
|
else
|
|
JUSTYOUARRAY=(`lynx -dump http://downforeveryoneorjustme.com/$1 | grep -o "It's just you"`)
|
|
if [ ${#JUSTYOUARRAY} != 0 ]
|
|
then
|
|
echo -e "${RED}It's just you. \n${NC}$1 is up."
|
|
else
|
|
echo -e "${GREEN}It's not just you! \n${NC}$1 looks down from here."
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# Topt10 commands, copied from the ultimate bashrc http://goo.gl/qGK5j
|
|
function top10() {
|
|
# copyright 2007 - 2010 Christopher Bratusek
|
|
history | awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}' | sort -rn | head
|
|
}
|
|
|
|
# ex command. Copied from zshrc of bioterror ( http://ricecows.org/configs/zsh/.zshrc ). Original comment below:
|
|
## for unit193 ;)
|
|
## use command "ex" to extract any archive files.
|
|
## "ex package.zip" for example
|
|
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()"
|
|
;;
|
|
esac
|
|
else
|
|
echo ""${1}" is not a valid file"
|
|
fi
|
|
}
|