2016-10-12 23:42:02 -04:00
|
|
|
# Borg backup repository
|
|
|
|
export BORG_REPO="kserver:borg"
|
2016-07-18 16:41:37 -04:00
|
|
|
#zmodload zsh/zprof
|
2016-07-25 03:53:50 -04:00
|
|
|
echo -ne '[ ]\r'
|
2016-07-18 16:44:17 -04:00
|
|
|
for config (~/.zsh/*.zsh) source $config
|
2016-07-18 16:41:37 -04:00
|
|
|
autoload -U compinit
|
|
|
|
compinit
|
2016-07-18 16:44:17 -04:00
|
|
|
setopt always_to_end # When completing from the middle of a word, move the cursor to the end of the word
|
|
|
|
setopt complete_in_word # Allow completion from within a word/phrase
|
2015-06-23 10:24:46 -04:00
|
|
|
setopt INTERACTIVECOMMENTS
|
2016-03-19 23:02:25 -04:00
|
|
|
setopt EXTENDED_GLOB
|
2014-08-29 09:46:43 -04:00
|
|
|
setopt HIST_EXPIRE_DUPS_FIRST
|
2016-05-22 13:52:20 -04:00
|
|
|
export HIST_STAMPS="dd.mm.yyyy"
|
|
|
|
export HISTSIZE=12000
|
|
|
|
export SAVEHIST=10000000
|
|
|
|
export HISTFILE=$HOME/.zsh_history
|
|
|
|
setopt APPEND_HISTORY
|
2014-08-29 09:46:43 -04:00
|
|
|
setopt EXTENDED_HISTORY
|
2015-03-02 11:20:59 -05:00
|
|
|
setopt APPEND_HISTORY SHARE_HISTORY HISTIGNOREALLDUPS
|
2015-03-25 14:25:22 -04:00
|
|
|
export DISABLE_AUTO_TITLE=true
|
2014-08-29 09:46:43 -04:00
|
|
|
export EDITOR='vim'
|
2016-05-22 13:52:20 -04:00
|
|
|
export FZF_COMPLETION_OPTS='--no-mouse -m -1 -x'
|
2016-09-28 12:54:47 -04:00
|
|
|
zstyle ':completion:*' use-cache on
|
|
|
|
zstyle ':completion:*' cache-path ~/.cache/zsh
|
|
|
|
# Check if a command exists
|
|
|
|
ex(){
|
|
|
|
command -v "$1" >/dev/null
|
|
|
|
return $?
|
|
|
|
}
|
2016-01-26 13:47:55 -05:00
|
|
|
# For pasting in commands that start with $
|
|
|
|
$ () {
|
|
|
|
$*
|
|
|
|
}
|
2016-05-22 13:52:20 -04:00
|
|
|
# A service implementation
|
2016-04-03 11:18:56 -04:00
|
|
|
sv () {
|
2016-03-30 13:29:12 -04:00
|
|
|
command="${@: -1}"
|
|
|
|
while (( $# > 1 )); do
|
2017-01-12 14:56:55 -05:00
|
|
|
if [[ "$command" == "i" ]]; then
|
|
|
|
echo "Status of $1"
|
|
|
|
service "$1" status
|
|
|
|
shift
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
sudo true || return 2
|
|
|
|
if [[ "$1" == "sshd" ]] || [[ "$1" == "ssh" ]]; then
|
|
|
|
echo "Checking sshd config..."
|
|
|
|
sudo sshd -t && echo "Config good. Continuing" || (echo "Aborting due to bad ssh config";return 1)
|
|
|
|
elif [[ "$command" == "r" ]]; then
|
2016-03-30 13:29:12 -04:00
|
|
|
echo "Restarting $1"
|
|
|
|
sudo service "$1" restart
|
|
|
|
elif [[ "$command" == "s" ]]; then
|
|
|
|
echo "Starting $1"
|
|
|
|
sudo service "$1" start
|
|
|
|
elif [[ "$command" == "x" ]]; then
|
|
|
|
echo "Stopping $1"
|
|
|
|
sudo service "$1" stop
|
2016-08-09 18:22:16 -04:00
|
|
|
else
|
|
|
|
sudo service "$1" "$command"
|
2016-03-30 13:29:12 -04:00
|
|
|
fi
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
}
|
2016-07-21 08:27:31 -04:00
|
|
|
compdef _services sv
|
2016-05-22 13:52:20 -04:00
|
|
|
# Run gui application as root by copying xauth credentials
|
2016-01-26 13:47:55 -05:00
|
|
|
asroot(){
|
2015-08-21 20:38:19 -04:00
|
|
|
# Use temporary file for added security
|
|
|
|
TEMPFILE=$(tempfile)
|
|
|
|
xauth extract $TEMPFILE $DISPLAY
|
|
|
|
sudo zsh -c "xauth merge $TEMPFILE;(srm $TEMPFILE||rm $TEMPFILE)&'$@';"
|
|
|
|
}
|
2016-05-22 02:08:21 -04:00
|
|
|
# De-symlink
|
2016-01-22 02:47:34 -05:00
|
|
|
dsl() {
|
|
|
|
while (( $# > 0 )); do
|
|
|
|
readlink $1 2>&1 >/dev/null && mv $(readlink $1) $1
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
}
|
2016-05-22 13:52:20 -04:00
|
|
|
# Remove directory by removing subdirectories up a level
|
2016-01-26 13:47:55 -05:00
|
|
|
dedir(){
|
2016-06-26 21:16:19 -04:00
|
|
|
# Try removing the directory if it's empty, fail silently if you can't
|
|
|
|
=rmdir "$1" 2>/dev/null && return
|
|
|
|
# Make a uuid to avoid name conflicts
|
|
|
|
# Ex: dediring sage when sage/sage fails because sage/sage is moved to .
|
|
|
|
# but since sage/ exists, it can't be moved
|
2016-05-22 02:08:21 -04:00
|
|
|
name=$(uuidgen)
|
2016-06-26 21:16:19 -04:00
|
|
|
# Move the directory to the uuid
|
|
|
|
=mv -n "$1" "$name" || return 1
|
|
|
|
# Move all files, use (N) in case there is no * or .* matches
|
|
|
|
=mv -n "$name"/{.,}*(N) . || return 2
|
|
|
|
=rmdir "$name" || return 3
|
2016-01-10 16:41:13 -05:00
|
|
|
}
|
2016-09-02 00:27:36 -04:00
|
|
|
mt(){
|
|
|
|
if [[ -z "$1" ]]; then
|
2016-09-20 12:24:40 -04:00
|
|
|
echo "Opts:\nm xe gogs dm syncthing g" >&2
|
2016-09-02 00:27:36 -04:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
case $1 in
|
|
|
|
m) sudo multitail /var/log/messages;;
|
|
|
|
xe) multitail ~/.xsession-errors;;
|
2016-11-13 02:17:55 -05:00
|
|
|
ef) sudo multitail /var/log/emerge-fetch.log;;
|
2016-09-02 00:27:36 -04:00
|
|
|
gogs) sudo multitail /var/log/gogs.{err,log};;
|
|
|
|
dm) dmesg -w;;
|
|
|
|
syncthing) sudo multitail /var/log/syncthing.{err,log};;
|
2016-09-20 12:24:40 -04:00
|
|
|
g) sudo watch -c genlop -tc;;
|
|
|
|
sync) watch grep -e Dirty: -e Writeback: /proc/meminfo;;
|
2016-09-02 00:27:36 -04:00
|
|
|
*) multitail "$1"
|
|
|
|
esac
|
2016-08-12 19:15:11 -04:00
|
|
|
}
|
2016-08-18 15:16:56 -04:00
|
|
|
run(){
|
|
|
|
test -f "${1:r}" && rm "${1:r}"
|
|
|
|
echo "Building..." >&2
|
2016-10-12 23:42:02 -04:00
|
|
|
gcc -Wall -g -std=c99 "${1:r}.c" -o "${1:r}" && (echo "Running..." >&2;./"${1:r}")
|
|
|
|
}
|
|
|
|
upload() {
|
|
|
|
tar -cf - "$1" | base64 | curl --data-urlencode text@- -d title="File uploaded at $(date '+%d/%h/%y %H:%M:%S') on $(hostname)" -d name=$USER -d expire="1440" https://austenwares.com/paste/api/create | sed -e 's/view/view\/raw/'
|
|
|
|
}
|
|
|
|
download() {
|
|
|
|
URL="$(printf $1 | perl -pe 's/\/paste\/view(?!\/raw)/\/paste\/view\/raw/')"
|
|
|
|
curl "$URL" | base64 -d | tar -xf -
|
2016-08-18 15:16:56 -04:00
|
|
|
}
|
2017-01-12 14:56:55 -05:00
|
|
|
update-tool() {
|
|
|
|
if [ "$EUID" -ne 0 ]; then
|
|
|
|
echo "This function should be run as root"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
local RESP=""
|
|
|
|
while [[ "$RESP" != "q" ]]; do
|
|
|
|
CMD=${RESP:0:1}
|
|
|
|
case "$CMD" in
|
2017-01-13 00:42:26 -05:00
|
|
|
u) update;;
|
2017-01-12 14:56:55 -05:00
|
|
|
l) layman -S ;;
|
2017-01-13 00:42:26 -05:00
|
|
|
g) upgrade;;
|
2017-01-12 14:56:55 -05:00
|
|
|
e) etc-update;;
|
2017-01-13 00:42:26 -05:00
|
|
|
p) emerge -Av @preserved-rebuild;;
|
|
|
|
m) emerge -Av @module-rebuild;;
|
2017-01-12 14:56:55 -05:00
|
|
|
d) emerge -Ava --depclean;;
|
|
|
|
h) haskell-updater -- --usepkg=n;;
|
2017-01-13 00:42:26 -05:00
|
|
|
c) perl-cleaner --reallyall;;
|
2017-01-12 14:56:55 -05:00
|
|
|
y) python-updater;;
|
|
|
|
r) revdep-rebuild;;
|
|
|
|
q) return;;
|
|
|
|
esac
|
|
|
|
RESP=${RESP:1}
|
|
|
|
if [[ ! -z "$RESP" ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
echo "Commands:"
|
2017-01-13 00:42:26 -05:00
|
|
|
echo "u: update"
|
2017-01-12 14:56:55 -05:00
|
|
|
echo "l: layman -S"
|
2017-01-13 00:42:26 -05:00
|
|
|
echo "g: upgrade"
|
2017-01-12 14:56:55 -05:00
|
|
|
echo "e: etc-update"
|
2017-01-13 00:42:26 -05:00
|
|
|
echo "p: emerge @preserved-rebuild"
|
|
|
|
echo "m: emerge @module-rebuild"
|
2017-01-12 14:56:55 -05:00
|
|
|
echo "d: emerge --ask --depclean"
|
|
|
|
echo "h: haskell-updater -- --usepkg=n"
|
2017-01-13 00:42:26 -05:00
|
|
|
echo "c: perl-cleaner --reallyall"
|
2017-01-12 14:56:55 -05:00
|
|
|
echo "y: python-updater"
|
|
|
|
echo "r: revdep-rebuild"
|
|
|
|
echo "q: quit"
|
|
|
|
echo -n "> "
|
2017-01-13 00:42:26 -05:00
|
|
|
echo '\a'
|
2017-01-12 14:56:55 -05:00
|
|
|
read RESP
|
|
|
|
done
|
|
|
|
}
|
|
|
|
alias cleaner="sudo ~/run.sh 'perl-cleaner --reallyall' 'python-updater' 'haskell-updater -- --usepkg=n'"
|
|
|
|
alias jsonpretty='python -m json.tool'
|
2016-09-15 23:35:17 -04:00
|
|
|
alias nmrestart='nmcli radio wifi off;nmcli radio wifi on'
|
2016-09-28 12:54:47 -04:00
|
|
|
if ex mtr; then
|
|
|
|
alias mtr='mtr -t'
|
|
|
|
fi
|
|
|
|
if ex telegram-cli; then
|
2017-01-12 14:56:55 -05:00
|
|
|
alias tg='telegram-cli -NWA --disable-link-preview'
|
2016-09-28 12:54:47 -04:00
|
|
|
fi
|
2016-07-06 11:28:59 -04:00
|
|
|
alias perm='stat -c "%a %n"'
|
2016-09-28 12:54:47 -04:00
|
|
|
alias afci='git x ./autoformat.sh;git commit -am "Autoformatted"'
|
|
|
|
if ex eix; then
|
|
|
|
alias eix="eix -F"
|
|
|
|
fi
|
2015-10-30 10:51:20 -04:00
|
|
|
alias mouse1="xmodmap <(echo pointer = 1 2 3)"
|
|
|
|
alias mouse2="xmodmap <(echo pointer = 3 2 1)"
|
2016-09-28 12:54:47 -04:00
|
|
|
if ex ocp; then
|
|
|
|
alias ocp="ocp -vs0 -dcurses"
|
|
|
|
fi
|
2016-11-13 02:17:55 -05:00
|
|
|
alias con='git x php bin/console'
|
2016-08-08 17:11:56 -04:00
|
|
|
alias srm='shred -uzv'
|
2014-08-11 01:09:13 -04:00
|
|
|
alias disphost='export DISPLAY=:0.0'
|
2015-12-09 15:12:43 -05:00
|
|
|
alias ll='ls -AlhF'
|
2014-08-11 01:09:13 -04:00
|
|
|
alias la='ls -A'
|
2015-01-16 11:11:49 -05:00
|
|
|
alias l='ls -CF'
|
2014-08-11 01:09:13 -04:00
|
|
|
alias logout='sudo pkill -u $USER'
|
2016-09-28 12:54:47 -04:00
|
|
|
if ex tmux; then
|
|
|
|
alias tmux='tmux -2'
|
|
|
|
fi
|
2015-01-20 07:43:44 -05:00
|
|
|
alias less='less -R'
|
2016-09-28 12:54:47 -04:00
|
|
|
if ex tree; then
|
|
|
|
alias tree='tree -C'
|
|
|
|
fi
|
2014-08-11 01:09:13 -04:00
|
|
|
alias resource='. ~/.zshrc'
|
2015-07-29 16:27:13 -04:00
|
|
|
if [ "$(uname)" != "Darwin" ]; then
|
2015-07-30 03:24:10 -04:00
|
|
|
# Not Mac
|
2016-09-28 12:54:47 -04:00
|
|
|
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:~/bin"
|
2015-07-29 16:27:13 -04:00
|
|
|
alias ls='ls --color=always -F'
|
|
|
|
alias matlab='matlab -glnx86'
|
2016-05-22 13:52:20 -04:00
|
|
|
alias where="readlink -m"
|
2016-05-18 02:56:59 -04:00
|
|
|
else
|
2016-05-22 13:52:20 -04:00
|
|
|
# It is a mac
|
2016-09-28 12:54:47 -04:00
|
|
|
# Prepend macports directories in /opt/local
|
|
|
|
if ex greadlink; then
|
|
|
|
alias readlink='greadlink'
|
|
|
|
alias where="greadlink -m"
|
|
|
|
fi
|
2016-07-18 17:10:06 -04:00
|
|
|
export PATH="/opt/local/sbin:/opt/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:~/bin"
|
2015-07-30 03:24:10 -04:00
|
|
|
fi
|
2015-07-31 16:52:21 -04:00
|
|
|
if test -f /etc/gentoo-release; then
|
2015-07-29 16:27:13 -04:00
|
|
|
# Gentoo
|
2016-07-21 08:27:31 -04:00
|
|
|
alias etup='sudo etc-update'
|
2015-07-30 03:24:10 -04:00
|
|
|
ins(){
|
2016-07-21 08:27:31 -04:00
|
|
|
# Sudo echo so we have immediate results on weather sudo worked
|
|
|
|
sudo echo "Args: $*"
|
2016-03-13 22:05:07 -04:00
|
|
|
# Beep, verbose, ask
|
2016-11-13 02:17:55 -05:00
|
|
|
sudo emerge --autounmask-write -Ava $*
|
2016-03-13 22:05:07 -04:00
|
|
|
echo "\a"
|
|
|
|
}
|
2016-07-21 08:27:31 -04:00
|
|
|
upgrade(){
|
|
|
|
# Sudo echo so we have immediate results on weather sudo worked
|
|
|
|
sudo echo "Args: $*"
|
2017-01-12 14:56:55 -05:00
|
|
|
sudo emerge --update --newuse --deep --verbose --tree --keep-going=y --verbose-conflicts --alert --ask --binpkg-respect-use=y --binpkg-changed-deps=y --backtrack=30 $* @world
|
2016-07-21 08:27:31 -04:00
|
|
|
echo "\\a"
|
|
|
|
}
|
2016-03-13 22:05:07 -04:00
|
|
|
# For emerging with absolute paths
|
|
|
|
em(){
|
|
|
|
# Beep, verbose, ask
|
|
|
|
EMERGE_ARGS="-Ava"
|
|
|
|
X=""
|
|
|
|
for var in "$@"
|
|
|
|
do
|
|
|
|
if [[ "$var" =~ ^- ]]; then
|
|
|
|
EMERGE_ARGS="$EMERGE_ARGS $var"
|
|
|
|
else
|
|
|
|
X="$X =$var"
|
|
|
|
fi
|
|
|
|
done
|
2016-03-19 23:02:25 -04:00
|
|
|
echo sudo emerge "$EMERGE_ARGS""$X"
|
|
|
|
sudo emerge "$EMERGE_ARGS""$X"
|
2016-03-03 20:19:18 -05:00
|
|
|
echo "\a"
|
2015-07-29 16:27:13 -04:00
|
|
|
}
|
2016-01-26 13:47:55 -05:00
|
|
|
update(){
|
2015-08-25 10:14:40 -04:00
|
|
|
# If this is a server computer
|
2016-09-09 12:01:04 -04:00
|
|
|
if [ "$(hostname)" = "SGen" ] ; then
|
2015-08-25 10:14:40 -04:00
|
|
|
echo "You're a server. Exiting"
|
2015-09-11 11:05:34 -04:00
|
|
|
return
|
2015-08-25 10:14:40 -04:00
|
|
|
fi
|
2017-01-12 14:56:55 -05:00
|
|
|
sudo rm -f '/usr/portage/metadata/timestamp.chk'
|
2016-09-29 17:32:02 -04:00
|
|
|
if ex eix-update; then
|
2016-11-13 02:17:55 -05:00
|
|
|
sudo zsh -c "emaint sync -a&&eix-update"
|
2016-09-29 17:32:02 -04:00
|
|
|
else
|
2016-11-13 02:17:55 -05:00
|
|
|
sudo emaint sync -a
|
2016-09-29 17:32:02 -04:00
|
|
|
fi
|
|
|
|
sudo -k
|
2016-03-03 20:19:18 -05:00
|
|
|
echo '\a'
|
2015-08-25 10:14:40 -04:00
|
|
|
}
|
2015-07-31 16:52:21 -04:00
|
|
|
elif test -f /etc/lsb-release; then
|
|
|
|
# Ubuntu
|
|
|
|
alias install='sudo apt-get --show-progress install'
|
|
|
|
alias remove='sudo apt-get --show-progress remove'
|
|
|
|
alias update='sudo apt-get update'
|
|
|
|
alias upgrade='sudo apt-get --show-progress upgrade'
|
|
|
|
alias autoremove='sudo apt-get --show-progress autoremove'
|
|
|
|
alias updateall='sudo sh -c "apt-get update;apt-get upgrade -y;apt-get dist-upgrade -y;apt-get autoremove -y"'
|
2016-05-22 13:52:20 -04:00
|
|
|
alias search='apt-cache search'
|
2015-07-29 16:27:13 -04:00
|
|
|
fi
|
2014-08-11 01:09:13 -04:00
|
|
|
alias ..='k ..'
|
|
|
|
alias ...='k ../..'
|
|
|
|
alias ....='k ../../..'
|
|
|
|
alias .....='k ../../../..'
|
|
|
|
alias ......='k ../../../../..'
|
|
|
|
alias .......='k ../../../../../..'
|
|
|
|
alias ........='k ../../../../../../..'
|
|
|
|
alias .........='k ../../../../../../../..'
|
|
|
|
alias ..........='k ../../../../../../../../..'
|
|
|
|
alias ...........='k ../../../../../../../../../..'
|
|
|
|
alias ............='k ../../../../../../../../../../..'
|
|
|
|
alias .............='k ../../../../../../../../../../../..'
|
|
|
|
alias ..............='k ../../../../../../../../../../../../..'
|
|
|
|
alias ...............='k ../../../../../../../../../../../../../..'
|
2016-09-28 12:54:47 -04:00
|
|
|
if ex youtube-dl; then
|
|
|
|
alias ytdl="youtube-dl $@ -x --audio-format mp3 --audio-quality 0 -c -o '%(title)s.%(ext)s'"
|
|
|
|
fi
|
|
|
|
if ex wemux; then
|
|
|
|
alias tux="wemux"
|
|
|
|
elif ex tmux; then
|
|
|
|
alias tux="tmux a || tmux"
|
|
|
|
fi
|
|
|
|
if ex git; then
|
|
|
|
alias g="git"
|
|
|
|
fi
|
2015-04-18 23:12:55 -04:00
|
|
|
alias stdns="sudo sh -c 'echo nameserver 8.8.8.8 > /etc/resolv.conf'"
|
2014-11-22 19:14:54 -05:00
|
|
|
alias fvim="vim -u NONE +\"so ~/.vim/plugged/flappyvird-vim/plugin/flappyvird.vim\" +\"so ~/.vim/plugged/flappyvird-vim/autoload/flappyvird.vim\" +\":FlappyVird\" +\":q\""
|
2014-09-28 11:45:17 -04:00
|
|
|
alias fk='k `fzf --no-mouse -m -1 -x`'
|
2016-11-13 02:17:55 -05:00
|
|
|
#alias susp="sudo true&&((slock;sleep 2;nmcli radio wifi off;nmcli radio wifi on)&echo mem | sudo tee /sys/power/state >/dev/null);sudo -k"
|
|
|
|
alias susp="sudo true&&((slock;sleep 2;nmcli radio wifi off;nmcli radio wifi on)&echo mem|sudo tee /sys/power/state>/dev/null)"
|
2016-09-28 12:54:47 -04:00
|
|
|
if ex sudo; then
|
|
|
|
alias s='sudo -Hu'
|
|
|
|
fi
|
2016-09-27 13:48:54 -04:00
|
|
|
alias -g PA='2>&1 | paste'
|
2016-09-28 12:54:47 -04:00
|
|
|
if ex rsync; then
|
|
|
|
alias -g c='rsync --partial -ha --info=progress2 "$@"'
|
|
|
|
alias -g cfat='rsync --partial -hrlc --info=progress2 "$@"'
|
|
|
|
alias cp='rsync --partial -ha --info=progress2 "$@"'
|
|
|
|
fi
|
2016-05-22 13:52:20 -04:00
|
|
|
alias -g nify=" > /dev/null 2>&1 &"
|
|
|
|
alias -g nifyd=" > /dev/null 2>&1 & disown"
|
|
|
|
alias -g L="2>&1|less"
|
2016-09-28 12:54:47 -04:00
|
|
|
if ex ag; then
|
|
|
|
alias -g G='|& ag'
|
|
|
|
elif ex egrep; then
|
|
|
|
alias -g G='|& egrep'
|
|
|
|
elif ex grep; then
|
|
|
|
alias -g G='|& grep'
|
|
|
|
fi
|
2016-09-09 12:01:04 -04:00
|
|
|
timer() {
|
|
|
|
for i in {1.."$1"}; do
|
|
|
|
sleep 1
|
|
|
|
echo
|
|
|
|
done | pv -Sptels "$1" >/dev/null
|
|
|
|
}
|
2016-05-22 13:52:20 -04:00
|
|
|
fixsh(){
|
|
|
|
sed -i -e $1"d" ~/.ssh/known_hosts
|
|
|
|
}
|
|
|
|
mv() { /bin/mv -v "$@" }
|
|
|
|
m() { mv "$@" }
|
2016-07-21 08:27:31 -04:00
|
|
|
compdef _cp c cfat m mv cp
|
2016-04-19 17:26:16 -04:00
|
|
|
paste() {
|
2016-05-31 17:37:46 -04:00
|
|
|
NAME="-d title=Command run at $(date '+%d/%h/%y %H:%M:%S') on $(hostname)"
|
2016-04-19 17:26:16 -04:00
|
|
|
if [[ ! -z "$1" ]]; then
|
|
|
|
NAME="-d title=$1"
|
|
|
|
fi
|
2016-05-22 22:02:04 -04:00
|
|
|
sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g" | curl --data-urlencode text@- $NAME -d name=$USER -d expire="40320" https://austenwares.com/paste/api/create
|
2016-04-19 17:26:16 -04:00
|
|
|
}
|
2016-05-22 01:06:48 -04:00
|
|
|
grename() {
|
|
|
|
echo incomplete
|
|
|
|
return
|
|
|
|
FILES=($*)
|
|
|
|
REGEX='s///'
|
|
|
|
echo -n "Command (frneVVVq): "
|
|
|
|
while read input; do
|
|
|
|
case $input in
|
|
|
|
f)
|
|
|
|
echo "File list:"
|
|
|
|
printf '%s\n' $FILES
|
|
|
|
;;
|
|
|
|
r)
|
|
|
|
echo "Regex:"
|
|
|
|
echo "$REGEX"
|
|
|
|
;;
|
|
|
|
n)
|
|
|
|
echo "Simulated replacement:"
|
|
|
|
perl-rename -n "$REGEX" $FILES
|
|
|
|
;;
|
|
|
|
e)
|
|
|
|
echo "Editing regex..."
|
|
|
|
TEMPFILE=$(tempfile)
|
|
|
|
(cat <(printf '%s\n' $FILES);echo;echo "$REGEX") > $TEMPFILE
|
|
|
|
vim $TEMPFILE +'normal G$h'
|
|
|
|
REGEX=$(tac $TEMPFILE|grep -m1 '.')
|
|
|
|
rm $TEMPFILE
|
|
|
|
;;
|
|
|
|
VVV)
|
|
|
|
echo "Actual results:"
|
|
|
|
perl-rename -v $REGEX $FILES
|
|
|
|
return
|
|
|
|
;;
|
|
|
|
q)
|
|
|
|
return
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
echo -n "Command (frneVVVq): "
|
|
|
|
done
|
|
|
|
}
|
2016-03-13 01:11:23 -05:00
|
|
|
bp(){
|
|
|
|
echo '\a'
|
|
|
|
}
|
2016-03-03 20:19:18 -05:00
|
|
|
apush(){
|
|
|
|
adb push $* & pv -d $!
|
|
|
|
}
|
2016-03-28 12:36:55 -04:00
|
|
|
ltar(){
|
|
|
|
tar -cf - $@|pv -WcN tar|xz|pv -WcN lzma
|
2015-12-09 13:01:35 -05:00
|
|
|
#tar -cf - $@|pv -WcN tar -s $(echo $(du -sb $@|awk '{print $1}'|tr '\n' '+')0|bc)|gzip|pv -WcN dest
|
2015-07-16 16:51:57 -04:00
|
|
|
#tar -cf - $@|pv -WcN tar -s $(echo $(du -sb $@|awk '{print $1}'|tr '\n' '+')0|bc)|gzip|pv -WcN dest
|
2015-02-23 13:12:42 -05:00
|
|
|
}
|
2016-03-28 12:36:55 -04:00
|
|
|
ctar(){
|
|
|
|
tar -cf - $@|pv -WcN tar|gzip|pv -WcN gzip
|
|
|
|
}
|
2016-01-26 13:47:55 -05:00
|
|
|
offline(){
|
2016-01-21 12:20:18 -05:00
|
|
|
if [ ! -z "$@" ] ; then
|
2016-07-26 23:06:22 -04:00
|
|
|
sudo unshare -n -- sudo -u $USER zsh -c "$@"
|
2016-01-21 12:20:18 -05:00
|
|
|
else
|
2016-07-26 23:06:22 -04:00
|
|
|
sudo unshare -n -- sudo -u $USER LP_MARK_PREFIX=" $(tput setaf 1)(offline)$(tput sgr0) " zsh
|
2016-01-21 12:20:18 -05:00
|
|
|
fi
|
2014-12-27 04:35:51 -05:00
|
|
|
}
|
2016-01-26 13:47:55 -05:00
|
|
|
dnstest(){
|
2014-11-22 19:14:54 -05:00
|
|
|
echo "resolv.conf:"
|
|
|
|
cat /etc/resolv.conf
|
2014-12-07 13:52:33 -05:00
|
|
|
echo "Testing DNS:"
|
|
|
|
dig google.com
|
2014-08-29 09:46:43 -04:00
|
|
|
echo "Testing ping:"
|
2014-09-23 18:10:30 -04:00
|
|
|
ping -c 2 8.8.8.8
|
2014-08-29 09:46:43 -04:00
|
|
|
echo "Testing IP curl:"
|
2014-12-07 13:52:33 -05:00
|
|
|
curl -k http://98.26.78.121/b/
|
2014-11-22 19:14:54 -05:00
|
|
|
echo
|
2014-08-29 09:46:43 -04:00
|
|
|
echo "Testing DNS"
|
2014-09-20 23:09:10 -04:00
|
|
|
curl ifconfig.me
|
2014-08-29 09:46:43 -04:00
|
|
|
}
|
2016-01-26 13:47:55 -05:00
|
|
|
tsh(){
|
2016-02-21 13:50:30 -05:00
|
|
|
ssh -X $*
|
2014-08-11 01:09:13 -04:00
|
|
|
if which ponysay >/dev/null; then
|
|
|
|
ponysay "Connection closed!"
|
|
|
|
else
|
|
|
|
echo "\n\n\n\n\n\n\n\n\n\nSESSION CLOSED\n\n\n\n\n\n\n\n\n\n"
|
|
|
|
fi
|
|
|
|
}
|
2016-07-21 08:27:31 -04:00
|
|
|
compdefas () {
|
|
|
|
local a
|
|
|
|
a="$1"
|
|
|
|
shift
|
|
|
|
compdef "$_comps[$a]" "${(@)*}=$a"
|
|
|
|
}
|
|
|
|
compdefas ssh tsh
|
|
|
|
compdefas mv m mv
|
2016-01-26 13:47:55 -05:00
|
|
|
mcl(){
|
2015-07-22 16:28:39 -04:00
|
|
|
mkdir -p $1
|
2015-06-10 17:01:47 -04:00
|
|
|
cd $1
|
|
|
|
}
|
2016-03-19 23:03:41 -04:00
|
|
|
create-repo(){
|
|
|
|
PRIVATE="true"
|
|
|
|
while getopts ":p" opt; do
|
|
|
|
case $opt in
|
|
|
|
p)
|
|
|
|
echo "-p was used, making public"
|
|
|
|
PRIVATE="false"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo "No repo name" >&2
|
|
|
|
return 2
|
|
|
|
fi
|
|
|
|
echo -n "Username: "
|
|
|
|
read username
|
|
|
|
echo -n "Password: "
|
|
|
|
read -s password
|
|
|
|
curl --user "$username:$password" -d name="$1" -d private="$PRIVATE" https://austenwares.com/gogs/api/v1/user/repos
|
|
|
|
}
|
2016-06-04 16:08:50 -04:00
|
|
|
hsh(){
|
|
|
|
FILE="$1"
|
|
|
|
ARGS=""
|
|
|
|
while (( $# > 0 )); do
|
|
|
|
if [[ "md5" = "$1" ]] || [[ "md5sum" = "$1" ]] || [[ "m" = "$1" ]]; then
|
|
|
|
ARGS="$ARGS "md5sum
|
|
|
|
elif [[ "sha1" = "$1" ]] || [[ "sha1sum" = "$1" ]] || [[ "s" = "$1" ]]; then
|
|
|
|
ARGS="$ARGS "sha1sum
|
|
|
|
elif [[ "sha2" = "$1" ]] || [[ "sha256sum" = "$1" ]]; then
|
|
|
|
ARGS="$ARGS "sha256sum
|
|
|
|
elif [[ "sha512" = "$1" ]] || [[ "sha512sum" = "$1" ]]; then
|
|
|
|
ARGS="$ARGS "sha512sum
|
|
|
|
fi
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
ARGS=$(echo "$ARGS"|xargs)
|
|
|
|
echo "Calculating ($ARGS) of \"$FILE\""
|
|
|
|
echo pv "$FILE" \| pee $ARGS
|
|
|
|
pv "$FILE" | pee $(echo $ARGS)
|
|
|
|
}
|
2016-08-29 11:54:43 -04:00
|
|
|
enc() {
|
|
|
|
test -f README.md || echo "# enc\n## files" > README.md
|
|
|
|
while (( $# > 0 )) ; do
|
|
|
|
fn="$1"
|
|
|
|
uuid="$(uuidgen)"
|
|
|
|
shift
|
|
|
|
echo "Encrypting ($fn)..."
|
|
|
|
pv "$fn" | gpg -r stonewareslord -o "$uuid" -e - || (echo "Error encrypting $fn" >&2 ; continue)
|
|
|
|
echo "- \`$uuid\`: \`$fn\`" >> README.md || (echo "Error appending $fn to README.md" >&2 ; continue)
|
|
|
|
echo "Calculating sum of ($fn) in the background"
|
|
|
|
pv "$uuid" | sha512sum | perl -pe "s/-/$uuid/" >> SHA512SUMS || (echo "Error calculating sum of $uuid" >&2 ; continue)
|
|
|
|
rm "$fn" || (echo "Error removing $fn"; continue)
|
|
|
|
done
|
|
|
|
}
|
2016-01-26 13:47:55 -05:00
|
|
|
rc(){
|
2015-08-18 18:38:07 -04:00
|
|
|
case $1 in
|
|
|
|
z) vim ~/.zshrc;;
|
|
|
|
v) vim ~/.vimrc;;
|
|
|
|
i) vim ~/.i3/config;;
|
2015-08-23 11:44:31 -04:00
|
|
|
use) sudo vim /etc/portage/package.use/package.use;;
|
|
|
|
make) sudo vim /etc/portage/make.conf;;
|
2016-02-08 10:48:11 -05:00
|
|
|
unmask) sudo vim /etc/portage/package.unmask/package.unmask;;
|
2015-08-23 11:44:31 -04:00
|
|
|
mask) sudo vim /etc/portage/package.mask/package.mask;;
|
|
|
|
accept_keywords) sudo vim /etc/portage/package.accept_keywords/package.accept_keywords;;
|
2016-08-21 01:50:17 -04:00
|
|
|
keywords) sudo vim /etc/portage/package.keywords/package.keywords;;
|
2016-02-05 00:18:49 -05:00
|
|
|
license) sudo vim /etc/portage/package.license/package.license;;
|
2016-08-21 01:50:17 -04:00
|
|
|
*) echo "Opts:\nz v i\nuse make unmask mask accept_keywords keywords license"
|
2015-08-23 11:44:31 -04:00
|
|
|
esac
|
|
|
|
}
|
2016-01-26 13:47:55 -05:00
|
|
|
pub-git-init(){
|
2015-12-29 23:51:16 -05:00
|
|
|
# Get the project name
|
2015-12-31 12:55:30 -05:00
|
|
|
branch=$(git remote -v | ag '^origin\s+' | sed -e 's/^origin\s*//' | cut -d\ -f1 | sed -r -e 's/^.+\///' -e 's/#.+$//' -e 's/\.git$//' | head -n1)
|
|
|
|
echo "Branch: $branch"
|
2015-12-29 23:51:16 -05:00
|
|
|
# Get the hashed project name
|
2015-12-31 12:55:30 -05:00
|
|
|
enc_branch=$(echo "$branch" | sha512sum | cut -d\ -f1)
|
|
|
|
git remote add local "gcrypt::git@localhost:stonewareslord/79a79b1a6e37813d9226872c6428aca29eec9f6111558109861cb0dcd2f0ffc8198deea4e361f84e170989212452fdfb21e0ef690da2ad399c03ce308d79dcfe#$enc_branch"
|
2015-12-29 23:51:16 -05:00
|
|
|
git remote add ncsu "gcrypt::git@github.ncsu.edu:agadler/a86a0f8757772be2ec617b395a0716679bfce51c1bfdeb8da6127feebd84facde645e9e30188318344eb458f5834e3d86800.git#$enc_branch"
|
|
|
|
git remote add gitlab "gcrypt::git@gitlab.com:stonewareslord/e6e03ea006d55de0970a28bcb7fcf65f4c66f98f50830bd69b50c5dc502bdf1a4e4172187cfb5fcef8c32bd7fb316bdc67d7d86713ebfe232f97eb303ac316ae.git#$enc_branch"
|
2016-01-28 16:44:03 -05:00
|
|
|
git remote add aws "gcrypt::git@aws:stonewareslord/5e0701d5b5b2118127d378c084be9a1dfb33d185d3e2c5da30a3984f5118e3d5136f3f3b038462bccd538e93f9e32cb06136.git#$enc_branch"
|
2015-08-24 17:43:29 -04:00
|
|
|
git config remote.ncsu.gcrypt-participants "CCDFE3F1"
|
2015-12-29 23:51:16 -05:00
|
|
|
git config remote.gitlab.gcrypt-participants "CCDFE3F1"
|
2015-08-24 17:43:29 -04:00
|
|
|
}
|
2016-01-26 13:47:55 -05:00
|
|
|
pub-git-rm(){
|
2016-01-03 19:17:50 -05:00
|
|
|
if (( $# == 0 )) ; then
|
2015-12-31 12:55:30 -05:00
|
|
|
git remote rm local
|
|
|
|
git remote rm ncsu
|
|
|
|
git remote rm gitlab
|
2016-01-28 16:44:03 -05:00
|
|
|
git remote rm aws
|
2015-12-31 12:55:30 -05:00
|
|
|
fi
|
|
|
|
while (( $# > 0 )) ; do
|
|
|
|
git remote rm "$1"
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
}
|
2016-01-26 13:47:55 -05:00
|
|
|
pub-git-push(){
|
2015-12-31 13:02:45 -05:00
|
|
|
if (( $# == 0 )) ; then
|
2015-12-31 12:55:30 -05:00
|
|
|
git push local --all && git push local --tags
|
|
|
|
git push ncsu --all && git push ncsu --tags
|
|
|
|
git push gitlab --all && git push gitlab --tags
|
2016-01-28 16:44:03 -05:00
|
|
|
git push aws --all && git push aws --tags
|
2015-12-31 12:55:30 -05:00
|
|
|
fi
|
|
|
|
while (( $# > 0 )) ; do
|
|
|
|
git push "$1" --all && git push "$1" --tags
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
}
|
2016-01-26 13:47:55 -05:00
|
|
|
pub-git-clone(){
|
2015-12-29 23:51:16 -05:00
|
|
|
case $1 in
|
|
|
|
ncsu) remote="gcrypt::git@github.ncsu.edu:agadler/a86a0f8757772be2ec617b395a0716679bfce51c1bfdeb8da6127feebd84facde645e9e30188318344eb458f5834e3d86800.git#" ;;
|
|
|
|
gitlab) remote="gcrypt::git@gitlab.com:stonewareslord/e6e03ea006d55de0970a28bcb7fcf65f4c66f98f50830bd69b50c5dc502bdf1a4e4172187cfb5fcef8c32bd7fb316bdc67d7d86713ebfe232f97eb303ac316ae.git#" ;;
|
2015-12-31 12:55:30 -05:00
|
|
|
local) remote="gcrypt::git@localhost:stonewareslord/79a79b1a6e37813d9226872c6428aca29eec9f6111558109861cb0dcd2f0ffc8198deea4e361f84e170989212452fdfb21e0ef690da2ad399c03ce308d79dcfe#" ;;
|
2016-01-28 16:44:03 -05:00
|
|
|
aws) remote="gcrypt::git@aws:stonewareslord/5e0701d5b5b2118127d378c084be9a1dfb33d185d3e2c5da30a3984f5118e3d5136f3f3b038462bccd538e93f9e32cb06136.git#" ;;
|
2015-12-31 12:55:30 -05:00
|
|
|
*) echo "Opts: local ncsu gitlab" ; return 1
|
2015-12-29 23:51:16 -05:00
|
|
|
esac
|
|
|
|
shift
|
|
|
|
if [ -z "$1" ] ; then
|
|
|
|
echo "No arg2"
|
|
|
|
return 2
|
|
|
|
fi
|
2015-08-24 17:43:29 -04:00
|
|
|
branch=$(echo $1 | sha512sum | cut -d\ -f1)
|
2015-12-29 23:51:16 -05:00
|
|
|
git clone "$remote$branch" $1
|
2015-08-24 17:43:29 -04:00
|
|
|
}
|
2016-01-26 13:47:55 -05:00
|
|
|
k(){
|
2015-06-10 17:01:47 -04:00
|
|
|
#More than 1 arguement
|
2014-08-11 01:09:13 -04:00
|
|
|
if [[ $# > 1 ]] ; then
|
2015-06-10 17:01:47 -04:00
|
|
|
vim $@
|
2014-08-11 01:09:13 -04:00
|
|
|
elif [ -d "$@" ] ; then
|
2014-08-30 15:59:01 -04:00
|
|
|
#cd then ls
|
2014-08-11 01:09:13 -04:00
|
|
|
cd "$@" && ls
|
2014-08-11 15:14:46 -04:00
|
|
|
elif [[ "$@" == "-" ]] ; then
|
2014-08-30 15:59:01 -04:00
|
|
|
#Because if this isn't here, k - won't work
|
2014-08-11 01:09:13 -04:00
|
|
|
cd - && ls
|
|
|
|
elif [ -f "$@" ] ; then
|
2014-08-30 15:59:01 -04:00
|
|
|
#Extract if it's extractable
|
2014-08-11 01:09:13 -04:00
|
|
|
case $1 in
|
2015-08-23 12:38:10 -04:00
|
|
|
*.tar.xz) pv $1|tar -xJf - ;;
|
2016-05-22 13:52:20 -04:00
|
|
|
*.txz) pv $1|tar -xJf - ;;
|
2015-08-23 12:38:10 -04:00
|
|
|
*.tar.bz2) pv $1|tar -xjf - ;;
|
|
|
|
*.tar.gz) pv $1|tar -xzf - ;;
|
|
|
|
*.tar) pv $1|tar -xf - ;;
|
|
|
|
*.tbz2) pv $1|tar -xjf - ;;
|
|
|
|
*.tgz) pv $1|tar -xzf - ;;
|
|
|
|
*.lzma) pv $1|tar --lzma -xf - ;;
|
|
|
|
*.xz) pv $1|tar -xJf - ;;
|
|
|
|
*.bz2) bunzip2 $1 ;;
|
2016-08-18 00:58:32 -04:00
|
|
|
*.rar) unrar x $1 ;;
|
2015-08-23 12:38:10 -04:00
|
|
|
*.gz) gunzip $1 ;;
|
|
|
|
*.zip) unzip $1 ;;
|
|
|
|
*.Z) uncompress $1 ;;
|
|
|
|
*.7z) 7z x $1 ;;
|
|
|
|
*.lrz) lrzuntar $1 ;;
|
2014-08-11 01:09:13 -04:00
|
|
|
*) vim $1
|
|
|
|
esac
|
|
|
|
else
|
2015-06-10 17:01:47 -04:00
|
|
|
#Edit with vim
|
|
|
|
echo -n "vim? "
|
2014-08-11 01:09:13 -04:00
|
|
|
read a
|
2015-06-10 17:01:47 -04:00
|
|
|
vim "$@"
|
2014-08-11 01:09:13 -04:00
|
|
|
fi
|
|
|
|
}
|
2016-09-28 12:54:47 -04:00
|
|
|
if (( $+TMUX )) || [[ "$TERM" = "screen-256color" ]] || [[ "$TERM" = "screen.xterm-256color" ]]; then
|
|
|
|
unset zle_bracketed_paste
|
|
|
|
fi
|
|
|
|
#(( $+TMUX )) && unset zle_bracketed_paste
|
2016-02-05 00:18:49 -05:00
|
|
|
|
|
|
|
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
2016-09-28 12:54:47 -04:00
|
|
|
if ex fasd; then
|
2016-07-18 19:54:00 -04:00
|
|
|
eval "$(fasd --init auto)"
|
|
|
|
fi
|
2016-05-22 13:52:20 -04:00
|
|
|
|
|
|
|
#Old config options that are no longer in use
|
|
|
|
#alias pg="pcregrep -M"
|
|
|
|
#if command -v greadlink 2>&1 >/dev/null; then
|
|
|
|
# alias readlink='greadlink'
|
|
|
|
#fi
|
2016-07-26 23:06:22 -04:00
|
|
|
#alias steamo='sudo kill -9 `pidof steam`;sudo unshare -n -- sh -c "ifconfig lo up;sudo -u $USER steam" > /dev/null 2>&1 & disown'
|
2016-05-22 13:52:20 -04:00
|
|
|
#alias bat='upower -i /org/freedesktop/UPower/devices/battery_BAT0| grep -E "state|to\ full|percentage"'
|
|
|
|
#alias aoeu='setxkbmap -layout us -option "'
|
|
|
|
#alias asdf='setxkbmap -layout dvorak -option ""'
|
|
|
|
#alias sudo='sudo -H'
|
2016-07-25 03:53:50 -04:00
|
|
|
echo -ne '[# ]\r'
|
2016-07-18 16:55:56 -04:00
|
|
|
source ~/.zsh-git/lpr/liquidprompt
|
|
|
|
source ~/.zsh-git/omg/base.sh
|
|
|
|
source ~/.zsh-git/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
|
|
|
source ~/.zsh-git/oh-my-git-themes/af-magic.zsh-theme
|
2016-07-25 03:53:50 -04:00
|
|
|
echo -e '[##]'
|
2016-07-18 16:41:37 -04:00
|
|
|
#zprof
|