2011-10-29 09:50:56 +02:00
# TOC
# Defaults etc... M0TZLS
# Environment 7RS56S
# Aliases RJ706I
# Functions ZGC5QQ
2012-09-16 14:27:48 +02:00
# uname should be readable in $uname
2014-05-22 10:31:14 +02:00
uname = $( uname)
2014-05-29 14:39:41 +02:00
UNAME = $( uname)
2012-09-16 14:27:48 +02:00
2014-01-22 21:08:38 +01:00
# enable terminal bell
2014-09-19 23:08:16 +02:00
if [ [ -f /usr/bin/xset ] ] ;
2014-01-22 21:08:38 +01:00
then
2014-05-29 15:02:08 +02:00
( xset b on& )
2014-01-22 21:08:38 +01:00
fi
2011-10-29 09:50:56 +02:00
##### Defaults etc... M0TZLS #####
2011-09-29 14:25:05 +02:00
# This is based on zshrc which came with Debian (Third option in wizard for new users.)
2014-10-07 07:41:24 +02:00
# Save history
export HISTSIZE = 99999
export SAVEHIST = $HISTSIZE
setopt hist_ignore_all_dups
export HISTFILE = ~/.zsh_history
setopt INC_APPEND_HISTORY
setopt SHARE_HISTORY
2011-09-29 14:25:05 +02:00
# Set up the prompt
autoload -Uz promptinit
2013-02-09 15:46:22 +01:00
# Green for normal user and red for root and show exit status
# if it's not 0. Thank you nyuszika7h
2011-09-29 14:25:05 +02:00
promptinit
2013-02-09 15:46:22 +01:00
autoload -Uz vcs_info
autoload -Uz colors && colors
setopt PROMPT_SUBST
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' enable git svn bzr hg
zstyle ':vcs_info:*' formats '%b '
precmd( ) { vcs_info }
2011-10-22 19:44:51 +02:00
PS1 = " %B%(!.%F{red}.%F{green})%n@%m %~
2014-01-17 12:27:46 +01:00
%# %( ?..%B%?%b ) %f%b"
2011-09-29 14:25:05 +02:00
# Use emacs keybindings even if our EDITOR is set to vi
bindkey -e
# Use modern completion system
autoload -Uz compinit
compinit
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete _correct _approximate
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' menu select = 2
2012-12-25 10:32:36 +01:00
if [ [ $UNAME != Darwin ] ] ; then
2012-12-24 19:04:14 +01:00
eval " $( dircolors -b) "
fi
2011-09-29 14:25:05 +02:00
zstyle ':completion:*:default' list-colors ${ (s. : .)LS_COLORS }
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' menu select = long
zstyle ':completion:*' select -prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
2013-02-16 08:56:00 +01:00
# Show the hostname, uptime and users logged in on shell start
2014-05-23 08:49:50 +02:00
( hostname& )
( uptime& )
( echo "" )
2014-05-01 13:50:14 +02:00
2013-02-17 08:11:44 +01:00
if [ [ $UNAME != Darwin ] ] then ;
2014-05-23 08:49:50 +02:00
( who -H -w -u| head -n10& )
( echo "" )
( last -10 -w -x& )
2013-02-17 08:11:44 +01:00
fi
2012-08-06 19:04:58 +02:00
2014-05-01 13:50:14 +02:00
if [ [ $UNAME = Darwin ] ] ; then
2014-05-23 08:49:50 +02:00
( who -H -u| head -n10& )
( echo "" )
( last -10& )
2014-05-01 13:50:14 +02:00
fi
2011-10-29 09:50:56 +02:00
##### 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
fi
# .zsh_environment
if [ -f ~/.zsh_environment ] ; then
source ~/.zsh_environment
2011-10-01 15:32:18 +02:00
fi
2011-10-29 09:50:56 +02:00
# .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).
2011-10-01 15:32:18 +02:00
if [ -f ~/.zshenv ] ; then
source ~/.zshenv
fi
2012-09-16 14:24:34 +02:00
# Enable core files.
2014-05-29 15:02:08 +02:00
( ulimit -c unlimited& )
2012-09-16 14:24:34 +02:00
2012-12-21 13:24:44 +01:00
#More colours
2011-12-29 10:18:28 +01:00
if [ [ $TERM = = 'xterm' ] ] ; then
export TERM = xterm-256color
fi
2011-12-29 10:20:01 +01:00
if [ [ $TERM = = 'screen' ] ] ; then
export TERM = screen-256color
fi
2012-04-30 18:12:20 +02:00
# Sets the default editor.
2014-10-09 19:25:11 +02:00
#export EDITOR=vim # MIKAELA_GREP # MIKAELA_GREP_ENVIRONMENT
2011-10-29 09:50:56 +02:00
# Sets locale. You can get list of locales with "locale -a" command. This should be something which ends to .utf8
2014-10-09 19:25:11 +02:00
#export LC_ALL=fi_FI.UTF-8 # MIKAELA_GREP # MIKAELA_GREP_ENVIRONMENT
2011-10-29 09:50:56 +02:00
# Sets your timezone. Set in format <Region/City>, or just timezone like UTC.
2014-10-09 19:25:11 +02:00
# export TZ="Europe/Helsinki" # MIKAELA_GREP # MIKAELA_GREP_ENVIRONMENT
2011-10-29 09:50:56 +02:00
2014-04-29 14:23:54 +02:00
# pyenv (Source: their README.md file http://git.io/ReCDSQ )
export PYENV_ROOT = " $HOME /.pyenv "
2014-04-30 20:53:00 +02:00
alias pyenv-install= "\wget -O /tmp/pyenv-installer https://raw.github.com/yyuu/pyenv-installer/master/bin/pyenv-installer;chmod +x /tmp/pyenv-installer;/tmp/pyenv-installer;rm /tmp/pyenv-installer"
2014-04-29 14:47:53 +02:00
alias pyenv-install-alt= " cd ~;git clone https://github.com/yyuu/pyenv.git $PYENV_ROOT "
2014-04-29 14:23:54 +02:00
2011-10-29 09:50:56 +02:00
# Sets PATH. To add another path, add :</path/to/new/path> to string below.
2014-11-02 20:49:11 +01:00
PATH = $HOME /.local/bin:$HOME /.local/sbin:$HOME /.local/games:$HOME /bin:$HOME /sbin:$HOME /games:$PYENV_ROOT /shims:$PYENV_ROOT /bin:/usr/local/bin:/usr/local/sbin:/usr/local/games:/usr/bin:/usr/sbin:/usr/games:/bin:/sbin:/games:$PATH
2014-04-29 14:23:54 +02:00
2014-05-29 19:28:25 +02:00
# Removes duplicates from $PATH. Copied from http://unix.stackexchange.com/a/14896
2014-06-15 09:03:20 +02:00
PATH = $( echo " $PATH " | awk -v RS = ':' -v ORS = ":" '!a[$1]++{if (NR > 1) printf ORS; printf $a[$1]}' )
2014-05-29 19:28:25 +02:00
2014-04-29 14:23:54 +02:00
# Apply pyenv changes.
2014-04-29 14:29:50 +02:00
if [ -d " $PYENV_ROOT " ] ; then
eval " $( pyenv init -) "
fi
2011-10-29 09:50:56 +02:00
# "Changes" home directory without root. Uncomment both lines below this.
#export HOME=<path to new home>
#cd
2012-12-21 14:24:51 +01:00
# Colours to less
# Copied from http://nion.modprobe.de/blog/archives/572-less-colors-for-man-pages.html
export LESS_TERMCAP_mb = $'\E[01;31m'
export LESS_TERMCAP_md = $'\E[01;31m'
export LESS_TERMCAP_me = $'\E[0m'
export LESS_TERMCAP_se = $'\E[0m'
export LESS_TERMCAP_so = $'\E[01;44;33m'
export LESS_TERMCAP_ue = $'\E[0m'
export LESS_TERMCAP_us = $'\E[01;32m'
2011-10-29 09:50:56 +02:00
2012-12-24 17:59:14 +01:00
# Sets environment variable CPUARCH to output of "uname -p" and UNAME to "uname"
2014-05-22 10:31:14 +02:00
CPUARCH = $( uname -p)
2012-12-24 17:59:14 +01:00
2013-02-16 09:11:40 +01:00
# Copied from http://homepages.see.leeds.ac.uk/~eeaol/notes/2012/03/how_to_only_type_ssh_passphrase_once/
export SSH_AUTH_SOCK = /tmp/$USER .agent
2013-02-17 08:02:07 +01:00
ssh-agent -a /tmp/$USER .agent > /dev/null 2>& 1
2013-02-16 09:11:40 +01:00
2014-04-20 20:39:30 +02:00
# If we are on Linux, enable apt progress bar and colours
2014-04-20 11:37:56 +02:00
if [ [ $USER = "root" ] ] ; then
mkdir -p /etc/apt/apt.conf.d/
echo 'Dpkg::Progress-Fancy "1";' > /etc/apt/apt.conf.d/99progressbar
2014-04-21 09:11:33 +02:00
echo 'DPkgPM::Progress-Fancy "1";' >> /etc/apt/apt.conf.d/99progressbar
2014-04-20 20:39:30 +02:00
echo 'APT::Color "1";' > /etc/apt/apt.conf.d/99color
2014-04-20 11:37:56 +02:00
fi
2014-01-15 13:28:44 +01:00
# In our series useless/weird environment variables, beep
2014-01-29 19:50:26 +01:00
export beep =
export BEEP =
2014-01-15 13:28:44 +01:00
2014-05-01 13:55:01 +02:00
# OS X ls colours (copied from https://apple.stackexchange.com/questions/33677/
export CLICOLOR = 1
export LSCOLORS = gxBxhxDxfxhxhxhxhxcxcx
2014-05-04 15:43:24 +02:00
# make
2014-05-06 16:25:29 +02:00
if [ [ $UNAME != Darwin ] ] ; then
2014-05-22 10:31:14 +02:00
export NPROC = $( nproc)
2014-05-06 16:25:29 +02:00
else
2014-05-22 10:31:14 +02:00
export NPROC = $( sysctl -n hw.ncpu)
2014-05-06 16:25:29 +02:00
fi
2014-06-07 18:53:29 +02:00
alias maken = " make -j $NPROC "
2014-05-06 16:25:29 +02:00
2014-12-24 14:41:34 +01:00
# Ensure that pkg-config paths are found
export PKG_CONFIG_PATH = $( which pkg-config)
2011-10-29 09:50:56 +02:00
##### Aliases RJ706I #####
# To get sudo work with aliases.
alias sudo = "sudo "
# Moving between directories:
alias ..= "cd .."
# Use htop instead of top, it's better. Requires htop.
2014-10-09 19:25:11 +02:00
#alias top="htop" # MIKAELA_GREP MIKAELA_GREP_ALIAS
2011-10-29 09:50:56 +02:00
2014-07-30 19:23:13 +02:00
# Add title to youtube-dl & make yle-dl Windows-friendly
2011-10-29 09:50:56 +02:00
alias youtube-dl= "youtube-dl -t"
2014-07-30 19:23:13 +02:00
alias yle-dl= "yle-dl --vfat"
2011-10-29 09:50:56 +02:00
# git specific. This is the command which I use when git asks me to commit something and says that I have modified files, even when I haven't.
alias gdrop = "git stash && git stash drop"
2014-01-14 20:34:37 +01:00
# Show compilation date of WeeChat.
alias weechat-version= "weechat --help|head -n2"
2011-10-29 09:50:56 +02:00
#NMAP specific. All nmap things should be run as root, so it's probably best to copy these aliases to root's .zshrc. Things which don't run without root ask for sudo password.
alias nmap-intense= "nmap -T4 -A -v -PE -PS22,25,80 -PA21,23,80,3389 "
alias nmap-intense-udp= "sudo nmap -sS -sU -T4 -A -v -PE -PS22,25,80 -PA21,23,80,3389 "
alias nmap-intense-all-tcp= "nmap -p 1-65535 -T4 -A -v -PE -PS22,25,80 -PA21,23,80,3389 "
alias nmap-intense-no-ping= "nmap -T4 -A -v -PN "
alias nmap-ping= "nmap -sP -PE -PA21,23,80,3389 "
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 "
# 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 "
# Downloads folder over SSH. Usage: rdownload <host>:<remotefolder> <local_destination> | TIP: use ~/ssh/config to configure hosts.
2012-01-10 15:54:10 +01:00
alias rdownload = "rsync -h --progress -avz "
2013-02-24 09:03:32 +01:00
alias rscp = 'rsync -h --progress -avz '
alias rscpr = 'rsync -h --progress -azvv '
2011-10-29 09:50:56 +02:00
# TMUX specific
2014-10-29 20:13:08 +01:00
alias tmux = "tmux -2u"
2014-05-29 15:02:08 +02:00
alias attach = "tmux attach-session"
alias detach = "tmux detach"
2011-10-29 09:50:56 +02:00
# I am always typoing "aptitude" with my phone...
alias aptitute = "aptitude "
# The Battle for Wesnoth specific, http://wesnoth.org/
# It seems to be an good idea to have debug logs on terminal with svn version.
alias wesnoth = "wesnoth --debug"
# Auto extension things, ( modified from https://wiki.archlinux.org/index.php/Zsh#Advanced_.zshrc_files )
alias -s html = $BROWSER
alias -s org = $BROWSER
alias -s php = $BROWSER
alias -s com = $BROWSER
alias -s net = $BROWSER
alias -s png = "eog"
alias -s jpg = "eog"
alias -s gif = "eog"
alias -s sxw = "libreoffice --writer"
alias -s doc = "libreoffice --writer"
alias -s gz = 'tar -xzvf'
alias -s bz2 = 'tar -xjvf'
#alias -s java=$EDITOR
#alias -s txt=$EDITOR
#alias -s PKGBUILD=$EDITOR
# For copy-pasting directly from somewhere
alias %= " "
2012-12-21 13:24:44 +01:00
alias \# = " "
2011-10-29 09:50:56 +02:00
2012-04-30 18:12:20 +02:00
# Supybot specifig. Why to write long command, if you can write short command?
2014-09-11 08:33:33 +02:00
alias supybot-config-reload= "killall -HUP supybot "
alias supybot-owner-quit= "killall -INT supybot "
2011-10-29 09:50:56 +02:00
# Translating plugins in Limnoria
2012-04-15 17:46:00 +02:00
alias supybot-generate-messages.pot= "pygettext --docstrings config.py plugin.py"
2012-08-04 14:26:07 +02:00
alias supybot-check-plugin-trans= "sandbox/check_trans.py plugins/"
2014-09-11 08:37:33 +02:00
alias supybot-check-core-trans= "sandbox/check_trans.py --core"
2012-10-07 17:25:38 +02:00
alias supybot-generate-messages.pot-mass= "find . -type d -exec sh -c '(cd {} && pygettext --docstrings config.py plugin.py)' ';'"
2011-10-29 09:50:56 +02:00
# ZSH specific.
# I think that "theme" is more describing than "prompt".
alias theme = "prompt "
## -- Start of aliases which are saved from Ubuntu default bashrc. --
# enable color support of ls and also add handy aliases
2012-12-31 11:16:46 +01:00
if [ [ $UNAME != Darwin ] ] ; then
2012-12-31 10:44:32 +01:00
alias ls = 'ls --color=always'
fi
2012-12-21 14:11:11 +01:00
alias dir = 'dir --color=always'
alias vdir = 'vdir --color=always'
alias grep = 'grep --color=always'
alias fgrep = 'fgrep --color=always'
alias egrep = 'egrep --color=always'
2011-10-29 09:50:56 +02:00
# some more ls aliases
2012-12-31 11:16:46 +01:00
if [ [ " $UNAME " != "Darwin" ] ] ; then
2012-12-31 21:07:43 +01:00
alias ll = 'ls -alFh --color=always' && alias la = 'ls -A --color=always' && alias l = 'ls -CF --color=always'
2012-12-31 10:44:32 +01:00
fi
2014-05-01 13:50:14 +02:00
if [ [ $UNAME = Darwin ] ] ; then
2014-05-01 14:24:52 +02:00
alias ls = "ls -Gp"
2014-05-01 14:06:44 +02:00
alias ll = "ls -alFHGp"
alias l = "ls -CFGp"
2014-05-08 18:31:00 +02:00
alias ssh-add= "\ssh-add -D && \ssh-add -K"
2014-05-01 13:50:14 +02:00
fi
2011-10-29 09:50:56 +02:00
# Add an "alert" alias for long running commands. Use like so:
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$//' \' ')"'
## -- End of aliases which are saved from Ubuntu default bashrc. --
# Copying command in Supybot (Internet.DNS)
alias dns = "nslookup "
alias dns6 = "nslookup -type=AAAA "
alias nslookup6 = "nslookup -type=AAAA "
# If I have nslookup6...
alias dig6 = "dig AAAA "
# SSHGuard specific
alias sshguard-show-bans= "sudo iptables -L sshguard --line-numbers"
# Enter ban number as arguement. You can see ban numbers with previous command.
alias sshguard-unban= "sudo iptables -D sshguard "
2011-11-12 19:42:26 +01:00
# This needs something which makes it easy to remember.
alias KILL = "killall -KILL "
2011-12-25 16:51:34 +01:00
# For locally rsync copying folder1 to folder2.
2012-01-10 15:54:10 +01:00
alias rsync-folder= "rsync -h --progress -azvv "
2011-12-25 16:51:34 +01:00
2011-12-31 21:11:01 +01:00
# SSHGuard seems to prefer users to run this always when connecting with keys in ssh-agent...
2014-05-08 18:31:00 +02:00
if [ [ $UNAME != Darwin ] ] ; then
alias ssh-add= "\ssh-add -D && \ssh-add "
fi
2011-12-31 21:11:01 +01:00
2012-04-01 16:21:38 +02:00
# Use GPG2 instead of GPG!
2014-07-10 10:04:55 +02:00
alias gpg = gpg2
compdef gpg2 = gpg
export KEYBASE_GPG = gpg2
2014-05-28 18:20:12 +02:00
alias gpg-fix-tty= 'export GPG_TTY=$(tty)'
2012-04-30 18:12:20 +02:00
# ZSH doesn't currently include automatic completion for GPG2,
# so use the GPG one, which works with GPG2 too. This is in aliases,
# because that above alias needs this and this will disappear when zsh
# gets GPG2 completion. See
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=666755
2014-10-09 19:25:11 +02:00
#compdef gpg2=gpg # MIKAELA_GREP MIKAELA_GREP_ALIAS
2012-04-01 16:21:38 +02:00
2012-05-03 16:26:50 +02:00
# For locally installed mosh on remote server.
alias lmosh = "mosh --server=~/.local/bin/mosh-server "
2014-03-20 18:52:11 +01:00
alias lmosha = "mosh --server=~/.local/bin/mosh-server-alt "
2012-05-03 16:26:50 +02:00
2011-10-29 09:50:56 +02:00
# Allow custom aliases to be put in .aliases or .zsh_aliases .
2012-05-19 11:58:51 +02:00
# Secure cat
alias scat = "gpg --decrypt "
2012-06-24 08:33:23 +02:00
# To check are keys, which apt uses changed
alias apt-key-refresh-keys= "apt-key adv --keyserver pool.sks-keyservers.net --refresh-keys"
2012-06-29 19:28:50 +02:00
# To see which mirror http.debian.net puts you to. The file which has the latest update time is the mirror which you are using.
2012-08-19 11:08:09 +02:00
alias http.debian.net= "curl -sL http://http.debian.net/debian/project/trace/|pandoc -f html -t markdown"
2012-06-29 19:28:50 +02:00
2012-07-25 09:51:05 +02:00
# Amount of keys in GPG keyring.
alias gpg-key-amount= "gpg --list-keys|grep '^pub'|wc -l"
2012-07-25 10:00:52 +02:00
alias gpg-key-count= "gpg --export -a|gpg --import"
2012-07-25 09:51:05 +02:00
2014-05-16 16:30:09 +02:00
alias follow = "tail -F"
2012-08-04 15:45:05 +02:00
2012-08-18 10:37:19 +02:00
#myip shows current IP. This was a function.
2012-08-18 10:57:20 +02:00
alias myip = "curl -s http://icanhazip.com"
2014-08-28 14:23:29 +02:00
alias myip4 = "dig A +short myip.opendns.com @resolver1.opendns.com"
2012-08-18 10:57:20 +02:00
alias myip6 = "curl -s6 http://icanhazip.com"
2012-08-18 10:37:19 +02:00
2012-08-30 18:55:53 +02:00
# Update groups without logging out. Requires entering password. Source: http://blog.edwards-research.com/2010/10/linux-refresh-group-membership-without-logging-out/
2012-08-31 16:48:55 +02:00
alias refreshgroups = " exec su -l $USER "
2012-08-30 18:55:53 +02:00
2012-08-31 16:48:55 +02:00
# Incasesensitive grepping
alias grep = "grep -i"
2012-08-30 18:55:53 +02:00
2012-09-15 09:12:17 +02:00
# Get public key lenght of (public) SSH key
alias ssh-pubkey-length= "ssh-keygen -lf "
# MSDOS commands. MSDOS is after every alias line to get these lines easily by grepping.
alias cls = clear # MSDOS
alias help = man # MSDOS
alias ipconfig = ifconfig # MSDOS
2012-09-15 09:25:39 +02:00
alias copy = cp # MSDOS
alias move = mv # MSDOS
2012-09-15 09:12:17 +02:00
2012-09-15 10:01:06 +02:00
# List git committers of repository
alias git-committers= "git shortlog -s"
2014-05-29 23:01:03 +02:00
alias git-changelog= "git log --oneline --decorate"
alias git-changelog-color= "git log --oneline --decorate --color"
2012-09-15 10:01:06 +02:00
2012-09-23 09:27:29 +02:00
alias unixle = "flip -ub "
alias msdosle = "flip -mb "
2012-12-09 13:08:31 +01:00
# Making .iso bootable from CD/DVD/USB. Cat it to /dev/<DEVICE>
# MaKe Hybrid ISO
alias mkhiso = isohybrid
# Yum
alias yum-unlock= "rm -rf /var/run/yum.pid"
2012-12-21 11:44:13 +01:00
alias yum-rm-timedhosts= " rm /var/cache/yum/ $CPUARCH /17/timedhost* "
2013-01-01 20:13:27 +01:00
alias yummy = "yum -y "
alias yummn = "yum -n "
alias yumy = yummy
alias yumn = yummn
2012-12-09 13:08:31 +01:00
2012-12-21 11:54:59 +01:00
# Archiving and extracting with tar
# This is tartar to avoid conflict with tar
alias tartar = "tar cfv "
alias targz = "tar cfvz "
alias tarbz2 = "tar cfvj "
# ex-tartar and ex-tar, because there is alias tartar and command tar
alias ex-tar= "tar xfv "
alias ex-tartar= "tar xfv "
alias ex-targz= "tar xfvz "
alias ex-tarbz2= "tar xfvj "
2012-12-22 20:17:56 +01:00
alias info = "echo 'I don't know anyone who likes and uses info pages, so I aliased this to pinfo. If you don't have it installed, you should install it! To override this alias run: \info <document>' && pinfo "
2013-01-14 17:13:46 +01:00
# systemd runlevels/targets
alias currenttargets = "systemctl list-units --type=target"
alias telsystemd = "systemctl isolate "
alias defaulttarget = "systemctl enable "
2012-12-31 22:00:59 +01:00
# For getting timestamps in history
alias history = "history -i "
2012-12-22 20:17:56 +01:00
# To have less handle ls colours
alias less = "less -R "
2012-12-21 11:54:59 +01:00
2013-02-04 09:52:58 +01:00
# "su -" with/without sudo
2013-02-04 15:11:30 +01:00
alias ssu = "sudo su -"
2013-02-04 09:52:58 +01:00
alias suu = "su -"
2013-01-01 10:30:37 +01:00
2013-01-19 10:21:31 +01:00
# Fedora Utils http://satya164.github.com/fedorautils/
alias fedorautils = "\fedorautils -c"
2013-01-19 11:30:25 +01:00
alias fedorautils-install= 'su -c "curl http://download.opensuse.org/repositories/home:/satya164:/fedorautils/Fedora_17/home:satya164:fedorautils.repo -Lo /etc/yum.repos.d/fedorautils.repo && yum -y install fedorautils"'
2013-01-19 10:21:31 +01:00
2013-02-10 12:12:52 +01:00
# ReSet Screen rss
alias rss = reset
2013-02-16 08:52:19 +01:00
# Who command which I use with Conky
alias cwho = "who -H -w -u"
2013-02-27 09:50:43 +01:00
# Upgrading Redhad/Debian
alias yumyup = "yum -y check-update;yum -y update;grub2-mkconfig -o /boot/grub2/grub.cfg"
2014-04-20 12:04:56 +02:00
alias apt-getyup= "apt-get -y update;apt-get -y upgrade;update-grub"
2013-04-26 13:00:13 +02:00
alias aptitudeyup = "aptitude -y update;aptitude -y upgrade;update-grub"
2014-04-20 12:04:56 +02:00
alias aptyup = "apt -y update;apt -y upgrade;update-grub"
2013-02-27 09:50:43 +01:00
2013-04-10 15:57:55 +02:00
alias apt-gety= "apt-get -y "
2013-04-15 11:24:12 +02:00
alias aptitudey = "aptitude -y "
2014-04-20 12:04:56 +02:00
alias apty = "apt -y"
2013-04-10 15:57:55 +02:00
2013-04-26 13:00:13 +02:00
# Set core pattern how I want it to be
2013-04-26 13:01:50 +02:00
alias fcorepattern = 'echo kernel.core_pattern = %e-%p-%h.core >> /etc/sysctl.conf;sysctl -f'
2013-04-26 13:00:13 +02:00
2013-05-06 16:20:36 +02:00
# ffmpeg is depreceated
alias ffmpeg = avconv
2014-01-08 20:18:57 +01:00
# inxi https://code.google.com/p/inxi/
2014-01-14 18:08:53 +01:00
alias inxi-install= "mkdir -p ~/.local/bin && cd ~/.local/bin && \wget -Nc smxi.org/inxi && chmod +x inxi && cd"
2014-03-18 10:23:25 +01:00
alias inxi-install-root= "cd /usr/local/bin;\wget -Nc smxi.org/inxi;chmod +x inxi;./inxi -U;cd"
2014-01-08 20:18:57 +01:00
alias inxi-update= "inxi -U"
2014-04-14 17:40:47 +02:00
# FINEID
2014-07-10 15:38:18 +02:00
#alias ssh-add-sc="ssh-add -s $(find /usr/*lib -name 'opensc-pkcs11.so')"
2014-07-09 16:07:47 +02:00
alias ssh-add-sc-pub= "\ssh-add -L"
2014-04-14 17:40:47 +02:00
2014-04-20 20:54:29 +02:00
## apt in Ubuntu 14.04+ and other distributions
2014-04-20 12:12:54 +02:00
2014-04-20 20:54:29 +02:00
#if [ -f /usr/bin/apt ]; then
# alias aptitude=apt
# alias apt-get=apt
# alias apt-cache=apt
#fi
2014-04-20 12:12:54 +02:00
2014-04-20 17:07:32 +02:00
# Same as the previous, but for yum --> dnf
if [ -f /usr/bin/dnf ] ; then
alias yum = dnf
fi
2014-04-30 21:50:44 +02:00
# Homebrew
2014-10-22 23:07:52 +02:00
alias homebrew-install= "cd ~;git clone https://github.com/Homebrew/homebrew.git;mkdir -p .local;rsync -aP homebrew/* .local;rsync -aP homebrew/.* .local;rm -rf homebrew"
alias homebrew-install-root= "cd /usr;git clone https://github.com/Homebrew/homebrew.git;mkdir -p local;rsync -aP homebrew/* local;rsync -aP homebrew/.* local/;chmod -R 755 local;chown -R root:wheel local;rm -rf homebrew"
2014-10-22 12:41:00 +02:00
alias linuxbrew-install= "cd ~;git clone https://github.com/Homebrew/linuxbrew.git;mkdir -p .local;rsync -aP linuxbrew/* .local;rsync -aP linuxbrew/.* .local;rm -rf linuxbrew"
2014-10-22 23:07:52 +02:00
alias linuxbrew-install-root= "cd /usr;git clone https://github.com/Homebrew/linuxbrew.git;mkdir -p local;rsync -aP linuxbrew/* local;rsync -aP linuxbrew/.* local/;chmod -R 755 local;chown -R root:wheel local;rm -rf linuxbrew"
2014-04-30 21:50:44 +02:00
2014-05-13 14:58:09 +02:00
# OS X
2014-05-13 14:41:07 +02:00
alias osx-server-caching-interface= "serveradmin settings caching:Interface ="
2014-05-13 15:00:13 +02:00
alias osx-show-hidden-files= "defaults write com.apple.finder AppleShowAllFiles"
2014-05-13 14:58:09 +02:00
alias osx-airdrop-listenallif= "defaults write com.apple.NetworkBrowser BrowseAllInterfaces"
alias osx-set-updatecheck= "defaults write /Library/Preferences/com.apple.SoftwareUpdate ScheduleFrequency"
2014-05-01 17:21:08 +02:00
2014-05-13 11:41:26 +02:00
# Simple HTTPd with Python.
2014-07-18 13:45:46 +02:00
alias python2-httpd= "python2 -m SimpleHTTPServer"
alias python3-httpd= "python3 -m http.server"
2014-05-13 11:41:26 +02:00
2014-05-22 11:05:13 +02:00
# Resetting different desktop environments
alias reset-gnome= "rm -rf ~/.gnome ~/.gnome2 ~/.gconf ~/.gconfd ~/.metacity ~/.cache ~/.dbus ~/.dmrc ~/.mission-control ~/.thumbnails ~/.config/dconf/user ~/.compiz*"
2014-05-22 11:11:44 +02:00
alias reset-unity= "unity-tweak-tool --reset-unity"
2014-05-22 11:05:13 +02:00
alias reset-kde= "rm -rf ~/.kde4 ~/.kde"
alias reset-lxpanel= "rm -rf ~/.config/lxpanel;lxpanelctl restart"
alias reset-xfce4= "rm -rf ~/.config/xfce4"
alias reset-matepanel= "mate-panel --reset"
2014-05-30 23:02:01 +02:00
# Show date in ISO 8601 format
2015-01-05 19:50:32 +01:00
alias isodate = 'date -Is'
alias isodateu = 'date -uIs'
alias isodatea = 'date "+%Y-%m-%dT%H:%M:%S%z"'
alias isodateua = 'date -u "+%Y-%m-%dT%H:%M:%S%z"'
2014-05-30 23:02:01 +02:00
2014-06-05 15:36:20 +02:00
# Show information on PEM file.
alias peminfo = "openssl x509 -text -in"
2014-06-28 07:03:28 +02:00
# tmux emergency attach
alias tmuxeattach = " /proc/ $( pgrep -o tmux) /exe attach "
2014-07-15 19:42:09 +02:00
# Reset configuration files on systems using apt
alias purgeconfig = "apt-get install --reinstall -o DPkg::options::=--force-confask"
2014-07-30 19:34:51 +02:00
# Send command output to http://sprunge.us `command|sprungeus`
alias sprungeus = "curl -F 'sprunge=<-' http://sprunge.us"
2014-08-10 14:42:09 +02:00
# Always build pythons with --enable-shared when using pyenv
alias pyenv = 'CONFIGURE_OPTS="--enable-shared" PYTHON_CONFIGURE_OPTS="--enable-shared" command \pyenv'
2014-08-15 16:54:33 +02:00
# Copy-paste mtr output more easily
2014-12-30 17:31:16 +01:00
alias mtrp = "mtr -rwc 10"
alias mtrp4 = "mtr -rw4c 10"
alias mtrp6 = "mtr -rw6c 10"
2014-08-15 16:54:33 +02:00
2014-09-04 12:27:56 +02:00
# pip
alias pip = "python -m pip"
alias pip2 = "python2 -m pip"
alias pip3 = "python3 -m pip"
alias pippypy = "pypy -m pip"
alias pippypy2 = "pypy2 -m pip"
alias pippypy3 = "pypy3 -m pip"
alias pypypip = pippypy
alias pypypip2 = pippypy2
alias pypypip3 = pippypy3
2014-09-11 08:32:02 +02:00
# apg with small letters, capital letters and numbers. I don't usually use
# special characters as they sometimes have difficulties with some systems
# and cross-platform operating systems.
# Usage: apt-random <minimum length>
alias apg-random= "apg -a1 -M LCN -m"
2014-09-13 10:26:28 +02:00
# cp/mv using rsync. rcp appears to be link to scp in my system, so I can
# safely use this alias.
alias rcp = "rsync -a --progress"
alias rmv = "rsync -a --progress --remove-source-files"
2014-12-28 08:22:31 +01:00
# Clear apt list cache
2014-12-28 17:31:45 +01:00
alias clear-apt-list-cache= "cd /var/lib/apt/lists;rm *;cd partial;rm *;cd"
2014-12-28 08:22:31 +01:00
2015-01-07 08:30:52 +01:00
# Accept all cookies with Lynx, makes browsing easier and
# every other browser does this too.
alias lynx = "lynx -accept_all_cookies"
2011-10-29 09:50:56 +02:00
# .aliases
if [ -f ~/.aliases ] ; then
source ~/.aliases
fi
# .zsh_aliases
if [ -f ~/.zsh_aliases ] ; then
source ~/.zsh_aliases
2011-10-01 15:32:18 +02:00
fi
2011-10-29 09:50:56 +02:00
##### Functions ZGC5QQ #####
# GEOIP lookup, copied from the ultimate bashrc http://goo.gl/qGK5j
function geoip( ) {
geoiplookup $1
}
# 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 } " ; }
# Down for everyone or just me? Copied from the ultimate bashrc http://goo.gl/qGK5j
function downforme( ) {
2014-06-05 15:36:20 +02:00
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
2014-05-22 10:31:14 +02:00
JUSTYOUARRAY = ( $( lynx -dump http://downforeveryoneorjustme.com/$1 | grep -o "It's just you" ) )
2014-06-05 15:36:20 +02:00
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
2011-10-29 09:50:56 +02:00
}
# Topt10 commands, copied from the ultimate bashrc http://goo.gl/qGK5j
function top10( ) {
2014-06-05 15:36:20 +02:00
# copyright 2007 - 2010 Christopher Bratusek
2014-10-07 07:49:35 +02:00
\h istory | awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}' | sort -rn | head
2011-10-29 09:50:56 +02:00
}
# 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"
2011-10-01 15:32:18 +02:00
fi
2011-10-29 09:50:56 +02:00
}
2012-01-06 19:24:36 +01:00
# Given by nyuszika7h. Shortens GitHub URLs with git.io
2012-04-24 16:30:37 +02:00
function gitio( ) {
curl -s -i http://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
2012-04-24 16:43:19 +02:00
mkdir -p " $* " && cd " $1 "
2012-04-24 16:30:37 +02:00
}
function gribble-gpg-everify( ) {
# Set which command to use for gpg. You
# probably want to use gpg2 here.
local gpg = gpg2
2012-04-24 16:43:19 +02:00
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
2012-04-24 16:30:37 +02:00
}
2012-01-06 19:24:36 +01:00
2014-05-06 16:12:33 +02:00
# This function will install/upgrade shell-things.
function shell-things {
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
2014-12-21 15:18:49 +01:00
git remote set-url origin https://github.com/Mikaela/shell-things.git
2014-05-06 16:12:33 +02:00
git pull
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 ""
2014-12-18 07:35:17 +01:00
git clone https://github.com/Mikaela/shell-things.git $SHELL_THINGS_REPO
2014-05-06 16:12:33 +02:00
cd $SHELL_THINGS_REPO
echo ""
echo "shell-things: Installing/Upgrading..."
echo ""
fi
# Installing...
2014-12-27 10:22:48 +01:00
bash -x ./install
2014-05-06 16:12:33 +02:00
echo ""
echo "shell-things: Installing finished."
echo ""
echo ""
echo "shell-things: Everthing is now done :)"
echo ""
cd
}
2014-05-13 11:34:11 +02:00
# This function will download and install sources.list.
function ubuntu-sources-list-install {
2014-05-22 10:31:14 +02:00
export RELEASE = $( lsb_release -sr)
2014-12-27 10:14:50 +01:00
a[ 1] = " https://raw.githubusercontent.com/Mikaela/shell-things/master/etc/apt/sources.list/ $RELEASE "
2014-05-13 11:34:11 +02:00
echo "I am now changing directory to /etc/apt/."
echo ""
cd /etc/apt/
echo "I will now backup sources.list to sources.list.bak ."
echo ""
cp /etc/apt/sources.list /etc/apt/sources.list.bak
2014-12-27 10:14:50 +01:00
echo " I will now download the sources.list file from https://raw.githubusercontent.com/Mikaela/shell-things/master/etc/apt/sources.list/ $RELEASE and save it as /etc/apt/sources.list . "
2014-05-13 11:34:11 +02:00
echo ""
echo "" > /etc/apt/sources.list
\w get ${ a [1] } -O /etc/apt/sources.list
#\curl -L ${a[1]} >> /etc/apt/sources.list
echo ""
echo "The new sources.list file should now be installed."
echo ""
echo "Finally, I will now run 'apt-get -y update' so the new sources.list is used."
echo ""
apt-get update
echo "I have now finished everything that I was supposed to do."
}
2014-05-13 12:07:04 +02:00
# This function fixes nodejs on Debian based systems.
# (Everything expects nodejs to be called as node, but it's not with Debian.)
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
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
}
2014-06-22 10:17:48 +02:00
# This function fixes automatic startup in graphical sessions.
# I have had issues with auto start not doing anything and this seems to
# fix it.
fix-autostart( ) {
if [ [ $USER = "root" ] ]
then
mkdir -p /etc/xdg/autostart
chmod -R 755 /etc/xdg/autostart
fi
mkdir -p ~/.config/autostart
chmod -R 755 ~/.config/autostart
}
2014-07-17 15:05:42 +02:00
# This function removes and regenerates ssh host keys.
ssh-regen-host-keys ( ) {
rm /etc/ssh/ssh_host_*
ssh-keygen -t dsa -N "" -f /etc/ssh/ssh_host_dsa_key
ssh-keygen -t rsa -N "" -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -t ecdsa -N "" -f /etc/ssh/ssh_host_ecdsa_key
ssh-keygen -t ed25519 -N "" -f /etc/ssh/ssh_host_ed25519_key
}
2014-07-30 19:40:44 +02:00
# 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
}
2014-09-19 23:08:16 +02:00
# 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
fi
if hash clang++ 2>/dev/null; then
export CXX = clang++
fi
2014-11-11 07:55:10 +01:00
# Function to temporarily set sysctl options which I want
2014-09-24 16:14:36 +02:00
function sysctl-mikaela( ) {
set -x
sysctl kernel.core_pattern= %e-%p-%h.core
sysctl vm.swappiness= 1
2014-12-29 11:36:43 +01:00
sysctl net.ipv6.bindv6only= 1
2014-10-30 07:45:32 +01:00
sysctl net.ipv6.conf.eth0.use_tempaddr= 2
sysctl net.ipv6.conf.wlan0.use_tempaddr= 2
echo 'If network-manager is used, see /etc/NetworkManager/system-connections/<connection>'
2014-09-24 16:14:36 +02:00
set +x
}
# Function to permanently set sysctl options which I want.
function sysctl-mikaela-run( ) {
set -x
2014-09-25 12:44:32 +02:00
echo kernel.core_pattern = %e-%p-%h.core >> /etc/sysctl.conf
echo vm.swappiness = 1 >> /etc/sysctl.conf
2014-12-29 11:36:43 +01:00
echo net.ipv6.bindv6only= 1 >> /etc/sysctl.conf
2014-11-21 16:22:37 +01:00
echo net.ipv6.conf.eth0.use_tempaddr= 2 >> /etc/sysctl.conf
echo net.ipv6.conf.wlan0.use_tempaddr= 2 >> /etc/sysctl.conf
2014-10-30 07:45:32 +01:00
echo 'If network-manager is used, see /etc/NetworkManager/system-connections/<connection>'
2014-09-24 16:14:36 +02:00
sysctl -p
set +x
}
2014-10-05 21:50:06 +02:00
# Add GitHub pull requests to fetched things via http://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/*'
}
2014-09-19 23:08:16 +02:00
2014-12-21 14:46:11 +01:00
# Get server SSL certificate fingerprint in MD5, SHA1 and SHA256.
# Note that this should not be pointed to round-robin and is pointed
# preferably to direct IP address.
# Note that OpenSSL doesn't support IPv6 at time of writing (2014-12-21).
2014-12-19 07:53:59 +01:00
serversslcertfp( ) {
openssl s_client -connect $1 < /dev/null 2>/dev/null| openssl x509 -fingerprint -md5 -noout -in /dev/stdin
openssl s_client -connect $1 < /dev/null 2>/dev/null| openssl x509 -fingerprint -sha1 -noout -in /dev/stdin
openssl s_client -connect $1 < /dev/null 2>/dev/null| openssl x509 -fingerprint -sha256 -noout -in /dev/stdin
}
2014-12-21 14:46:11 +01:00
# Get server SSL certificate fingerprint in MD5, SHA1 and SHA256.
serversslcertfpmd5( ) {
openssl s_client -connect $1 < /dev/null 2>/dev/null| openssl x509 -fingerprint -md5 -noout -in /dev/stdin
}
# Get server SSL certificate fingerprint in MD5, SHA1 and SHA256.
serversslcertfpsha1( ) {
openssl s_client -connect $1 < /dev/null 2>/dev/null| openssl x509 -fingerprint -sha1 -noout -in /dev/stdin
}
# Get server SSL certificate fingerprint in MD5, SHA1 and SHA256.
serversslcertfpsha256( ) {
openssl s_client -connect $1 < /dev/null 2>/dev/null| openssl x509 -fingerprint -sha256 -noout -in /dev/stdin
}
2011-10-29 09:50:56 +02:00
# Source files for miscannellious modifications.
# .custom
if [ -f ~/.custom ] ; then
source ~/.custom
2014-07-17 15:05:42 +02:00
fi
2011-10-02 16:05:17 +02:00
2011-10-29 09:50:56 +02:00
# .zsh_custom
2011-10-02 16:22:09 +02:00
if [ -f ~/.zsh_custom ] ; then
2011-10-02 16:05:17 +02:00
source ~/.zsh_custom
2014-07-17 15:05:42 +02:00
fi
2012-07-14 19:46:08 +02:00
# Warnings
if [ -f ~/.warnings ] ; then
source ~/.warnings
2014-07-17 15:05:42 +02:00
fi