From a457f85c1faa7639db536a9217a244f85ae89bd6 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Tue, 21 Apr 2020 12:39:18 -0400 Subject: [PATCH] More fleshed-out aliases and zsh, plus copy.sh --- .shell_aliases | 96 +++++++++++------ .zshrc | 283 ++++++++++++++++++++++++++----------------------- copy.sh | 3 + 3 files changed, 214 insertions(+), 168 deletions(-) create mode 100755 copy.sh diff --git a/.shell_aliases b/.shell_aliases index 3dc44aa..2de4142 100644 --- a/.shell_aliases +++ b/.shell_aliases @@ -1,39 +1,67 @@ -# short-hand -alias ml="mpc listall" -alias gre="grep" -alias rmr="rm -r" -alias rmrt="rm -r *" -alias gv="grep -v" -alias lsg="ls | grep" -alias pgrep="ps aux | grep -v grep | grep" -alias sql="mysql -u vaillanc --password='rdc52ty5' -h dbsrv2.cs.fsu.edu vaillancdb" -alias pp="poweroff" +#!/bin/bash -alias sshfsu="ssh -YC $fsu" +# Use `al` to view and edit aliases +alias al="vim ~/.shell_aliases && source ~/.shell_aliases" -# sanity adjustments -alias free="free -h" -alias rmlint="rmlint -L" -alias mkdir="mkdir -p" -alias du="du -sh" -alias df="df -h | grep -v tmpfs | grep -v ^dev | grep -v ^run" -alias py="python" -alias quota="quota -s" +# Sudo commands will turn red +alias sudo='echo -e "\e[1;31m" && sudo' -# vim aliases -alias vi="vim " -alias vim="vim " -alias bim="vim " -alias cim="vim " +# Edit current wisdom with `wim` +alias wim="vim ~/.wisdom" -# and config file shortcuts -alias vimc="vim ~/.vimrc" -alias vv="vim ~/.vimrc" -alias zz="vim ~/.zshrc && source ~/.zshrc" -alias al='vim ~/.shell_aliases && source ~/.shell_aliases' +alias vim="vi" +alias cim="vi" -# Sudo McDoDoh -alias pacman='sudo pacman' -alias mount='sudo mount' -alias umount='sudo umount' -alias fuck='sudo $(fc -ln -1)' +# Use `vimc` to edit ~/.vimrc +alias v="vi ~/.vimrc" +alias vimc="vi ~/.vimrc" +alias cimc="vi ~/.vimrc" +alias vims="vi -S" + +# Use `zz` to edit ~/.zshrc +alias zz='vim ~/.zshrc && source ~/.zshrc' +alias termrc='vim ~/.config/xfce4/terminal/terminalrc' + +# Use `bb` and `uu` to build and apply bpi kernel changes +alias bb="echo '\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n' && cd ~/Desktop/Griffin/bpi_build_scripts/ && sudo ./bbuild.sh 3 && cd -" +alias qbb="echo '\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n\\n' && cd ~/Desktop/Griffin/bpi_build_scripts/ && sudo ./bbuild.sh 3 && cd -" +alias uu="cd ~/Desktop/Griffin/bpi_build_scripts/ && sudo ./update_sd.sh /dev/sde && cd -" + +# Use `grepr` for a recursive, case-insensitive, and filtered grep +# alias grepr="grep -RInsi --color=auto --exclude-dir=.git --exclude=tags" +# alias grepr='grep -RInsi --color=auto --exclude-dir=.git --exclude-dir=banana_pi_kernel --exclude-dir={bpi_build_scripts, storm_dox, sam_dox} --exclude=tags --exclude=\*.{ko, o}' +alias grepr='grep -RInsi --color=auto --exclude-dir=.git --exclude-dir=banana_pi_kernel --exclude-dir=bpi_build_scripts --exclude=tags --exclude="*.ko"' + +alias apt="sudo apt" +alias apt-get="sudo apt-get" +alias eject="sudo eject" +alias dpkg="sudo dpkg" +alias dpi="sudo dpkg -i" + +# Use `fin` to search for files by name +alias fin="find -iname " + +alias python="python3" + +# Use `grubdate` to update grub +alias grubdate="sudo update-grub" + +# Use `n` and `nn` to edit and view notes +alias n="vim ~/.notes && clear && cat ~/.notes && wis" +alias nn="cat ~/.notes && wis" + +# Use `open` after `grepr` to vim a file with grep text matching $1 +alias open=_open +alias open2=_open2 + +# `pp` and `pwoeroff` -> `poweroff` +alias pp=poweroff +alias pwoeroff=poweroff + +# Use `ll` to get a detailed list of files +alias ll='ls --color=auto -Flh -w 80' +alias ls='ls --color=auto -F -w 80' + +alias tags='ctags -f newtags -R . && mv newtags tags' + +alias newvpn='sudo openvpn --config ~/.ssh/sagev.ovpn' diff --git a/.zshrc b/.zshrc index 32957a1..3ae0461 100644 --- a/.zshrc +++ b/.zshrc @@ -1,135 +1,159 @@ -# If you come from bash you might have to change your $PATH. -# export PATH=$HOME/bin:/usr/local/bin:$PATH +# 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 "$@ " } -# Path to your oh-my-zsh installation. -ZSH=~/.oh-my-zsh - -# Set name of the theme to load --- if set to "random", it will -# load a random theme each time oh-my-zsh is loaded, in which case, -# to know which specific one was loaded, run: echo $RANDOM_THEME -# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes -ZSH_THEME="kolo" -# michelebologna - -# Set list of themes to pick from when loading at random -# Setting this variable when ZSH_THEME=random will cause zsh to load -# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/ -# If set to an empty array, this variable will have no effect. -# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) - -# Uncomment the following line to use case-sensitive completion. -# CASE_SENSITIVE="true" - -# Uncomment the following line to use hyphen-insensitive completion. -# Case-sensitive completion must be off. _ and - will be interchangeable. -# HYPHEN_INSENSITIVE="true" - -# Uncomment the following line to disable bi-weekly auto-update checks. -DISABLE_AUTO_UPDATE="true" - -# Uncomment the following line to automatically update without prompting. -# DISABLE_UPDATE_PROMPT="true" - -# Uncomment the following line to change how often to auto-update (in days). -# export UPDATE_ZSH_DAYS=13 - -# Uncomment the following line if pasting URLs and other text is messed up. -# DISABLE_MAGIC_FUNCTIONS=true - -# Uncomment the following line to disable colors in ls. -# DISABLE_LS_COLORS="true" - -# Uncomment the following line to disable auto-setting terminal title. -# DISABLE_AUTO_TITLE="true" - -# Uncomment the following line to enable command auto-correction. -# ENABLE_CORRECTION="true" - -# Uncomment the following line to display red dots whilst waiting for completion. -# COMPLETION_WAITING_DOTS="true" - -# Uncomment the following line if you want to disable marking untracked files -# under VCS as dirty. This makes repository status check for large repositories -# much, much faster. -# DISABLE_UNTRACKED_FILES_DIRTY="true" - -# Uncomment the following line if you want to change the command execution time -# stamp shown in the history command output. -# You can set one of the optional three formats: -# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" -# or set a custom format using the strftime function format specifications, -# see 'man strftime' for details. -# HIST_STAMPS="mm/dd/yyyy" - -# Would you like to use another custom folder than $ZSH/custom? -# ZSH_CUSTOM=/path/to/new-custom-folder - -# Which plugins would you like to load? -# Standard plugins can be found in ~/.oh-my-zsh/plugins/* -# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ -# Example format: plugins=(rails git textmate ruby lighthouse) -# Add wisely, as too many plugins slow down shell startup. -plugins=(git) - - -# User configuration - -# export MANPATH="/usr/local/man:$MANPATH" - -# You may need to manually set your language environment -# export LANG=en_US.UTF-8 - -# Preferred editor for local and remote sessions -# if [[ -n $SSH_CONNECTION ]]; then -# export EDITOR='vim' -# else -# export EDITOR='mvim' -# fi - -# Compilation flags -# export ARCHFLAGS="-arch x86_64" - -# Set personal aliases, overriding those provided by oh-my-zsh libs, -# plugins, and themes. Aliases can be placed here, though oh-my-zsh -# users are encouraged to define aliases within the ZSH_CUSTOM folder. -# For a full list of active aliases, run `alias`. -# -# Example aliases -# alias zshconfig="mate ~/.zshrc" -# alias ohmyzsh="mate ~/.oh-my-zsh" - -ZSH_CACHE_DIR=$HOME/.cache/oh-my-zsh -if [[ ! -d $ZSH_CACHE_DIR ]]; then - mkdir $ZSH_CACHE_DIR -fi - -source $ZSH/oh-my-zsh.sh +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 zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate -zstyle ':completion:*' matcher-list '+m:{[:lower:]}={[:upper:]}' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|[._-]=** r:|=**' 'l:|=* r:|=*' -zstyle :compinstall filename '/home/sage/.zshrc' - -autoload -U up-line-or-beginning-search -autoload -U down-line-or-beginning-search -bindkey '^[[A' up-line-or-search -bindkey '^[[B' down-line-or-search +zstyle ':completion:*' matcher-list '+' '+m:{[:lower:]}={[:upper:]}' '+m:{[:lower:][:upper:]}={[:upper:][:lower:]}' '+r:|[._-]=** r:|=** l:|=*' +zstyle :compinstall filename '/home/cprtools/.zshrc' autoload -Uz compinit compinit # End of lines added by compinstall -# Lines configured by zsh-newuser-install -HISTFILE=~/.histfile -HISTSIZE=10000 -SAVEHIST=10000 -setopt appendhistory autocd extendedglob -unsetopt beep -bindkey -v -# End of lines configured by zsh-newuser-install - source ~/.shell_aliases -export fsu="vaillanc@linprog.cs.fsu.edu" -export EDITOR='vim' + +autoload -Uz vcs_info +precmd() { vcs_info } + +zstyle ':vcs_info:git:*' formats ' [%b]' + +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 ' + +# 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' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +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 +} + +if [ "$TERM" = "linux" ]; then + SetTtyColors +fi + +[ -z "$STY" ] && screen -x -p + -A + +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` +} + +# 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`; + +} + +bindkey "OA" history-search-backward +bindkey "OB" history-search-forward +function cd { + builtin cd "$@" && ls -F +} + +function note() { + builtin echo "$@" >> ~/.notes +} + +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 && @@ -141,14 +165,5 @@ function pushdot { cd - } -codi() { - local syntax="${1:-python}" - shift - vim -c \ - "let g:startify_disable_at_vimenter = 1 |\ - set bt=nofile ls=0 noru nonu nornu |\ - hi ColorColumn ctermbg=NONE |\ - hi VertSplit ctermbg=NONE |\ - hi NonText ctermfg=0 |\ - Codi $syntax" "$@" -} +cat ~/.notes +wis diff --git a/copy.sh b/copy.sh new file mode 100755 index 0000000..2276884 --- /dev/null +++ b/copy.sh @@ -0,0 +1,3 @@ +#!/bin/bash +ln -sf ~/.dotfiles/.* ~/ +yes | rm -r ~/.git