dotfiles/.zshrc

170 lines
4.6 KiB
Bash
Raw Normal View History

# Lines configured by zsh-newuser-install
function 0 { screen -X at 0 stuff "$@ " }
function 1 { screen -X at 1 stuff "$@ " }
function 2 { screen -X at 2 stuff "$@ " }
function 3 { screen -X at 3 stuff "$@ " }
function 4 { screen -X at 4 stuff "$@ " }
function 5 { screen -X at 5 stuff "$@ " }
2020-02-09 12:29:17 -05:00
HISTFILE=~/.histfile
HISTSIZE=10000
SAVEHIST=10000
setopt appendhistory autocd notify
setopt menu_complete
unsetopt beep
bindkey -v
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
[ -z "$PS1" ] && return
2020-02-09 12:29:17 -05:00
zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate
zstyle ':completion:*' matcher-list '+' '+m:{[:lower:]}={[:upper:]}' '+m:{[:lower:][:upper:]}={[:upper:][:lower:]}' '+r:|[._-]=** r:|=** l:|=*'
zstyle :compinstall filename '/home/cprtools/.zshrc'
2020-02-09 12:29:17 -05:00
autoload -Uz compinit
compinit
# End of lines added by compinstall
source ~/.shell_aliases
2020-02-09 12:29:17 -05:00
autoload -Uz vcs_info
precmd() { vcs_info }
2020-02-09 12:29:17 -05:00
zstyle ':vcs_info:git:*' formats ' [%b]'
2020-02-09 12:29:17 -05:00
setopt PROMPT_SUBST
PROMPT='[%(!.%B%F{red}.%B%F{blue})%n%B%F{white}@%m%b%f] %b%F{green}%~%B%F{yellow}${vcs_info_msg_0_} %B%f$%b%f '
2020-02-09 12:29:17 -05:00
# 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=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
2020-02-09 12:29:17 -05:00
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
2020-02-09 12:29:17 -05:00
export PATH=./:$PATH
alias df="df -h"
fignore=(o)
function SetTtyColors() {
echo -en "\e]P0191e1f" #black 1
echo -en "\e]P1dc4848" #darkgrey 2
echo -en "\e]P200aa00" #darkred 3
echo -en "\e]P3d99f4e" #red 4
echo -en "\e]P44444aa" #darkgreen 5
echo -en "\e]P5c436b9" #green 6
echo -en "\e]P600aaaa" #brown 7
echo -en "\e]P7d7d7d7" #yellow 8
echo -en "\e]P87b7b7b" #darkblue 9
echo -en "\e]P9ff6f6f" #blue 10
echo -en "\e]PA55ff55" #darkmagenta11
echo -en "\e]PBffed8b" #magenta 12
echo -en "\e]PC5555ff" #darkcyan 13
echo -en "\e]PDff6eff" #cyan 14
echo -en "\e]PE55ffff" #lightgray 15
echo -en "\e]PFaaaaaa" #white 16
clear
}
2020-02-09 12:29:17 -05:00
if [ "$TERM" = "linux" ]; then
SetTtyColors
fi
2020-02-09 12:29:17 -05:00
[ -z "$STY" ] && screen -x -p + -A
2020-02-09 12:29:17 -05:00
function _open2(){
var=$(fc -ln -1);
if [[ $var != *"grep"* ]]; then;
return;
fi;
var=$(sed "s/grepr/grepr -l/" <<< $var);
vim -p `zsh -c "$var" | grep $1`
}
2020-02-09 12:29:17 -05:00
# After running grepr, `open` plus a match will
# search history for the most recent grepr,
# and open the first file matching the text
# in Vim, at the first matching line number
function _open(){
command=$(fc -ln -1);
count=1;
while [[ $command != *"grepr"* ]]; do
((count++))
command=$(fc -ln -$count | head -n 1);
done;
# echo '$@'
line=$(zsh -c "$command" | grep $1 | sed "s/^[^:]*://g" | sed "s/:.*//" | head -n 1);
echo $line;
file=$(zsh -c "$command" | grep $1 | sed "s/:.*//" | head -n 1);
echo $file;
vim +$line -p `echo $file`;
2020-02-09 12:29:17 -05:00
}
2020-02-09 12:29:17 -05:00
bindkey "OA" history-search-backward
bindkey "OB" history-search-forward
function cd {
builtin cd "$@" && ls -F
}
function note() {
builtin echo "$@" >> ~/.notes
}
2020-02-09 12:29:17 -05:00
function wis() {
echo -en "\n\e[36m"
# Get a random comment
WISDOM=""
while [[ "$WISDOM" != \#* || "$WISDOM" == \#!* || "$WISDOM" == \#\ alia* ]]
do
ALIAS_COUNT=$(cat ~/.shell_aliases ~/.wisdom | wc -l)
RAN=$RANDOM
RAN=$(($RAN % $ALIAS_COUNT))
WISDOM=$(tail -n+$RAN <(cat ~/.shell_aliases ~/.wisdom) | head -n1)
done
# Search upward for the comment's start
RAN=$(($RAN - 1))
ADDWIS=$(tail -n+$RAN ~/.shell_aliases ~/.wisdom | head -n1)
while [[ "$ADDWIS" == \#* && "$ADDWIS" != \#!* && "$ADDWIS" != \#\ alia* ]]
do
WISDOM=$ADDWIS
RAN=$(($RAN - 1))
ADDWIS=$(tail -n+$RAN <(cat ~/.shell_aliases ~/.wisdom) | head -n1)
done
# Add until comment's end
RAN=$(($RAN + 2))
ADDWIS=$(tail -n+$RAN <(cat ~/.shell_aliases ~/.wisdom) | head -n1)
while [[ "$ADDWIS" == \#* && "$ADDWIS" != \#!* && "$ADDWIS" != \#\ alia* ]]
do
WISDOM+="\n"
WISDOM+=$ADDWIS
RAN=$(($RAN + 1))
ADDWIS=$(tail -n+$RAN <(cat ~/.shell_aliases ~/.wisdom) | head -n1)
done
echo $WISDOM
echo -en "\n\e[0m"
}
function pushdot {
cd ~/.dotfiles &&
2020-02-09 12:54:34 -05:00
if [ $# -eq 0 ]; then
git add .* && git commit && git push -u origin master
else
git add .* && git commit -m "$1" && git push -u origin master
fi
cd -
}
2020-02-09 13:43:19 -05:00
cat ~/.notes
wis