abra zsh config 2.0
This commit is contained in:
56
.zprezto/abra/aliases.zsh
Normal file
56
.zprezto/abra/aliases.zsh
Normal file
@@ -0,0 +1,56 @@
|
||||
alias g="git"
|
||||
alias a="git add --all :/"
|
||||
alias b="git branch"
|
||||
alias c="git commit -am"
|
||||
alias ch="git checkout"
|
||||
alias pull="git pull"
|
||||
alias rb="git reset HEAD --hard"
|
||||
alias s="git status"
|
||||
alias st="git stash"
|
||||
|
||||
# alias g5="git5"
|
||||
# alias e="git5 export"
|
||||
# alias m="git5 merge --no-ff"
|
||||
# alias ma="git5 mail -m"
|
||||
# alias push="git5 submit -xy"
|
||||
# alias push="git submit -xy"
|
||||
alias dc="a && c \"dummy comment\""
|
||||
# alias dcp="a; dc; git push"
|
||||
|
||||
alias zshconfig="subl ~/.zshrc"
|
||||
alias zshreload="exec zsh"
|
||||
|
||||
alias tarc="tar cvzf"
|
||||
# alias rcp="rsync --partial --progress --append --rsh=ssh -r -h"
|
||||
# alias rmv="rsync --partial --progress --append --rsh=ssh -r -h --remove-sent-files"
|
||||
# alias rsyncc="rsync -rzPhc"
|
||||
|
||||
alias pythonserve="sudo python -m SimpleHTTPServer 80"
|
||||
|
||||
# replace
|
||||
alias sg='perl -0pe'
|
||||
|
||||
# alias clbin="curl -F 'clbin=<-' https://clbin.com"
|
||||
|
||||
#alias afs="unmount-abra0; mount-abra0;"
|
||||
|
||||
alias .g='git --git-dir=$HOME/.dotgit/ --work-tree=$HOME'
|
||||
alias .gs='.g status -uno'
|
||||
alias .gp='.g commit -am "auto" && .g push'
|
||||
|
||||
alias p="perl -pe"
|
||||
alias p0="perl -0pe"
|
||||
|
||||
alias -g LATEST='*(om[1])'
|
||||
|
||||
#alias f1sql="/google/data/ro/projects/storage/f1/tools/f1-sql"
|
||||
|
||||
#alias t="task"
|
||||
|
||||
#alias revs="ssh abra0 'tail -f -n0 ~/reverse_shell' | tee -a .rem_history| zsh -s"
|
||||
#alias nika_pop="echo \"afplay ~/tmp/nika.mp3\" > ~/reverse_shell"
|
||||
|
||||
# remote tmux on server
|
||||
alias tmuxr="tmux new -ADs auto-session"
|
||||
|
||||
alias FUNCTION_PRELUDE="setopt LOCAL_OPTIONS PIPE_FAIL XTRACE ERR_RETURN"
|
182
.zprezto/abra/functions.zsh
Normal file
182
.zprezto/abra/functions.zsh
Normal file
@@ -0,0 +1,182 @@
|
||||
function is_local {
|
||||
local HOSTNAME=$(hostname)
|
||||
|
||||
[[ "$HOSTNAME" =~ '^abra0' || "$HOSTNAME" == "svxf2-osx" ]]
|
||||
}
|
||||
|
||||
function publish {
|
||||
FUNCTION_PRELUDE
|
||||
|
||||
rsync2 "$@" "dedi:/var/www/abra.me/list/"
|
||||
}
|
||||
|
||||
function twitch {
|
||||
FUNCTION_PRELUDE
|
||||
|
||||
livestreamer "http://www.twitch.tv/${1}" "${${@:2}:-best}"
|
||||
}
|
||||
|
||||
function dcp {
|
||||
FUNCTION_PRELUDE
|
||||
|
||||
git add --all :/
|
||||
|
||||
git commit -m "${*:-$(whoami) at $(date)}"
|
||||
|
||||
git push
|
||||
}
|
||||
|
||||
|
||||
function .dcp {
|
||||
FUNCTION_PRELUDE
|
||||
|
||||
.g add -u
|
||||
|
||||
.g commit -m "${*:-$(whoami) at $(date)}"
|
||||
|
||||
.g push
|
||||
}
|
||||
|
||||
function strip-tags {
|
||||
FUNCTION_PRELUDE
|
||||
|
||||
find . -type f -name '*.mp3' \
|
||||
| tr '\n' '\0' \
|
||||
| xargs -0 -n1 mid3v2 --delete-frames=TXXX,USLT,TIPL,UFID,APIC,TBPM,TCMP,TDOR,TDRC,TLAN,TMED,TPOS,TPUB,TRCK,TCON
|
||||
}
|
||||
|
||||
function dedi-beet {
|
||||
FUNCTION_PRELUDE
|
||||
|
||||
ssh dedi -- sudo -u torrent-user beet "$@"
|
||||
}
|
||||
|
||||
function beet-comments {
|
||||
FUNCTION_PRELUDE
|
||||
|
||||
: "${1:?who?}"
|
||||
: "${2:?what?}"
|
||||
|
||||
dedi-beet modify \'"comments=$2"\' \'"albumartist::$1"\'
|
||||
}
|
||||
|
||||
function rsync2 {
|
||||
rsync \
|
||||
--info=PROGRESS2 \
|
||||
--progress \
|
||||
--recursive \
|
||||
--compress \
|
||||
--human-readable \
|
||||
--update \
|
||||
--times \
|
||||
--no-whole-file \
|
||||
--itemize-changes \
|
||||
--stats \
|
||||
--verbose \
|
||||
--links \
|
||||
"${(@)@}"
|
||||
}
|
||||
|
||||
function sync-music {
|
||||
FUNCTION_PRELUDE
|
||||
|
||||
# if ! is_local; then
|
||||
# echo "Should be local"
|
||||
# return 1
|
||||
# fi
|
||||
|
||||
mkdir -p "$HOME/music/library"
|
||||
|
||||
rsync2 \
|
||||
--delete \
|
||||
"dedi:/home/torrent-user/music-library/" \
|
||||
"$HOME/music/library/"
|
||||
}
|
||||
|
||||
# function .g-init() {
|
||||
# git init --bare $HOME/.dotgit
|
||||
# .g config --local status.showUntrackedFiles no
|
||||
# .g remote add origin ssh://dedi/root/.dotgit
|
||||
# git config --global user.name "Your Name"
|
||||
# git config --global user.email you@example.com
|
||||
# .g remote add origin ssh://dedi/var/www/git.abra.me/dot.git
|
||||
# }
|
||||
|
||||
|
||||
# make_user() {
|
||||
# FUNCTION_PRELUDE
|
||||
|
||||
# if is_local; then
|
||||
# echo "You're local"
|
||||
# return 1
|
||||
# fi
|
||||
|
||||
# adduser --system --shell /bin/zsh --disabled-password $1 || return 1
|
||||
|
||||
# # wget abra.me/.dotfiles.tar.gz -O /home/$1/.dotfiles.tar.gz
|
||||
# # tar xf /home/$1/.dotfiles.tar.gz -C /home/$1
|
||||
# # chown $1:nogroup -R /home/$1/
|
||||
# }
|
||||
|
||||
# function latest() {
|
||||
# echo -n ("${(@f)$(ls *(om[1,$1]))}")
|
||||
# }
|
||||
|
||||
function testo {
|
||||
local A="${@[2,3]}"
|
||||
./t.py ${(t)A} "$A" ${A[@]}
|
||||
unset A
|
||||
|
||||
local A=("$@[2,3]")
|
||||
./t.py ${(t)A} "$A" ${A[@]}
|
||||
unset A
|
||||
|
||||
./t.py "$@[2,3]"
|
||||
}
|
||||
# testo 1 "2 3" 4
|
||||
|
||||
# shit shit shit s hist h is htisthsi 2018-06-30
|
||||
function ffmpeg_timelapse {
|
||||
FUNCTION_PRELUDE
|
||||
|
||||
local DATE="$1"
|
||||
|
||||
ls "/mnt/a/snaps/$DATE" | wc -l
|
||||
|
||||
ffmpeg \
|
||||
-framerate 60 \
|
||||
-pattern_type glob -i "/mnt/a/snaps/$DATE/*.jpg" \
|
||||
"${@:2}" \
|
||||
-y "/mnt/a/tmp/$DATE.mp4"
|
||||
|
||||
mv "/mnt/a/tmp/$DATE.mp4" "/mnt/a/$DATE.mp4"
|
||||
|
||||
rm -rf "/mnt/a/snaps/$DATE"
|
||||
}
|
||||
|
||||
function ffmpeg_timelapse_today {
|
||||
local TODAY=$(date '+%Y-%m-%d')
|
||||
|
||||
ffmpeg_timelapse "$TODAY" -preset ultrafast -crf 20
|
||||
}
|
||||
|
||||
function update_.g {
|
||||
if [[ ! -d "$HOME/.dotgit" ]]; then
|
||||
# no git to update
|
||||
return
|
||||
fi
|
||||
|
||||
local RES=$(.g pull --no-stat 2>&1)
|
||||
|
||||
if [[ $? != 0 ]]; then
|
||||
# something went wrong
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ ! ($RES =~ "Already up.to.date") ]]; then
|
||||
echo "Updated .g"
|
||||
echo $RES
|
||||
echo "======"
|
||||
echo
|
||||
fi
|
||||
}
|
8
.zprezto/abra/main.zsh
Normal file
8
.zprezto/abra/main.zsh
Normal file
@@ -0,0 +1,8 @@
|
||||
zsource_if_exists "${ZDOTDIR:-$HOME}/.zprezto/abra/options.zsh"
|
||||
zsource_if_exists "${ZDOTDIR:-$HOME}/.zprezto/abra/aliases.zsh"
|
||||
zsource_if_exists "${ZDOTDIR:-$HOME}/.zprezto/abra/functions.zsh"
|
||||
|
||||
zsource_if_exists "$HOME/.iterm2_shell_integration.zsh"
|
||||
|
||||
# update, background+disown
|
||||
update_.g &!
|
47
.zprezto/abra/options.zsh
Normal file
47
.zprezto/abra/options.zsh
Normal file
@@ -0,0 +1,47 @@
|
||||
# Disable corrections
|
||||
unsetopt CORRECT
|
||||
# Now we can pipe to multiple outputs!
|
||||
setopt MULTIOS
|
||||
# This makes cd=pushd
|
||||
setopt AUTO_PUSHD
|
||||
# This will use named dirs when possible
|
||||
setopt AUTO_NAME_DIRS
|
||||
# If we have a glob this will expand it
|
||||
setopt GLOB_COMPLETE
|
||||
# use magic (this is default, but it can't hurt!)
|
||||
setopt ZLE
|
||||
# setopt NO_HUP
|
||||
# setopt IGNORE_EOF
|
||||
# If I could disable Ctrl-s completely I would!
|
||||
setopt NO_FLOW_CONTROL
|
||||
# unsetopt normstarsilent
|
||||
|
||||
## Keep echo "station" > station from clobbering station
|
||||
#setopt NO_CLOBBER
|
||||
setopt CLOBBER
|
||||
|
||||
# No ! voodoo
|
||||
unsetopt bang_hist
|
||||
|
||||
# Case insensitive globbing
|
||||
setopt NO_CASE_GLOB
|
||||
# Be Reasonable!
|
||||
setopt NUMERIC_GLOB_SORT
|
||||
# I don't know why I never set this before.
|
||||
setopt EXTENDED_GLOB
|
||||
# hows about arrays be awesome? (that is, frew${cool}frew has frew surrounding all the variables, not just first and last
|
||||
setopt RC_EXPAND_PARAM
|
||||
# disable running directory names
|
||||
unsetopt AUTO_CD
|
||||
|
||||
# return in functions if a command fails
|
||||
# setopt ERR_RETURN
|
||||
|
||||
|
||||
|
||||
# Who doesn't want home and end to work?
|
||||
bindkey '\e[1~' beginning-of-line
|
||||
bindkey '\e[4~' end-of-line
|
||||
|
||||
bindkey "\eOH" beginning-of-line
|
||||
bindkey "\eOF" end-of-line
|
89
.zprezto/abra/prompt_abra_setup.zsh
Normal file
89
.zprezto/abra/prompt_abra_setup.zsh
Normal file
@@ -0,0 +1,89 @@
|
||||
pmodload 'helper'
|
||||
|
||||
# %F{color}...%f -- foreground colors
|
||||
# %B...%b -- bold
|
||||
# %(x.a.b) -- if
|
||||
|
||||
# color chart: https://upload.wikimedia.org/wikipedia/en/1/15/Xterm_256color_chart.svg
|
||||
# COLOR_PWD='141'
|
||||
# COLOR_PWD_ROOT='201'
|
||||
# COLOR_PROMPT_STARTER='85'
|
||||
# COLOR_TIME='244'
|
||||
# COLOR_USERNAME='34'
|
||||
# COLOR_AT='244'
|
||||
# COLOR_HOSTNAME='162'
|
||||
|
||||
COLOR_PWD='cyan'
|
||||
COLOR_PWD_ROOT='red'
|
||||
COLOR_PROMPT_STARTER='green'
|
||||
COLOR_TIME='green'
|
||||
COLOR_USERNAME='blue'
|
||||
COLOR_AT=$COLOR_USERNAME
|
||||
COLOR_HOSTNAME=$COLOR_USERNAME
|
||||
|
||||
NEWLINE=$'\n'
|
||||
|
||||
function prompt_abra_precmd {
|
||||
setopt LOCAL_OPTIONS
|
||||
unsetopt XTRACE KSH_ARRAYS
|
||||
|
||||
# Get Git repository information.
|
||||
if [[ -z $NOGIT ]] && (( $+functions[git-info] )); then
|
||||
git-info || true
|
||||
fi
|
||||
|
||||
PRE_LENGTH=$(($COLUMNS*2/3))
|
||||
|
||||
PRE='%$PRE_LENGTH<...<%~ %<<'
|
||||
PRE=$(print -P $PRE)
|
||||
PRE=$(print ${(l:$COLUMNS:)PRE})
|
||||
print -P '%(!.%F{$COLOR_PWD_ROOT}.%F{$COLOR_PWD})$PRE%f'
|
||||
}
|
||||
|
||||
function prompt_abra_setup {
|
||||
setopt LOCAL_OPTIONS
|
||||
unsetopt XTRACE KSH_ARRAYS
|
||||
prompt_opts=(cr percent subst)
|
||||
|
||||
# Load required functions.
|
||||
autoload -Uz add-zsh-hook
|
||||
|
||||
# Add hook for calling git-info before each command.
|
||||
add-zsh-hook precmd prompt_abra_precmd
|
||||
|
||||
# Set git-info parameters.
|
||||
zstyle ':prezto:module:git:info' verbose 'yes'
|
||||
zstyle ':prezto:module:git:info:action' format ':%%B%F{yellow}%s%f%%b'
|
||||
zstyle ':prezto:module:git:info:added' format ' %%B%F{green}✚%f%%b'
|
||||
zstyle ':prezto:module:git:info:ahead' format ' %%B%F{yellow}⬆%f%%b'
|
||||
zstyle ':prezto:module:git:info:behind' format ' %%B%F{yellow}⬇%f%%b'
|
||||
zstyle ':prezto:module:git:info:branch' format ':%F{green}%b%f'
|
||||
zstyle ':prezto:module:git:info:commit' format ':%F{green}%.7c%f'
|
||||
zstyle ':prezto:module:git:info:deleted' format ' %%B%F{red}✖%f%%b'
|
||||
zstyle ':prezto:module:git:info:modified' format ' %%B%F{blue}✱%f%%b'
|
||||
zstyle ':prezto:module:git:info:position' format ':%F{red}%p%f'
|
||||
zstyle ':prezto:module:git:info:renamed' format ' %%B%F{magenta}➜%f%%b'
|
||||
zstyle ':prezto:module:git:info:stashed' format ' %%B%F{cyan}✭%f%%b'
|
||||
zstyle ':prezto:module:git:info:unmerged' format ' %%B%F{yellow}═%f%%b'
|
||||
zstyle ':prezto:module:git:info:untracked' format ' %%B%F{white}◼%f%%b'
|
||||
zstyle ':prezto:module:git:info:keys' format \
|
||||
'prompt' '%b ' \
|
||||
'rprompt' '%A%B%S%a%d%m%r%U%u'
|
||||
|
||||
|
||||
|
||||
PROMPT=''
|
||||
PROMPT=$PROMPT'${git_info:+${(e)git_info[prompt]}}'
|
||||
PROMPT=$PROMPT'%(?.%F{$COLOR_PROMPT_STARTER}.%F{red})➤ %f'
|
||||
|
||||
RPROMPT=''
|
||||
RPROMPT=$RPROMPT'%(?::%F{red}%?%f )' # last command code if nonzero
|
||||
RPROMPT=$RPROMPT'%B%F{$COLOR_USERNAME}%n%f%b'
|
||||
RPROMPT=$RPROMPT'%B%F{$COLOR_AT}@%f%b'
|
||||
RPROMPT=$RPROMPT'%B%F{$COLOR_HOSTNAME}%2m%f%b'
|
||||
RPROMPT=$RPROMPT'${git_info[rprompt]} '
|
||||
RPROMPT=$RPROMPT'%F{$COLOR_TIME}%*%f'
|
||||
}
|
||||
|
||||
prompt_abra_setup "$@"
|
||||
|
Reference in New Issue
Block a user