232 lines
4.5 KiB
Bash
232 lines
4.5 KiB
Bash
autoload -U promptinit
|
|
promptinit
|
|
|
|
autoload -U colors
|
|
colors
|
|
|
|
autoload -U compinit
|
|
compinit
|
|
|
|
HISTSIZE=10000
|
|
SAVEHIST=10000
|
|
HISTFILE="$HOME/.zsh_history"
|
|
|
|
PROMPT="%{$fg[white]%}╭─%{$fg[green]%}%M %{$fg[red]%}▶ %{$fg[yellow]%}%~
|
|
%{$fg[white]%}╰─%B%#%b "
|
|
RPROMPT="%{$fg[red]%}%? %{$fg[white]%}%*%{$reset_color%}"
|
|
|
|
PATH="$PATH:$HOME/bin"
|
|
|
|
man() {
|
|
env LESS_TERMCAP_mb=$'\E[01;31m' \
|
|
LESS_TERMCAP_md=$'\E[01;38;5;74m' \
|
|
LESS_TERMCAP_me=$'\E[0m' \
|
|
LESS_TERMCAP_se=$'\E[0m' \
|
|
LESS_TERMCAP_so=$'\E[38;5;246m' \
|
|
LESS_TERMCAP_ue=$'\E[0m' \
|
|
LESS_TERMCAP_us=$'\E[04;38;5;146m' \
|
|
man "$@"
|
|
}
|
|
|
|
### VARIABLES
|
|
export EDITOR="vim"
|
|
export VISUAL="vim"
|
|
|
|
### BOOKMARKS
|
|
bm() {
|
|
case "$1" in
|
|
dev)
|
|
cd "$HOME/development/projects"
|
|
;;
|
|
dot)
|
|
cd "$HOME/dotfiles"
|
|
;;
|
|
*)
|
|
echo "unknown target"
|
|
;;
|
|
esac
|
|
}
|
|
|
|
|
|
### SHELL OPTIONS
|
|
setopt EXTENDED_HISTORY
|
|
setopt HIST_EXPIRE_DUPS_FIRST
|
|
setopt HIST_VERIFY
|
|
setopt INC_APPEND_HISTORY
|
|
setopt SHARE_HISTORY
|
|
setopt AUTO_CD
|
|
setopt APPEND_HISTORY
|
|
setopt HIST_IGNORE_DUPS
|
|
setopt NOHIST_IGNORE_ALL_DUPS
|
|
setopt HIST_IGNORE_SPACE
|
|
setopt CORRECT
|
|
setopt RM_STAR_SILENT
|
|
setopt BG_NICE
|
|
setopt CHECK_JOBS
|
|
setopt HUP
|
|
setopt LONG_LIST_JOBS
|
|
|
|
bindkey -e
|
|
|
|
|
|
[[ $TERM == "urxvt" ]] && export TERM="rxvt-unicode"
|
|
|
|
### ALIASES
|
|
|
|
alias su="su -"
|
|
|
|
LS_HIDE="*.py[co]"
|
|
|
|
# --dereference-command-line
|
|
alias ls="ls --group-directories-first --classify --color=auto --hide=\"$LS_HIDE\""
|
|
|
|
alias ll='ls -AlF'
|
|
alias la='ls -A'
|
|
|
|
alias grep='grep --color=auto'
|
|
alias fgrep='fgrep --color=auto'
|
|
alias egrep='egrep --color=auto'
|
|
|
|
alias rm='rm -v'
|
|
alias cp='cp -v'
|
|
alias mv='mv -v'
|
|
alias ln='ln -v'
|
|
|
|
alias du='du -h'
|
|
alias df='df -h'
|
|
|
|
alias root='sudo -sE'
|
|
|
|
alias b='cd $OLDPWD'
|
|
|
|
alias cs="cryptsetup"
|
|
|
|
alias le_haxxor_1='clear && dmesg | pv -qL $[15 + (RANDOM % 10)]'
|
|
alias le_haxxor_2='clear && hexdump -C /dev/urandom | grep "1e 4c"'
|
|
|
|
alias YOLO="pacman -Syu --force"
|
|
|
|
alias such="git"
|
|
alias very="git"
|
|
alias much="git"
|
|
alias wow="git status"
|
|
|
|
alias v="vim"
|
|
alias g="git"
|
|
|
|
|
|
# rebase the current branch onto WTF ARE YOU DOING YOU ARE DRUNNK TO GO BED
|
|
##alias rebase="git rebase -i $(git branch --contains HEAD | grep -v '\*.*' | head -1)"
|
|
|
|
|
|
### FUNCTIONS
|
|
|
|
slideshow() {
|
|
delay=$1
|
|
[[ -z "$delay" ]] && { echo "wrong usage" ; return 1 ; }
|
|
shift
|
|
[[ -z "$@" ]] && { echo "wrong usage" ; return 1 ; }
|
|
feh --auto-zoom \
|
|
--randomize \
|
|
--recursive \
|
|
--scale-down \
|
|
--image-bg black \
|
|
--draw-filename \
|
|
--slideshow-delay=$delay \
|
|
"$@"
|
|
}
|
|
|
|
cd() {
|
|
builtin cd $* && ls
|
|
}
|
|
|
|
mount() {
|
|
if [[ $# == 0 ]] ; then
|
|
/usr/bin/env mount | column -t
|
|
else
|
|
/usr/bin/env mount $*
|
|
fi
|
|
}
|
|
|
|
ff() {
|
|
find . -type f -iname "*"$*"*" ;
|
|
}
|
|
|
|
ffcs() {
|
|
find . -type f -name "*"$*"*" ;
|
|
}
|
|
|
|
extr()
|
|
{
|
|
if [[ -f "$1" ]] ; then
|
|
case "$1" in
|
|
*.tar.bz2 ) tar xvjf "$1" ;;
|
|
*.tar.gz ) tar xvzf "$1" ;;
|
|
*.tar.xz ) tar xvJf "$1" ;;
|
|
*.bz2 ) bunzip2 "$1" ;;
|
|
*.rar ) unrar x "$1" ;;
|
|
*.gz ) gunzip "$1" ;;
|
|
*.tar ) tar xvf "$1" ;;
|
|
*.tbz2 ) tar xvjf "$1" ;;
|
|
*.tgz ) tar xvzf "$1" ;;
|
|
*.zip ) unzip "$1" ;;
|
|
*.Z ) uncompress "$1" ;;
|
|
*.7z ) 7z x "$1" ;;
|
|
*)
|
|
echo "$1 cannot be extracted via $0"
|
|
;;
|
|
esac
|
|
else
|
|
echo "$1 is not a valid file"
|
|
fi
|
|
}
|
|
|
|
ruler() {
|
|
for s in '....^....|' '1234567890'; do
|
|
w=${#s}
|
|
str=$(for (( i=1; $i<=$(( ($COLUMNS + $w) / $w )) ; i=$i+1 )); do echo -n $s; done )
|
|
str=$(echo $str | cut -c -$COLUMNS)
|
|
echo $str
|
|
done
|
|
}
|
|
|
|
addext() {
|
|
[[ -z "$1" ]] || [[ -z "$2" ]] && { echo "Usage: $0 <file> <extension>" ; return }
|
|
mv "$1" "$1$2"
|
|
|
|
}
|
|
|
|
ckwww() {
|
|
ping -c 3 www.google.com
|
|
}
|
|
|
|
topcmds() {
|
|
history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -nr | head
|
|
}
|
|
|
|
fnottype() {
|
|
find . -maxdepth 1 ! -type $1
|
|
}
|
|
|
|
# simple calculator
|
|
c () {
|
|
echo "$*" | bc -l
|
|
}
|
|
|
|
http() {
|
|
curl http://httpcode.info/$1
|
|
}
|
|
|
|
bak() {
|
|
[[ -e "$1" ]] && cp -ai "$1" "$1.$(date +%FT%T).bak"
|
|
}
|
|
|
|
fstab() {
|
|
# yeah
|
|
expand /etc/fstab | grep -v '^#' | grep -P '^.+$' | tr -s ' ' | tr ' ' '|' | cat <(grep -P '<.+>' /etc/fstab | cut -f 2- -d ' ' | sed 's/>[^<]*</>|</g') - | column -ts '|'
|
|
}
|
|
|
|
rmext() {
|
|
[[ -e "$1" ]] && mv -i "$1" "${1%.*}"
|
|
}
|