mirror of
https://github.com/Matir/skel.git
synced 2026-05-25 21:19:09 -07:00
Cleanup
This commit is contained in:
5
bin/remove-wine-associations
Executable file
5
bin/remove-wine-associations
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
rm -f ~/.local/share/applications/wine*.desktop
|
||||
update-desktop-database ~/.local/share/applications
|
||||
rm -f ~/.local/share/mime/packages/x-wine*.xml
|
||||
update-mime-database ~/.local/share/mime
|
||||
7
bin/update_skel
Executable file
7
bin/update_skel
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
SKEL_DIR=$(dirname -- "$(readlink -f -- "$HOME/.profile")")
|
||||
cd -- "$SKEL_DIR"
|
||||
cd -- "$(git rev-parse --show-toplevel)"
|
||||
git pull
|
||||
./install.sh
|
||||
@@ -187,7 +187,7 @@ if [[ $- == *i* ]] ; then
|
||||
source "$file"
|
||||
done
|
||||
# extra completions, prompt
|
||||
fpath=(~/.zshrc.completions ~/.zshrc.d/matir_prompt ~/.zshrc.d/agnoster_prompt $fpath)
|
||||
fpath=(~/.zshrc.completions ~/.zshrc.d/matir_prompt $fpath)
|
||||
# Homebrew on mac
|
||||
if test -x /opt/homebrew/bin/brew ; then
|
||||
eval $(/opt/homebrew/bin/brew shellenv)
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
function afk {
|
||||
# Note, may fail if multiple users are logged in with different desktop
|
||||
# environments.
|
||||
if pidof cinnamon-screensaver >/dev/null ; then
|
||||
cinnamon-screensaver-command -l
|
||||
elif pidof gnome-screensaver >/dev/null ; then
|
||||
gnome-screensaver-command -l
|
||||
else
|
||||
echo 'No screensaver found...' >&2
|
||||
fi
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
# vim:ft=zsh ts=2 sw=2 sts=2
|
||||
#
|
||||
# agnoster's Theme - https://gist.github.com/3712874
|
||||
# A Powerline-inspired theme for ZSH
|
||||
#
|
||||
# # README
|
||||
#
|
||||
# In order for this theme to render correctly, you will need a
|
||||
# [Powerline-patched font](https://gist.github.com/1595572).
|
||||
#
|
||||
# In addition, I recommend the
|
||||
# [Solarized theme](https://github.com/altercation/solarized/) and, if you're
|
||||
# using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app -
|
||||
# it has significantly better color fidelity.
|
||||
#
|
||||
# # Goals
|
||||
#
|
||||
# The aim of this theme is to only show you *relevant* information. Like most
|
||||
# prompts, it will only show git information when in a git working directory.
|
||||
# However, it goes a step further: everything from the current user and
|
||||
# hostname to whether the last call exited with an error to whether background
|
||||
# jobs are running in this shell will all be displayed automatically when
|
||||
# appropriate.
|
||||
|
||||
### Segments of the prompt, default order declaration
|
||||
|
||||
typeset -aHg AGNOSTER_PROMPT_SEGMENTS=(
|
||||
prompt_status
|
||||
prompt_context
|
||||
prompt_virtualenv
|
||||
prompt_dir
|
||||
prompt_git
|
||||
prompt_end
|
||||
)
|
||||
|
||||
### Segment drawing
|
||||
# A few utility functions to make it easy and re-usable to draw segmented prompts
|
||||
|
||||
CURRENT_BG='NONE'
|
||||
if [[ -z "$PRIMARY_FG" ]]; then
|
||||
PRIMARY_FG=black
|
||||
fi
|
||||
|
||||
# Characters
|
||||
SEGMENT_SEPARATOR="\ue0b0"
|
||||
PLUSMINUS="\u00b1"
|
||||
BRANCH="\ue0a0"
|
||||
DETACHED="\u27a6"
|
||||
CROSS="\u2718"
|
||||
LIGHTNING="\u26a1"
|
||||
GEAR="\u2699"
|
||||
|
||||
# Begin a segment
|
||||
# Takes two arguments, background and foreground. Both can be omitted,
|
||||
# rendering default background/foreground.
|
||||
prompt_segment() {
|
||||
local bg fg
|
||||
[[ -n $1 ]] && bg="%K{$1}" || bg="%k"
|
||||
[[ -n $2 ]] && fg="%F{$2}" || fg="%f"
|
||||
if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then
|
||||
print -n "%{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%}"
|
||||
else
|
||||
print -n "%{$bg%}%{$fg%}"
|
||||
fi
|
||||
CURRENT_BG=$1
|
||||
[[ -n $3 ]] && print -n $3
|
||||
}
|
||||
|
||||
# End the prompt, closing any open segments
|
||||
prompt_end() {
|
||||
if [[ -n $CURRENT_BG ]]; then
|
||||
print -n "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"
|
||||
else
|
||||
print -n "%{%k%}"
|
||||
fi
|
||||
print -n "%{%f%}"
|
||||
CURRENT_BG=''
|
||||
}
|
||||
|
||||
### Prompt components
|
||||
# Each component will draw itself, and hide itself if no information needs to be shown
|
||||
|
||||
# Context: user@hostname (who am I and where am I)
|
||||
prompt_context() {
|
||||
local user=`whoami`
|
||||
|
||||
if [[ "$user" != "$DEFAULT_USER" || -n "$SSH_CONNECTION" ]]; then
|
||||
prompt_segment $PRIMARY_FG default " %(!.%{%F{yellow}%}.)$user@%m "
|
||||
fi
|
||||
}
|
||||
|
||||
# Git: branch/detached head, dirty status
|
||||
prompt_git() {
|
||||
local color ref
|
||||
is_dirty() {
|
||||
test -n "$(git status --porcelain --ignore-submodules)"
|
||||
}
|
||||
ref="$vcs_info_msg_0_"
|
||||
if [[ -n "$ref" ]]; then
|
||||
if is_dirty; then
|
||||
color=yellow
|
||||
ref="${ref} $PLUSMINUS"
|
||||
else
|
||||
color=green
|
||||
ref="${ref} "
|
||||
fi
|
||||
if [[ "${ref/.../}" == "$ref" ]]; then
|
||||
ref="$BRANCH $ref"
|
||||
else
|
||||
ref="$DETACHED ${ref/.../}"
|
||||
fi
|
||||
prompt_segment $color $PRIMARY_FG
|
||||
print -n " $ref"
|
||||
fi
|
||||
}
|
||||
|
||||
# Dir: current working directory
|
||||
prompt_dir() {
|
||||
prompt_segment blue $PRIMARY_FG ' %~ '
|
||||
}
|
||||
|
||||
# Status:
|
||||
# - was there an error
|
||||
# - am I root
|
||||
# - are there background jobs?
|
||||
prompt_status() {
|
||||
local symbols
|
||||
symbols=()
|
||||
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}$CROSS"
|
||||
[[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}$LIGHTNING"
|
||||
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}$GEAR"
|
||||
|
||||
[[ -n "$symbols" ]] && prompt_segment $PRIMARY_FG default " $symbols "
|
||||
}
|
||||
|
||||
# Display current virtual environment
|
||||
prompt_virtualenv() {
|
||||
if [[ -n $VIRTUAL_ENV ]]; then
|
||||
color=cyan
|
||||
prompt_segment $color $PRIMARY_FG
|
||||
print -Pn " $(basename $VIRTUAL_ENV) "
|
||||
fi
|
||||
}
|
||||
|
||||
## Main prompt
|
||||
prompt_agnoster_main() {
|
||||
RETVAL=$?
|
||||
CURRENT_BG='NONE'
|
||||
for prompt_segment in "${AGNOSTER_PROMPT_SEGMENTS[@]}"; do
|
||||
[[ -n $prompt_segment ]] && $prompt_segment
|
||||
done
|
||||
}
|
||||
|
||||
prompt_agnoster_precmd() {
|
||||
vcs_info
|
||||
PROMPT='%{%f%b%k%}$(prompt_agnoster_main) '
|
||||
}
|
||||
|
||||
prompt_agnoster_setup() {
|
||||
autoload -Uz add-zsh-hook
|
||||
autoload -Uz vcs_info
|
||||
|
||||
prompt_opts=(cr subst percent)
|
||||
|
||||
add-zsh-hook precmd prompt_agnoster_precmd
|
||||
|
||||
zstyle ':vcs_info:*' enable git
|
||||
zstyle ':vcs_info:*' check-for-changes false
|
||||
zstyle ':vcs_info:git*' formats '%b'
|
||||
zstyle ':vcs_info:git*' actionformats '%b (%a)'
|
||||
}
|
||||
|
||||
prompt_agnoster_setup "$@"
|
||||
@@ -1,7 +1,7 @@
|
||||
function dmesg {
|
||||
if [ $(id -u) -eq 0 ] ; then
|
||||
command dmesg "$@"
|
||||
elif id | grep -q '(sudo)' ; then
|
||||
elif sudo -n true 2>/dev/null ; then
|
||||
sudo dmesg "$@"
|
||||
else
|
||||
command dmesg "$@"
|
||||
|
||||
@@ -1,151 +0,0 @@
|
||||
function _jekyll_locate_dir {
|
||||
if [[ -n "${JEKYLL_DIR}" && -f "${JEKYLL_DIR}" ]] ; then
|
||||
echo ${JEKYLL_DIR}
|
||||
elif test -f `pwd`/_config.yml ; then
|
||||
pwd
|
||||
elif test -f ${HOME}/Projects/blog/_config.yml ; then
|
||||
echo ${HOME}/Projects/blog
|
||||
else
|
||||
echo "Jekyll instance not found!" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
function _jekyll_set_date {
|
||||
local FILENAME
|
||||
local DATE
|
||||
FILENAME=${1}
|
||||
DATE=${2}
|
||||
sed -i "2,/---/{s/^date:.*$/date: ${DATE}/;s/---/date: ${DATE}\n---/}" ${FILENAME}
|
||||
}
|
||||
|
||||
function _jekyll_find_post {
|
||||
local files
|
||||
local fname
|
||||
local jekyll_dir
|
||||
|
||||
jekyll_dir="${3}"
|
||||
|
||||
if [ -f "${1}" ] ; then
|
||||
printf -- "${1}"
|
||||
return 0
|
||||
fi
|
||||
if [ -f "${jekyll_dir}/_posts/${1}" ] ; then
|
||||
printf -- "${jekyll_dir}/_posts/${1}"
|
||||
return 0
|
||||
fi
|
||||
if [ -f "${jekyll_dir}/_drafts/${1}" ] ; then
|
||||
printf -- "${jekyll_dir}/_drafts/${1}"
|
||||
return 0
|
||||
fi
|
||||
fname=${2:-${1}}
|
||||
files=(${jekyll_dir}/_posts/*${fname}* ${jekyll_dir}/_drafts/*${fname}*)
|
||||
if [ ${#files} -eq "0" ] ; then
|
||||
echo "No post found for ${fname}" >&2
|
||||
return 1
|
||||
fi
|
||||
if [ ${#files} -gt "1" ] ; then
|
||||
echo "Ambiguous results: ${files}" >&2
|
||||
return 1
|
||||
fi
|
||||
printf -- ${files}
|
||||
return 0
|
||||
}
|
||||
|
||||
function jekyll {
|
||||
setopt localoptions nullglob
|
||||
local JTEMPLATE
|
||||
local TITLE
|
||||
local SLUG
|
||||
local FILENAME
|
||||
local DATE
|
||||
local NEWNAME
|
||||
local JEKYLL_DIR
|
||||
local EDITOR=${EDITOR:-vim}
|
||||
|
||||
JEKYLL_DIR=`_jekyll_locate_dir`
|
||||
|
||||
if [ -z "${JEKYLL_DIR}" ] ; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
JTEMPLATE="---\n"
|
||||
JTEMPLATE+="layout: post\n"
|
||||
JTEMPLATE+="title: \"%s\"\n"
|
||||
JTEMPLATE+="category: Blog\n"
|
||||
JTEMPLATE+="---\n\n"
|
||||
TITLE=${@[2,-1]}
|
||||
SLUG=$(echo -n ${TITLE} |
|
||||
tr A-Z a-z | # Everything in lower case
|
||||
tr -d "'" | # Remove single quotes entirely
|
||||
tr -c -s -- a-z0-9 - | # Replace non-alphanums with dashes
|
||||
sed 's/^-*\([^-].*[^-]\)-*$/\1/' # Remove leading and trailing slashes
|
||||
)
|
||||
TITLE=$(echo ${TITLE} | sed 's/\\/\\\\/g;s/"/\\"/g')
|
||||
DATE=`date +%Y-%m-%d`
|
||||
|
||||
case "${1:-help}" in
|
||||
help|--help)
|
||||
command jekyll help
|
||||
echo "Added by zsh plugin:"
|
||||
echo " draft Create a new draft post."
|
||||
echo " post Create a new post to publish immediately."
|
||||
echo " publish Publish a draft post by name."
|
||||
echo " edit Edit a post."
|
||||
echo " dev Run local server with drafts and incremental."
|
||||
;;
|
||||
draft)
|
||||
if [ -z "${SLUG}" ] ; then
|
||||
echo "slug is required."
|
||||
return 1
|
||||
fi
|
||||
mkdir -p "${JEKYLL_DIR}/_drafts"
|
||||
FILENAME="${JEKYLL_DIR}/_drafts/${SLUG}.md"
|
||||
printf -- "${JTEMPLATE}" "${TITLE}" > "${FILENAME}"
|
||||
${EDITOR} "${FILENAME}" '+$' '+startinsert'
|
||||
;;
|
||||
post)
|
||||
if [ -z "${SLUG}" ] ; then
|
||||
echo "slug is required."
|
||||
return 1
|
||||
fi
|
||||
FILENAME="${JEKYLL_DIR}/_posts/${DATE}-${SLUG}.md"
|
||||
printf -- "${JTEMPLATE}" "${TITLE}" > "${FILENAME}"
|
||||
_jekyll_set_date "${FILENAME}" "${DATE}"
|
||||
${EDITOR} "${FILENAME}" '+$' '+startinsert'
|
||||
;;
|
||||
publish)
|
||||
if [ -z "${SLUG}" ] ; then
|
||||
echo "slug is required."
|
||||
return 1
|
||||
fi
|
||||
FILENAME=$(_jekyll_find_post "${TITLE}" "${SLUG}" "${JEKYLL_DIR}")
|
||||
if [ $? -ne 0 ] ; then
|
||||
return 1
|
||||
fi
|
||||
if ! [[ "${FILENAME}" =~ '/_drafts/' ]] ; then
|
||||
echo "${FILENAME} is not a draft." >&2
|
||||
return 1
|
||||
fi
|
||||
NEWNAME=$(echo "${FILENAME}" | sed "s/_drafts\//_posts\/${DATE}-/")
|
||||
mv "${FILENAME}" "${NEWNAME}"
|
||||
_jekyll_set_date "${NEWNAME}" "${DATE}"
|
||||
;;
|
||||
edit)
|
||||
if [ -z "${SLUG}" ] ; then
|
||||
echo "slug is required."
|
||||
return 1
|
||||
fi
|
||||
FILENAME=$(_jekyll_find_post "${TITLE}" "${SLUG}" "${JEKYLL_DIR}")
|
||||
if [ $? -ne 0 ] ; then
|
||||
return
|
||||
fi
|
||||
${EDITOR} "${FILENAME}"
|
||||
;;
|
||||
dev)
|
||||
command bundle exec jekyll serve -D -I "$@"
|
||||
;;
|
||||
*)
|
||||
command bundle exec jekyll "$@"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
prune-broken-symlinks() {
|
||||
setopt localoptions nounset
|
||||
local ASK
|
||||
local DIR
|
||||
local FINDCMD
|
||||
local i
|
||||
|
||||
if [[ "${1:-}" == "-y" ]] ; then
|
||||
ASK=0
|
||||
shift
|
||||
else
|
||||
ASK=1
|
||||
fi
|
||||
DIR=${1:-.}
|
||||
FINDCMD=(find -L ${DIR} -xdev -type l)
|
||||
if (($ASK)) ; then
|
||||
local FILES
|
||||
FILES=`${FINDCMD} -print`
|
||||
if [[ "${FILES}" == "" ]] ; then
|
||||
return 0
|
||||
fi
|
||||
echo ${FILES}
|
||||
echo -n 'Delete these links? [y/n] '
|
||||
if read -q ; then
|
||||
${FINDCMD} -exec rm {} +
|
||||
fi
|
||||
echo
|
||||
else
|
||||
${FINDCMD} -exec rm {} +
|
||||
fi
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
remove-wine-associations() {
|
||||
rm ~/.local/share/applications/wine*.desktop
|
||||
update-desktop-database ~/.local/share/applications
|
||||
rm ~/.local/share/mime/packages/x-wine*.xml
|
||||
update-mime-database ~/.local/share/mime
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
function site2pdf {
|
||||
setopt localoptions nounset
|
||||
local URL=${1}
|
||||
local OUTFILE=${2}
|
||||
command wkhtmltopdf -s Letter -q ${URL} ${OUTFILE}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
update_skel() {
|
||||
(cd $(dirname $(readlink $HOME/.profile)) &&
|
||||
cd $(git rev-parse --show-toplevel) &&
|
||||
git pull &&
|
||||
./install.sh
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user