cleanup for new folder

This commit is contained in:
Nikolas Weger 2019-11-10 13:03:14 +01:00
parent d9ca82a51b
commit 005541a96f
50 changed files with 0 additions and 10356 deletions

18
.gitmodules vendored
View file

@ -1,18 +0,0 @@
[submodule "dotbot"]
path = lib/dotbot
url = https://github.com/anishathalye/dotbot
[submodule "lib/completions"]
path = lib/completions
url = https://github.com/zsh-users/zsh-completions
[submodule "lib/ohmyzsh"]
path = lib/ohmyzsh
url = https://github.com/robbyrussell/oh-my-zsh
[submodule "lib/gitignore"]
path = lib/gitignore
url = https://github.com/github/gitignore
[submodule "lib/basher"]
path = lib/basher
url = https://github.com/basherpm/basher
[submodule "lib/has"]
path = lib/has
url = https://github.com/kdabir/has

View file

@ -1,13 +0,0 @@
## My Dotfiles
This Repo contains my dotfiles
Prerequisites:
- xmlstarlet: `yaourt -S xmlstarlet`
- nano-syntax-highlighting `yaourt -S nano-syntax-highlighting`
- as root `echo "include /usr/share/nano-syntax-highlighting/*.nanorc" >> /etc/nanorc`
- fzf nano-syntax-highlighting `yaourt -S fzf`
- linuxbrew `ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install)"`
Install with the `./install` script.

1633
bin/ansi

File diff suppressed because it is too large Load diff

340
bin/desk
View file

@ -1,340 +0,0 @@
#!/usr/bin/env bash
# vim: set filetype=sh:
PREFIX="${DESK_DIR:-$HOME/.desk}"
DESKS="${DESK_DESKS_DIR:-$PREFIX/desks}"
DESKFILE_NAME=Deskfile
## Commands
cmd_version() {
echo "◲ desk 0.6.0"
}
cmd_usage() {
cmd_version
echo
cat <<_EOF
Usage:
$PROGRAM
List the current desk and any associated aliases. If no desk
is being used, display available desks.
$PROGRAM init
Initialize desk configuration.
$PROGRAM (list|ls)
List all desks along with a description.
$PROGRAM (.|go) [<desk-name-or-path> [shell-args...]]
Activate a desk. Extra arguments are passed onto shell. If called with
no arguments, look for a Deskfile in the current directory. If not a
recognized desk, try as a path to directory containing a Deskfile.
$PROGRAM run <desk-name> '<cmd>'
$PROGRAM run <desk-name> <cmd> <arg>...
Run a command within a desk's environment then exit. In the first form
shell expansion is performed. In the second form, the argument vector
is executed as is.
$PROGRAM edit [desk-name]
Edit (or create) a deskfile with the name specified, otherwise
edit the active deskfile.
$PROGRAM help
Show this text.
$PROGRAM version
Show version information.
Since desk spawns a shell, to deactivate and "pop" out a desk, you
simply need to exit or otherwise end the current shell process.
_EOF
}
cmd_init() {
if [ -d "$PREFIX" ]; then
echo "Desk dir already exists at ${PREFIX}"
exit 1
fi
read -p "Where do you want to store your deskfiles? (default: ${PREFIX}): " \
NEW_PREFIX
[ -z "${NEW_PREFIX}" ] && NEW_PREFIX="$PREFIX"
if [ ! -d "${NEW_PREFIX}" ]; then
echo "${NEW_PREFIX} doesn't exist, attempting to create."
mkdir -p "$NEW_PREFIX/desks"
fi
local SHELLTYPE=$(get_running_shell)
case "${SHELLTYPE}" in
bash) local SHELLRC="${HOME}/.bashrc" ;;
fish) local SHELLRC="${HOME}/.config/fish/config.fish" ;;
zsh) local SHELLRC="${HOME}/.zshrc" ;;
esac
read -p "Where's your shell rc file? (default: ${SHELLRC}): " \
USER_SHELLRC
[ -z "${USER_SHELLRC}" ] && USER_SHELLRC="$SHELLRC"
if [ ! -f "$USER_SHELLRC" ]; then
echo "${USER_SHELLRC} doesn't exist"
exit 1
fi
printf "\n# Hook for desk activation\n" >> "$USER_SHELLRC"
# Since the hook is appended to the rc file, its exit status becomes
# the exit status of `source $USER_SHELLRC` which typically
# indicates if something went wrong. If $DESK_ENV is void, `test`
# sets exit status to 1. That, however, is part of desk's normal
# operation, so we clear exit status after that.
if [ "$SHELLTYPE" == "fish" ]; then
echo "test -n \"\$DESK_ENV\"; and . \"\$DESK_ENV\"; or true" >> "$USER_SHELLRC"
else
echo "[ -n \"\$DESK_ENV\" ] && source \"\$DESK_ENV\" || true" >> "$USER_SHELLRC"
fi
echo "Done. Start adding desks to ${NEW_PREFIX}/desks!"
}
cmd_go() {
# TODESK ($1) may either be
#
# - the name of a desk in $DESKS/
# - a path to a Deskfile
# - a directory containing a Deskfile
# - empty -> `./Deskfile`
#
local TODESK="$1"
local DESKEXT=$(get_deskfile_extension)
local DESKPATH="$(find "${DESKS}/" -name "${TODESK}${DESKEXT}" 2>/dev/null)"
local POSSIBLE_DESKFILE_DIR="${TODESK%$DESKFILE_NAME}"
if [ -z "$POSSIBLE_DESKFILE_DIR" ]; then
POSSIBLE_DESKFILE_DIR="."
fi
# If nothing could be found in $DESKS/, check to see if this is a path to
# a Deskfile.
if [[ -z "$DESKPATH" && -d "$POSSIBLE_DESKFILE_DIR" ]]; then
if [ ! -f "${POSSIBLE_DESKFILE_DIR}/${DESKFILE_NAME}" ]; then
echo "No Deskfile found in '${POSSIBLE_DESKFILE_DIR}'"
exit 1
fi
local REALPATH=$( cd $POSSIBLE_DESKFILE_DIR && pwd )
DESKPATH="${REALPATH}/${DESKFILE_NAME}"
TODESK=$(basename "$REALPATH")
fi
# Shift desk name so we can forward on all arguments to the shell.
shift;
if [ -z "$DESKPATH" ]; then
echo "Desk $TODESK (${TODESK}${DESKEXT}) not found in $DESKS"
exit 1
else
local SHELL_EXEC="$(get_running_shell)"
DESK_NAME="${TODESK}" DESK_ENV="${DESKPATH}" exec "${SHELL_EXEC}" "$@"
fi
}
cmd_run() {
local TODESK="$1"
shift;
if [ $# -eq 1 ]; then
cmd_go "$TODESK" -ic "$1"
else
cmd_go "$TODESK" -ic '"$@"' -- "$@"
fi
}
# Usage: desk list [options]
# Description: List all desks along with a description
# --only-names: List only the names of the desks
# --no-format: Use ' - ' to separate names from descriptions
cmd_list() {
if [ ! -d "${DESKS}/" ]; then
echo "No desk dir! Run 'desk init'."
exit 1
fi
local SHOW_DESCRIPTIONS DESKEXT AUTO_ALIGN name desc len longest out
while [[ $# -gt 0 ]]; do
case "$1" in
--only-names) SHOW_DESCRIPTIONS=false && AUTO_ALIGN=false ;;
--no-format) AUTO_ALIGN=false ;;
esac
shift
done
DESKEXT=$(get_deskfile_extension)
out=""
longest=0
while read -d '' -r f; do
name=$(basename "${f/${DESKEXT}//}")
if [[ "$SHOW_DESCRIPTIONS" = false ]]; then
out+="$name"$'\n'
else
desc=$(echo_description "$f")
out+="$name - $desc"$'\n'
len=${#name}
(( len > longest )) && longest=$len
fi
done < <(find "${DESKS}/" -name "*${DESKEXT}" -print0)
if [[ "$AUTO_ALIGN" != false ]]; then
print_aligned "$out" "$longest"
else
printf "%s" "$out"
fi
}
# Usage: desk [options]
# Description: List the current desk and any associated aliases. If no desk is being used, display available desks
# --no-format: Use ' - ' to separate alias/export/function names from their descriptions
cmd_current() {
if [ -z "$DESK_ENV" ]; then
printf "No desk activated.\n\n%s" "$(cmd_list)"
exit 1
fi
local DESKPATH=$DESK_ENV
local CALLABLES=$(get_callables "$DESKPATH")
local AUTO_ALIGN len longest out
while [[ $# -gt 0 ]]; do
case "$1" in
--no-format) AUTO_ALIGN=false ;;
esac
shift
done
printf "%s - %s\n" "$DESK_NAME" "$(echo_description "$DESKPATH")"
if [[ -n "$CALLABLES" ]]; then
longest=0
out=$'\n'
for NAME in $CALLABLES; do
# Last clause in the grep regexp accounts for fish functions.
len=$((${#NAME} + 2))
(( len > longest )) && longest=$len
local DOCLINE=$(
grep -B 1 -E \
"^(alias ${NAME}=|export ${NAME}=|(function )?${NAME}( )?\()|function $NAME" "$DESKPATH" \
| grep "#")
if [ -z "$DOCLINE" ]; then
out+=" ${NAME}"$'\n'
else
out+=" ${NAME} - ${DOCLINE##\# }"$'\n'
fi
done
if [[ "$AUTO_ALIGN" != false ]]; then
print_aligned "$out" "$longest"
else
printf "%s" "$out"
fi
fi
}
cmd_edit() {
if [ $# -eq 0 ]; then
if [ "$DESK_NAME" == "" ]; then
echo "No desk activated."
exit 3
fi
local DESKNAME_TO_EDIT="$DESK_NAME"
elif [ $# -eq 1 ]; then
local DESKNAME_TO_EDIT="$1"
else
echo "Usage: ${PROGRAM} edit [desk-name]"
exit 1
fi
local DESKEXT=$(get_deskfile_extension)
local EDIT_PATH="${DESKS}/${DESKNAME_TO_EDIT}${DESKEXT}"
${EDITOR:-vi} "$EDIT_PATH"
}
## Utilities
FNAME_CHARS='[a-zA-Z0-9_-]'
# Echo the description of a desk. $1 is the deskfile.
echo_description() {
local descline=$(grep -E "#\s+Description" "$1")
echo "${descline##*Description: }"
}
# Echo a list of aliases, exports, and functions for a given desk
get_callables() {
local DESKPATH=$1
grep -E "^(alias |export |(function )?${FNAME_CHARS}+ ?\()|function $NAME" "$DESKPATH" \
| sed 's/alias \([^= ]*\)=.*/\1/' \
| sed 's/export \([^= ]*\)=.*/\1/' \
| sed -E "s/(function )?(${FNAME_CHARS}+) ?\(\).*/\2/" \
| sed -E "s/function (${FNAME_CHARS}+).*/\1/"
}
get_running_shell() {
# Echo the name of the parent shell via procfs, if we have it available.
# Otherwise, try to use ps with bash's parent pid.
if [ -e /proc ]; then
# Get cmdline procfile of the process running this script.
local CMDLINE_FILE="/proc/$(grep PPid /proc/$$/status | cut -f2)/cmdline"
if [ -f "$CMDLINE_FILE" ]; then
# Strip out any verion that may be attached to the shell executable.
# Strip leading dash for login shells.
local CMDLINE_SHELL=$(sed -r -e 's/\x0.*//' -e 's/^-//' "$CMDLINE_FILE")
fi
else
# Strip leading dash for login shells.
# If the parent process is a login shell, guess bash.
local CMDLINE_SHELL=$(ps -o comm= -p $PPID | tail -1 | sed -e 's/login/bash/' -e 's/^-//')
fi
if [ ! -z "$CMDLINE_SHELL" ]; then
basename "$CMDLINE_SHELL"
exit
fi
# Fall back to $SHELL otherwise.
basename "$SHELL"
exit
}
# Echo the extension of recognized deskfiles (.fish for fish)
get_deskfile_extension() {
if [ "$(get_running_shell)" == "fish" ]; then
echo '.fish'
else
echo '.sh'
fi
}
# Echo first argument as key/value pairs aligned into two columns; second argument is the longest key
print_aligned() {
local out=$1 longest=$2
printf "%s" "$out" | awk -v padding="$longest" -F' - ' '{
printf "%-*s %s\n", padding, $1, substr($0, index($0, " - ")+2, length($0))
}'
}
PROGRAM="${0##*/}"
case "$1" in
init) shift; cmd_init "$@" ;;
help|--help) shift; cmd_usage "$@" ;;
version|--version) shift; cmd_version "$@" ;;
ls|list) shift; cmd_list "$@" ;;
go|.) shift; cmd_go "$@" ;;
run) shift; cmd_run "$@" ;;
edit) shift; cmd_edit "$@" ;;
*) cmd_current "$@" ;;
esac
exit 0

View file

@ -1,41 +0,0 @@
#!/usr/bin/env bash
# Path to your hosts file
hostsFile="/etc/hosts"
# Default IP address for host
ip="127.0.0.1"
# Hostname to add/remove.
hostname="$2"
yell() { echo "$0: $*" >&2; }
die() { yell "$*"; exit 111; }
try() { "$@" || die "cannot $*"; }
remove() {
if [ -n "$(grep -P "[[:space:]]$hostname" /etc/hosts)" ]; then
echo "$hostname found in $hostsFile. Removing now...";
try sudo sed -ie "/[[:space:]]$hostname/d" "$hostsFile";
else
yell "$hostname was not found in $hostsFile";
fi
}
add() {
if [ -n "$(grep -P "[[:space:]]$hostname" /etc/hosts)" ]; then
yell "$hostname, already exists: $(grep $hostname $hostsFile)";
else
echo "Adding $hostname to $hostsFile...";
try printf "%s\t%s\n" "$ip" "$hostname" | sudo tee -a "$hostsFile" > /dev/null;
if [ -n "$(grep $hostname /etc/hosts)" ]; then
echo "$hostname was added succesfully:";
echo "$(grep $hostname /etc/hosts)";
else
die "Failed to add $hostname";
fi
fi
}
$@

133
bin/is
View file

@ -1,133 +0,0 @@
#!/bin/bash
#
# Copyright (c) 2016 Józef Sokołowski
# Distributed under the MIT License
#
# For most current version checkout repository:
# https://github.com/qzb/is.sh
#
is() {
if [ "$1" == "--help" ]; then
cat << EOF
Conditions:
is equal VALUE_A VALUE_B
is matching REGEXP VALUE
is substring VALUE_A VALUE_B
is empty VALUE
is number VALUE
is gt NUMBER_A NUMBER_B
is lt NUMBER_A NUMBER_B
is ge NUMBER_A NUMBER_B
is le NUMBER_A NUMBER_B
is file PATH
is dir PATH
is link PATH
is existing PATH
is readable PATH
is writeable PATH
is executable PATH
is available COMMAND
is older PATH_A PATH_B
is newer PATH_A PATH_B
is true VALUE
is false VALUE
Negation:
is not equal VALUE_A VALUE_B
Optional article:
is not a number VALUE
is an existing PATH
is the file PATH
EOF
exit
fi
if [ "$1" == "--version" ]; then
echo "is.sh 1.1.0"
exit
fi
local condition="$1"
local value_a="$2"
local value_b="$3"
if [ "$condition" == "not" ]; then
shift 1
! is "${@}"
return $?
fi
if [ "$condition" == "a" ] || [ "$condition" == "an" ] || [ "$condition" == "the" ]; then
shift 1
is "${@}"
return $?
fi
case "$condition" in
file)
[ -f "$value_a" ]; return $?;;
dir|directory)
[ -d "$value_a" ]; return $?;;
link|symlink)
[ -L "$value_a" ]; return $?;;
existent|existing|exist|exists)
[ -e "$value_a" ]; return $?;;
readable)
[ -r "$value_a" ]; return $?;;
writeable)
[ -w "$value_a" ]; return $?;;
executable)
[ -x "$value_a" ]; return $?;;
available|installed)
which "$value_a"; return $?;;
empty)
[ -z "$value_a" ]; return $?;;
number)
echo "$value_a" | grep -E '^[0-9]+(\.[0-9]+)?$'; return $?;;
older)
[ "$value_a" -ot "$value_b" ]; return $?;;
newer)
[ "$value_a" -nt "$value_b" ]; return $?;;
gt)
is not a number "$value_a" && return 1;
is not a number "$value_b" && return 1;
awk "BEGIN {exit $value_a > $value_b ? 0 : 1}"; return $?;;
lt)
is not a number "$value_a" && return 1;
is not a number "$value_b" && return 1;
awk "BEGIN {exit $value_a < $value_b ? 0 : 1}"; return $?;;
ge)
is not a number "$value_a" && return 1;
is not a number "$value_b" && return 1;
awk "BEGIN {exit $value_a >= $value_b ? 0 : 1}"; return $?;;
le)
is not a number "$value_a" && return 1;
is not a number "$value_b" && return 1;
awk "BEGIN {exit $value_a <= $value_b ? 0 : 1}"; return $?;;
eq|equal)
[ "$value_a" = "$value_b" ] && return 0;
is not a number "$value_a" && return 1;
is not a number "$value_b" && return 1;
awk "BEGIN {exit $value_a == $value_b ? 0 : 1}"; return $?;;
match|matching)
echo "$value_b" | grep -xE "$value_a"; return $?;;
substr|substring)
echo "$value_b" | grep -F "$value_a"; return $?;;
true)
[ "$value_a" == true ] || [ "$value_a" == 0 ]; return $?;;
false)
[ "$value_a" != true ] && [ "$value_a" != 0 ]; return $?;;
esac > /dev/null
return 1
}
if is not equal "${BASH_SOURCE[0]}" "$0"; then
export -f is
else
is "${@}"
exit $?
fi

156
bin/lj
View file

@ -1,156 +0,0 @@
#!/usr/bin/env zsh
# Create a mapping of log levels to their names
typeset -A _log_levels
_log_levels=(
'emergency' 0
'alert' 1
'critical' 2
'error' 3
'warning' 4
'notice' 5
'info' 6
'debug' 7
)
###
# Output usage information and exit
###
function _lumberjack_usage() {
echo "\033[0;33mUsage:\033[0;m"
echo " lj [options] [<level>] <message>"
echo
echo "\033[0;33mOptions:\033[0;m"
echo " -h, --help Output help text and exit"
echo " -v, --version Output version information and exit"
echo " -f, --file Set the logfile and exit"
echo " -l, --level Set the log level and exit"
echo
echo "\033[0;33mLevels:\033[0;m"
echo " emergency"
echo " alert"
echo " critical"
echo " error"
echo " warning"
echo " notice"
echo " info"
echo " debug"
}
###
# Output the message to the logfile
###
function _lumberjack_message() {
local level="$1" file="$2" logtype="$3" msg="${(@)@:4}"
# If the file string is empty, output an error message
if [[ -z $file ]]; then
echo "\033[0;31mNo logfile has been set for this process. Use \`lumberjack --file /path/to/file\` to set it\033[0;m"
exit 1
fi
# If the level is not set, assume 5 (notice)
if [[ -z $level ]]; then
level=5
fi
case $logtype in
# If a valid logtype is passed
emergency|alert|critical|error|warning|notice|info|debug )
# We do nothing here
;;
# In all other cases
* )
# Second argument was not a log level, so manually set it to notice
# and include the first parameter in the message
logtype='notice'
msg="${(@)@:3}"
;;
esac
if [[ $_log_levels[$logtype] > $level ]]; then
# The message being recorded is for a higher log level than the one
# currently being recorded, so gracefully exit
exit 0
fi
# Output the message to the logfile
echo "[$(echo $logtype | tr '[a-z]' '[A-Z]')] [$(date '+%Y-%m-%d %H:%M:%S')] $msg" >> $file
}
###
# The main lumberjack process
###
function _lumberjack() {
local help version logfile loglevel dir statefile state
# Create the state directory if it doesn't exist
dir="${ZDOTDIR:-$HOME}/.lumberjack"
if [[ ! -d $dir ]]; then
mkdir -p $dir
fi
# If a statefile already exists, load the level and file
statefile="$dir/$PPID"
if [[ -f $statefile ]]; then
state=$(cat $statefile)
level="$state[1]"
file="${(@)state:2}"
fi
# Parse CLI options
zparseopts -D h=help -help=help \
v=version -version=version \
f:=logfile -file:=logfile \
l:=loglevel -level:=loglevel
# If the help option is passed, output usage information and exit
if [[ -n $help ]]; then
_lumberjack_usage
exit 0
fi
# If the version option is passed, output the version and exit
if [[ -n $version ]]; then
echo "0.1.1"
exit 0
fi
# If the logfile option is passed, set the current logfile
# for the parent process ID
if [[ -n $logfile ]]; then
shift logfile
file=$logfile
# Create the log file if it doesn't exist
if [[ ! -f $file ]]; then
touch $file
fi
fi
# If the loglevel option is passed, set the current loglevel
# for the parent process ID
if [[ -n $loglevel ]]; then
shift loglevel
level=$_log_levels[$loglevel]
fi
if [[ -z $level ]]; then
level=5
fi
# Check if we're setting options rather than logging
if [[ -n $logfile || -n $loglevel ]]; then
# Store the state
echo "$level $file" >! $statefile
# Exit gracefully
exit 0
fi
# Log the message
_lumberjack_message "$level" "$file" "$@"
}
_lumberjack "$@"

1061
bin/mo

File diff suppressed because it is too large Load diff

View file

@ -1,21 +0,0 @@
#!/usr/bin/php
<?php
$script = array_shift($_SERVER['argv']);
$settings['token'] = 'ayndqf6fdyjo9pua8reusvvb733k1u';
$settings['user'] = 'uesmxehx2bcuyv5prfrw39ema2312f';
$settings['title'] = array_shift($_SERVER['argv']);
$settings['message'] = array_shift($_SERVER['argv']);
$settings['priority'] = 1;
$curl = curl_init("https://api.pushover.net/1/messages.json");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $settings);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$return = curl_exec($curl);
curl_close($curl);
$json = json_decode($return, true);
if(isset($json['info'])) echo("Result: ${json['info']}");

View file

@ -1,318 +0,0 @@
#!/usr/bin/env zsh
local -A _revolver_spinners
_revolver_spinners=(
'dots' '0.08 ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏'
'dots2' '0.08 ⣾ ⣽ ⣻ ⢿ ⡿ ⣟ ⣯ ⣷'
'dots3' '0.08 ⠋ ⠙ ⠚ ⠞ ⠖ ⠦ ⠴ ⠲ ⠳ ⠓'
'dots4' '0.08 ⠄ ⠆ ⠇ ⠋ ⠙ ⠸ ⠰ ⠠ ⠰ ⠸ ⠙ ⠋ ⠇ ⠆'
'dots5' '0.08 ⠋ ⠙ ⠚ ⠒ ⠂ ⠂ ⠒ ⠲ ⠴ ⠦ ⠖ ⠒ ⠐ ⠐ ⠒ ⠓ ⠋'
'dots6' '0.08 ⠁ ⠉ ⠙ ⠚ ⠒ ⠂ ⠂ ⠒ ⠲ ⠴ ⠤ ⠄ ⠄ ⠤ ⠴ ⠲ ⠒ ⠂ ⠂ ⠒ ⠚ ⠙ ⠉ ⠁'
'dots7' '0.08 ⠈ ⠉ ⠋ ⠓ ⠒ ⠐ ⠐ ⠒ ⠖ ⠦ ⠤ ⠠ ⠠ ⠤ ⠦ ⠖ ⠒ ⠐ ⠐ ⠒ ⠓ ⠋ ⠉ ⠈'
'dots8' '0.08 ⠁ ⠁ ⠉ ⠙ ⠚ ⠒ ⠂ ⠂ ⠒ ⠲ ⠴ ⠤ ⠄ ⠄ ⠤ ⠠ ⠠ ⠤ ⠦ ⠖ ⠒ ⠐ ⠐ ⠒ ⠓ ⠋ ⠉ ⠈ ⠈'
'dots9' '0.08 ⢹ ⢺ ⢼ ⣸ ⣇ ⡧ ⡗ ⡏'
'dots10' '0.08 ⢄ ⢂ ⢁ ⡁ ⡈ ⡐ ⡠'
'dots11' '0.1 ⠁ ⠂ ⠄ ⡀ ⢀ ⠠ ⠐ ⠈'
'dots12' '0.08 "⢀⠀" "⡀⠀" "⠄⠀" "⢂⠀" "⡂⠀" "⠅⠀" "⢃⠀" "⡃⠀" "⠍⠀" "⢋⠀" "⡋⠀" "⠍⠁" "⢋⠁" "⡋⠁" "⠍⠉" "⠋⠉" "⠋⠉" "⠉⠙" "⠉⠙" "⠉⠩" "⠈⢙" "⠈⡙" "⢈⠩" "⡀⢙" "⠄⡙" "⢂⠩" "⡂⢘" "⠅⡘" "⢃⠨" "⡃⢐" "⠍⡐" "⢋⠠" "⡋⢀" "⠍⡁" "⢋⠁" "⡋⠁" "⠍⠉" "⠋⠉" "⠋⠉" "⠉⠙" "⠉⠙" "⠉⠩" "⠈⢙" "⠈⡙" "⠈⠩" "⠀⢙" "⠀⡙" "⠀⠩" "⠀⢘" "⠀⡘" "⠀⠨" "⠀⢐" "⠀⡐" "⠀⠠" "⠀⢀" "⠀⡀"'
'line' '0.13 - \\ | /'
'line2' '0.1 ⠂ - -'
'pipe' '0.1 ┤ ┘ ┴ └ ├ ┌ ┬ ┐'
'simpleDots' '0.4 ". " ".. " "..." " "'
'simpleDotsScrolling' '0.2 ". " ".. " "..." " .." " ." " "'
'star' '0.07 ✶ ✸ ✹ ✺ ✹ ✷'
'star2' '0.08 + x *'
'flip' "0.07 _ _ _ - \` \` ' ´ - _ _ _"
'hamburger' '0.1 ☱ ☲ ☴'
'growVertical' '0.12 ▁ ▃ ▄ ▅ ▆ ▇ ▆ ▅ ▄ ▃'
'growHorizontal' '0.12 ▏ ▎ ▍ ▌ ▋ ▊ ▉ ▊ ▋ ▌ ▍ ▎'
'balloon' '0.14 " " "." "o" "O" "@" "*" " "'
'balloon2' '0.12 . o O ° O o .'
'noise' '0.14 ▓ ▒ ░'
'bounce' '0.1 ⠁ ⠂ ⠄ ⠂'
'boxBounce' '0.12 ▖ ▘ ▝ ▗'
'boxBounce2' '0.1 ▌ ▀ ▐ ▄'
'triangle' '0.05 ◢ ◣ ◤ ◥'
'arc' '0.1 ◜ ◠ ◝ ◞ ◡ ◟'
'circle' '0.12 ◡ ⊙ ◠'
'squareCorners' '0.18 ◰ ◳ ◲ ◱'
'circleQuarters' '0.12 ◴ ◷ ◶ ◵'
'circleHalves' '0.05 ◐ ◓ ◑ ◒'
'squish' '0.1 ╫ ╪'
'toggle' '0.25 ⊶ ⊷'
'toggle2' '0.08 ▫ ▪'
'toggle3' '0.12 □ ■'
'toggle4' '0.1 ■ □ ▪ ▫'
'toggle5' '0.1 ▮ ▯'
'toggle6' '0.3 '
'toggle7' '0.08 ⦾ ⦿'
'toggle8' '0.1 ◍ ◌'
'toggle9' '0.1 ◉ ◎'
'toggle10' '0.1 ㊂ ㊀ ㊁'
'toggle11' '0.05 ⧇ ⧆'
'toggle12' '0.12 ☗ ☖'
'toggle13' '0.08 = * -'
'arrow' '0.1 ← ↖ ↑ ↗ → ↘ ↓ ↙'
'arrow2' '0.12 ▹▹▹▹▹ ▸▹▹▹▹ ▹▸▹▹▹ ▹▹▸▹▹ ▹▹▹▸▹ ▹▹▹▹▸'
'bouncingBar' '0.08 "[ ]" "[ =]" "[ ==]" "[ ===]" "[====]" "[=== ]" "[== ]" "[= ]"'
'bouncingBall' '0.08 "( ● )" "( ● )" "( ● )" "( ● )" "( ●)" "( ● )" "( ● )" "( ● )" "( ● )" "(● )"'
'pong' '0.08 "▐⠂ ▌" "▐⠈ ▌" "▐ ⠂ ▌" "▐ ⠠ ▌" "▐ ⡀ ▌" "▐ ⠠ ▌" "▐ ⠂ ▌" "▐ ⠈ ▌" "▐ ⠂ ▌" "▐ ⠠ ▌" "▐ ⡀ ▌" "▐ ⠠ ▌" "▐ ⠂ ▌" "▐ ⠈ ▌" "▐ ⠂▌" "▐ ⠠▌" "▐ ⡀▌" "▐ ⠠ ▌" "▐ ⠂ ▌" "▐ ⠈ ▌" "▐ ⠂ ▌" "▐ ⠠ ▌" "▐ ⡀ ▌" "▐ ⠠ ▌" "▐ ⠂ ▌" "▐ ⠈ ▌" "▐ ⠂ ▌" "▐ ⠠ ▌" "▐ ⡀ ▌" "▐⠠ ▌"'
'shark' '0.12 "▐|\\____________▌" "▐_|\\___________▌" "▐__|\\__________▌" "▐___|\\_________▌" "▐____|\\________▌" "▐_____|\\_______▌" "▐______|\\______▌" "▐_______|\\_____▌" "▐________|\\____▌" "▐_________|\\___▌" "▐__________|\\__▌" "▐___________|\\_▌" "▐____________|\\▌" "▐____________/|▌" "▐___________/|_▌" "▐__________/|__▌" "▐_________/|___▌" "▐________/|____▌" "▐_______/|_____▌" "▐______/|______▌" "▐_____/|_______▌" "▐____/|________▌" "▐___/|_________▌" "▐__/|__________▌" "▐_/|___________▌" "▐/|____________▌"'
)
###
# Output usage information and exit
###
function _revolver_usage() {
echo "\033[0;33mUsage:\033[0;m"
echo " revolver [options] <command> <message>"
echo
echo "\033[0;33mOptions:\033[0;m"
echo " -h, --help Output help text and exit"
echo " -v, --version Output version information and exit"
echo " -s, --style Set the spinner style"
echo
echo "\033[0;33mCommands:\033[0;m"
echo " start <message> Start the spinner"
echo " update <message> Update the message"
echo " stop Stop the spinner"
echo " demo Display an demo of each style"
}
###
# The main revolver process, which contains the loop
###
function _revolver_process() {
local dir statefile state msg pid="$1" spinner_index=0
# Find the directory and load the statefile
dir=${REVOLVER_DIR:-"${ZDOTDIR:-$HOME}/.revolver"}
statefile="$dir/$pid"
# The frames that, when animated, will make up
# our spinning indicator
frames=(${(@z)_revolver_spinners[$style]})
interval=${(@z)frames[1]}
shift frames
# Create a never-ending loop
while [[ 1 -eq 1 ]]; do
# If the statefile has been removed, exit the script
# to prevent it from being orphaned
if [[ ! -f $statefile ]]; then
exit 1
fi
# Check for the existence of the parent process
$(kill -s 0 $pid 2&>/dev/null)
# If process doesn't exist, exit the script
# to prevent it from being orphaned
if [[ $? -ne 0 ]]; then
exit 1
fi
# Load the current state, and parse it to get
# the message to be displayed
state=($(cat $statefile))
msg="${(@)state:1}"
# Output the current spinner frame, and add a
# slight delay before the next one
_revolver_spin
sleep ${interval:-"0.1"}
done
}
###
# Output the spinner itself, along with a message
###
function _revolver_spin() {
local dir statefile state pid frame
# ZSH arrays start at 1, so we need to bump the index if it's 0
if [[ $spinner_index -eq 0 ]]; then
spinner_index+=1
fi
# Calculate the screen width
lim=$(tput cols)
# Clear the line and move the cursor to the start
printf ' %.0s' {1..$lim}
echo -n "\r"
# Echo the current frame and message, and overwrite
# the rest of the line with white space
msg="\033[0;38;5;242m${msg}\033[0;m"
frame="${${(@z)frames}[$spinner_index]//\"}"
printf '%*.*b' ${#msg} $lim "$frame $msg$(printf '%0.1s' " "{1..$lim})"
# Return to the beginning of the line
echo -n "\r"
# Set the spinner index to the next frame
spinner_index=$(( $(( $spinner_index + 1 )) % $(( ${#frames} + 1 )) ))
}
###
# Stop the current spinner process
###
function _revolver_stop() {
local dir statefile state pid
# Find the directory and load the statefile
dir=${REVOLVER_DIR:-"${ZDOTDIR:-$HOME}/.revolver"}
statefile="$dir/$PPID"
# If the statefile does not exist, raise an error.
# The spinner process itself performs the same check
# and kills itself, so it should never be orphaned
if [[ ! -f $statefile ]]; then
echo '\033[0;31mRevolver process could not be found\033[0;m'
exit 1
fi
# Get the current state, and parse it to find the PID
# of the spinner process
state=($(cat $statefile))
pid="$state[1]"
# Clear the line and move the cursor to the start
printf ' %.0s' {1..$(tput cols)}
echo -n "\r"
# If a PID has been found, kill the process
[[ ! -z $pid ]] && kill "$pid" > /dev/null
unset pid
# Remove the statefile
rm $statefile
}
###
# Update the message being displayed
function _revolver_update() {
local dir statefile state pid msg="$1"
# Find the directory and load the statefile
dir=${REVOLVER_DIR:-"${ZDOTDIR:-$HOME}/.revolver"}
statefile="$dir/$PPID"
# If the statefile does not exist, raise an error.
# The spinner process itself performs the same check
# and kills itself, so it should never be orphaned
if [[ ! -f $statefile ]]; then
echo '\033[0;31mRevolver process could not be found\033[0;m'
exit 1
fi
# Get the current state, and parse it to find the PID
# of the spinner process
state=($(cat $statefile))
pid="$state[1]"
# Clear the line and move the cursor to the start
printf ' %.0s' {1..$(tput cols)}
echo -n "\r"
# Echo the new message to the statefile, to be
# picked up by the spinner process
echo "$pid $msg" >! $statefile
}
###
# Create a new spinner with the specified message
###
function _revolver_start() {
local dir statefile msg="$1"
# Find the directory and create it if it doesn't exist
dir=${REVOLVER_DIR:-"${ZDOTDIR:-$HOME}/.revolver"}
if [[ ! -d $dir ]]; then
mkdir -p $dir
fi
# Create the filename for the statefile
statefile="$dir/$PPID"
touch $statefile
if [[ ! -f $statefile ]]; then
echo '\033[0;31mRevolver process could not create state file\033[0;m'
echo "Check that the directory $dir is writable"
exit 1
fi
# Start the spinner process in the background
_revolver_process $PPID &!
# Save the current state to the statefile
echo "$! $msg" >! $statefile
}
###
# Demonstrate each of the included spinner styles
###
function _revolver_demo() {
for style in "${(@k)_revolver_spinners[@]}"; do
revolver --style $style start $style
sleep 2
revolver stop
done
}
###
# Handle command input
###
function _revolver() {
# Get the context from the first parameter
local help version style ctx="$1"
# Parse CLI options
zparseopts -D \
h=help -help=help \
v=version -version=version \
s:=style -style:=style
# Output usage information and exit
if [[ -n $help ]]; then
_revolver_usage
exit 0
fi
# Output version information and exit
if [[ -n $version ]]; then
echo '0.2.0'
exit 0
fi
if [[ -z $style ]]; then
style='dots'
fi
if [[ -n $style ]]; then
shift style
ctx="$1"
fi
if [[ -z $_revolver_spinners[$style] ]]; then
echo $(color red "Spinner '$style' is not recognised")
exit 1
fi
case $ctx in
start|update|stop|demo)
# Check if a valid command is passed,
# and if so, run it
_revolver_${ctx} "${(@)@:2}"
;;
*)
# If the context is not recognised,
# throw an error and exit
echo "Command $ctx is not recognised"
exit 1
;;
esac
}
_revolver "$@"

688
bin/shml
View file

@ -1,688 +0,0 @@
#!/usr/bin/env bash
#SHML:START
#************************************************#
# SHML - Shell Markup Language Framework
# v1.1.0
# (MIT)
# by Justin Dorfman - @jdorfman
# && Joshua Mervine - @mervinej
#
# http://shml.xyz
#************************************************#
SHML_VERSION="1.1.0"
# Progress Bar
##
# options:
# SHML_PROGRESS_CHAR - width of progress bar, default '#'
# SHML_PROGRESS_WIDTH - width of progress bar, default 60
# SHML_PROGRESS_MAX - maximum progress value, default 100
# SHML_PROGRESS_BREAK - put a new line at the end of the output, default 'true'
# SHML_PROGRESS_CLEAR - clear line at the end of the output, default 'false'
# SHML_PGOGRESS_NOCURSOR - hide the cursor, default 'true'
progress() {
[[ -z $SHML_PROGRESS_WIDTH ]] && SHML_PROGRESS_WIDTH=60
[[ -z $SHML_PROGRESS_BREAK ]] && SHML_PROGRESS_BREAK=true
[[ -z $SHML_PROGRESS_CLEAR ]] && SHML_PROGRESS_CLEAR=false
[[ -z $SHML_PROGRESS_NOCURSOR ]] && SHML_PROGRESS_NOCURSOR=true
# defaults
local __title="Progress"
local __steps=10
local __char="#"
# arg parser
[[ ! -z $1 ]] && __title=$1
[[ ! -z $2 ]] && __steps=$2
[[ ! -z $3 ]] && __char="$3"
local __width=${SHML_PROGRESS_WIDTH}
local __break=${SHML_PROGRESS_BREAK}
local __clear=${SHML_PROGRESS_CLEAR}
local __ncursor=${SHML_PROGRESS_NOCURSOR}
local __pct=0
local __num=0
local __len=0
local __bar=''
local __line=''
# ensure terminal
[[ -t 1 ]] || return 1
# ensure tput
if test "$(which tput)"; then
if $__ncursor; then
# hide cursor
tput civis
trap 'tput cnorm; exit 1' SIGINT
fi
fi
while read __value; do
# compute pct
__pct=$(( __value * 100 / __steps ))
# compute number of blocks to display
__num=$(( __value * __width / __steps ))
# create bar string
if [ $__num -gt 0 ]; then
__bar=$(printf "%0.s${__char}" $(seq 1 $__num))
fi
__line=$(printf "%s [%-${__witdth}s] (%d%%)" "$__title" "$__bar" "$__pct")
# print bar
echo -en "${__line}\r"
done
# clear line if requested
if $__clear; then
__len=$(echo -en "$__line" | wc -c)
printf "%$((__len + 1))s\r" " "
fi
# new line if requested
$__break && echo
# show cursor again
test "$(which tput)" && $__ncursor && tput cnorm
}
# Confirm / Dialog
##
__default_confirm_success_input="y Y yes Yes YES ok OK Ok okay Okay OKAY k K continue Continue CONTINUE proceed Proceed PROCEED success Success SUCCESS successful Successful SUCCESSFUL good Good GOOD"
confirm() {
[[ -z $1 ]] && return 127
[[ -z $SHML_CONFIRM_SUCCESS ]] && SHML_CONFIRM_SUCCESS=$__default_confirm_success_input
echo -ne "$1 "
local found=false
while read __input; do
for str in $(echo $SHML_CONFIRM_SUCCESS); do
[[ "$str" == "$__input" ]] && found=true
done
break
done
if $found; then
[[ ! -z $2 ]] && eval $2
return 0
else
[[ ! -z $3 ]] && eval $3
return 1
fi
}
dialog() {
[[ -z $1 ]] && return 127
[[ -z $2 ]] && return 127
echo -en "$1 "
while read __input; do
eval "$2 $__input"
break
done
}
# Foreground (Text)
##
fgcolor() {
local __end='\033[39m'
local __color=$__end # end by default
case "$1" in
end|off|reset) __color=$__end;;
black|000000|000) __color='\033[30m';;
red|F00BAF) __color='\033[31m';;
green|00CD00) __color='\033[32m';;
yellow|CDCD00) __color='\033[33m';;
blue|0286fe) __color='\033[34m';;
magenta|e100cc) __color='\033[35m';;
cyan|00d3cf) __color='\033[36m';;
gray|e4e4e4) __color='\033[90m';;
darkgray|4c4c4c) __color='\033[91m';;
lightgreen|00fe00) __color='\033[92m';;
lightyellow|f8fe00) __color='\033[93m';;
lightblue|3a80b5) __color='\033[94m';;
lightmagenta|fe00fe) __color='\033[95m';;
lightcyan|00fefe) __color='\033[96m';;
white|ffffff|fff) __color='\033[97m';;
esac
if test "$2"; then
echo -en "$__color$2$__end"
else
echo -en "$__color"
fi
}
# Backwards Compatibility
color() {
fgcolor "$@"
}
# Aliases
fgc() {
fgcolor "$@"
}
c() {
fgcolor "$@"
}
# Background
##
bgcolor() {
local __end='\033[49m'
local __color=$__end # end by default
case "$1" in
end|off|reset) __color=$__end;;
black|000000|000) __color='\033[40m';;
red|F00BAF) __color='\033[41m';;
green|00CD00) __color='\033[42m';;
yellow|CDCD00) __color='\033[43m';;
blue|0286fe) __color='\033[44m';;
magenta|e100cc) __color='\033[45m';;
cyan|00d3cf) __color='\033[46m';;
gray|e4e4e4) __color='\033[47m';;
darkgray|4c4c4c) __color='\033[100m';;
lightred) __color='\033[101m';;
lightgreen|00fe00) __color='\033[102m';;
lightyellow|f8fe00) __color='\033[103m';;
lightblue|3a80b5) __color='\033[104m';;
lightmagenta|fe00fe) __color='\033[105m';;
lightcyan|00fefe) __color='\033[106m';;
white|fffff|fff) __color='\033[107m';;
esac
if test "$2"; then
echo -en "$__color$2$__end"
else
echo -en "$__color"
fi
}
#Backwards Compatibility
background() {
bgcolor "$@"
}
#Aliases
bgc() {
bgcolor "$@"
}
bg() {
bgcolor "$@"
}
## Color Bar
color-bar() {
if test "$2"; then
for i in "$@"; do
echo -en "$(background "$i" " ")"
done; echo
else
for i in {16..21}{21..16}; do
echo -en "\033[48;5;${i}m \033[0m"
done; echo
fi
}
#Alises
cb() {
color-bar "$@"
}
bar() {
color-bar "$@"
}
## Attributes
##
attribute() {
local __end='\033[0m'
local __attr=$__end # end by default
case "$1" in
end|off|reset) __attr=$__end;;
bold) __attr='\033[1m';;
dim) __attr='\033[2m';;
underline) __attr='\033[4m';;
blink) __attr='\033[5m';;
invert) __attr='\033[7m';;
hidden) __attr='\033[8m';;
esac
if test "$2"; then
echo -en "$__attr$2$__end"
else
echo -en "$__attr"
fi
}
a() {
attribute "$@"
}
## Elements
br() {
echo -e "\n\r"
}
tab() {
echo -e "\t"
}
indent() {
local __len=4
local __int='^[0-9]+$'
if test "$1"; then
if [[ $1 =~ $__int ]] ; then
__len=$1
fi
fi
while [ $__len -gt 0 ]; do
echo -n " "
__len=$(( $__len - 1 ))
done
}
i() {
indent "$@"
}
hr() {
local __len=60
local __char='-'
local __int='^[0-9]+$'
if ! test "$2"; then
if [[ $1 =~ $__int ]] ; then
__len=$1
elif test "$1"; then
__char=$1
fi
else
__len=$2
__char=$1
fi
while [ $__len -gt 0 ]; do
echo -n "$__char"
__len=$(( $__len - 1 ))
done
}
# Icons
##
icon() {
local i='';
case "$1" in
check|checkmark) i='\xE2\x9C\x93';;
X|x|xmark) i='\xE2\x9C\x98';;
'<3'|heart) i='\xE2\x9D\xA4';;
sun) i='\xE2\x98\x80';;
'*'|star) i='\xE2\x98\x85';;
darkstar) i='\xE2\x98\x86';;
umbrella) i='\xE2\x98\x82';;
flag) i='\xE2\x9A\x91';;
snow|snowflake) i='\xE2\x9D\x84';;
music) i='\xE2\x99\xAB';;
scissors) i='\xE2\x9C\x82';;
tm|trademark) i='\xE2\x84\xA2';;
copyright) i='\xC2\xA9';;
apple) i='\xEF\xA3\xBF';;
skull|bones) i='\xE2\x98\xA0';;
':-)'|':)'|smile|face) i='\xE2\x98\xBA';;
esac
echo -ne "$i";
}
# Emojis
##
emoji() {
local i=""
case "$1" in
1F603|smiley|'=)'|':-)'|':)') i='😃';;
1F607|innocent|halo) i='😇';;
1F602|joy|lol|laughing) i='😂';;
1F61B|tongue|'=p'|'=P') i='😛';;
1F60A|blush|'^^'|blushing) i='😊';;
1F61F|worried|sadface|sad) i='😟';;
1F622|cry|crying|tear) i='😢';;
1F621|rage|redface) i='😡';;
1F44B|wave|hello|goodbye) i='👋';;
1F44C|ok_hand|perfect|okay|nice|ok) i='👌';;
1F44D|thumbsup|+1|like) i='👍';;
1F44E|thumbsdown|-1|no|dislike) i='👎';;
1F63A|smiley_cat|happycat) i='😺';;
1F431|cat|kitten|:3|kitty) i='🐱';;
1F436|dog|puppy) i='🐶';;
1F41D|bee|honeybee|bumblebee) i='🐝';;
1F437|pig|pighead) i='🐷';;
1F435|monkey_face|monkey) i='🐵';;
1F42E|cow|happycow) i='🐮';;
1F43C|panda_face|panda|shpanda) i='🐼';;
1F363|sushi|raw|sashimi) i='🍣';;
1F3E0|home|house) i='🏠';;
1F453|eyeglasses|bifocals) i='👓';;
1F6AC|smoking|smoke|cigarette) i='🚬';;
1F525|fire|flame|hot|snapstreak) i='🔥';;
1F4A9|hankey|poop|poo|shit) i='💩';;
1F37A|beer|homebrew|brew) i='🍺';;
1F36A|cookie|biscuit|chocolate) i='🍪';;
1F512|lock|padlock|secure) i='🔒';;
1F513|unlock|openpadlock) i='🔓';;
2B50|star|yellowstar) i='⭐';;
1F0CF|black_joker|joker|wild) i='🃏';;
2705|white_check_mark|check) i='✅';;
274C|x|cross|xmark) i='❌';;
1F6BD|toilet|restroom|loo) i='🚽';;
1F514|bell|ringer|ring) i='🔔';;
1F50E|mag_right|search|magnify) i='🔎';;
1F3AF|dart|bullseye|darts) i='🎯';;
1F4B5|dollar|cash|cream) i='💵';;
1F4AD|thought_balloon|thinking) i='💭';;
1F340|four_leaf_clover|luck) i='🍀';;
esac
echo -ne "$i"
}
function e {
emoji "$@"
}
#SHML:END
# Usage / Examples
##
if [ "$0" = "$BASH_SOURCE" ]; then
if [[ $@ =~ .*-v.* ]]; then
echo "shml version ${SHML_VERSION}"
exit 0
fi
I=2
echo -e "
$(color "lightblue")
#$(hr "*" 48)#
# SHML - Shell Markup Language Framework
# v${SHML_VERSION}
# (MIT)
# by Justin Dorfman - @jdorfman
# && Joshua Mervine - @mervinej
#
# https://maxcdn.github.io/shml/
#$(hr "*" 48)#
$(color "end")
$(a bold 'SHML Usage / Help')
$(hr '=')
$(a bold 'Section 0: Sourcing')
$(hr '-')
$(i $I)When installed in path:
$(i $I) source \$(which shml.sh)
$(i $I)When installed locally:
$(i $I) source ./shml.sh
$(a bold 'Section 1: Foreground')
$(hr '-')
$(i $I)\$(color red \"foo bar\")
$(i $I)$(color red "foo bar")
$(i $I)\$(color blue \"foo bar\")
$(i $I)$(color blue "foo bar")
$(i $I)\$(fgcolor green)
$(i $I) >>foo bar<<
$(i $I) >>bah boo<<
$(i $I)\$(fgcolor end)
$(i $I)$(fgcolor green)
$(i $I)>>foo bar<<
$(i $I)>>bah boo<<
$(i $I)$(fgcolor end)
$(i $I)Short Hand: $(a underline 'c')
$(i $I)\$(c red 'foo')
$(i $I)Argument list:
$(i $I)black, red, green, yellow, blue, magenta, cyan, gray,
$(i $I)white, darkgray, lightgreen, lightyellow, lightblue,
$(i $I)lightmagenta, lightcyan
$(i $I)Termination: end, off, reset
$(i $I)Default (no arg): end
$(a bold 'Section 2: Background')
$(hr '-')
$(i $I)\$(bgcolor red \"foo bar\")
$(i $I)$(background red "foo bar")
$(i $I)\$(background blue \"foo bar\")
$(i $I)$(background blue "foo bar")
$(i $I)\$(background green)
$(i $I)$(i $I)>>foo bar<<
$(i $I)$(i $I)>>bah boo<<
$(i $I)\$(background end)
$(background green)
$(i $I)>>foo bar<<
$(i $I)>>bah boo<<
$(background end)
$(i $I)Short Hand: $(a underline 'bg')
$(i $I)\$(bg red 'foo')
$(i $I)Argument list:
$(i $I)black, red, green, yellow, blue, magenta, cyan, gray,
$(i $I)white, darkgray, lightred, lightgreen, lightyellow,
$(i $I)lightblue, lightmagenta, lightcyan
$(i $I)Termination: end, off, reset
$(i $I)Default (no arg): end
$(a bold 'Section 3: Attributes')
$(hr '-')
$(i $I)$(a bold "Attributes only work on vt100 compatible terminals.")
$(i $I)> Note:
$(i $I)> $(a underline 'attribute end') turns off everything,
$(i $I)> including foreground and background color.
$(i $I)\$(attribute bold \"foo bar\")
$(i $I)$(attribute bold "foo bar")
$(i $I)\$(attribute underline \"foo bar\")
$(i $I)$(attribute underline "foo bar")
$(i $I)\$(attribute blink \"foo bar\")
$(i $I)$(attribute blink "foo bar")
$(i $I)\$(attribute invert \"foo bar\")
$(i $I)$(attribute invert "foo bar")
$(i $I)\$(attribute dim)
$(i $I)$(i $I)>>foo bar<<
$(i $I)$(i $I)>>bah boo<<
$(i $I)\$(attribute end)
$(i $I)$(attribute dim)
$(i $I)$(i $I)>>foo bar<<
$(i $I)$(i $I)>>bah boo<<
$(i $I)$(attribute end)
$(i $I)Short Hand: $(a underline 'a')
$(i $I)\$(a bold 'foo')
$(i $I)Argument list:
$(i $I)bold, dim, underline, blink, invert, hidden
$(i $I)Termination: end, off, reset
$(i $I)Default (no arg): end
$(a bold 'Section 4: Elements')
$(hr '-')
$(i $I)foo\$(br)\$(tab)bar
$(i $I)foo$(br)$(tab)bar
$(i $I)
$(i $I)foo\$(br)\$(indent)bar\$(br)\$(indent 6)boo
$(i $I)foo$(br)$(indent)bar$(br)$(indent 6)boo
$(i $I)
$(i $I)> Note: short hand for $(a underline 'indent') is $(a underline 'i')
$(i $I)
$(i $I)\$(hr)
$(i $I)$(hr)
$(i $I)
$(i $I)\$(hr 50)
$(i $I)$(hr 50)
$(i $I)
$(i $I)\$(hr '~' 40)
$(i $I)$(hr '~' 40)
$(i $I)
$(i $I)\$(hr '#' 30)
$(i $I)$(hr '#' 30)
$(a bold 'Section 5: Icons')
$(hr '-')
$(i $I)Icons
$(i $I)$(hr '-' 10)
$(i $I)\$(icon check) \$(icon '<3') \$(icon '*') \$(icon ':)')
$(i $I)$(icon check) $(icon '<3') $(icon '*') $(icon 'smile')
$(i $I)Argument list:
$(i $I)check|checkmark, X|x|xmark, <3|heart, sun, *|star,
$(i $I)darkstar, umbrella, flag, snow|snowflake, music,
$(i $I)scissors, tm|trademark, copyright, apple,
$(i $I):-)|:)|smile|face
$(a bold 'Section 6: Emojis')
$(hr '-')
$(i $I)Couldn't peep it with a pair of \$(emoji bifocals)
$(i $I)Couldn't peep it with a pair of $(emoji bifocals)
$(i $I)
$(i $I)I'm no \$(emoji joker) play me as a \$(emoji joker)
$(i $I)I'm no $(emoji joker) play me as a $(emoji joker)
$(i $I)
$(i $I)\$(emoji bee) on you like a \$(emoji house) on \$(emoji fire), \$(emoji smoke) ya
$(i $I)$(emoji bee) on you like a $(emoji house) on $(emoji fire), $(emoji smoke) ya
$(i $I)
$(i $I)$(a bold 'Each Emoji has 1 or more alias')
$(i $I)
$(i $I)\$(emoji smiley) \$(emoji 1F603) \$(emoji '=)') \$(emoji ':-)') \$(emoji ':)')
$(i $I)$(emoji smiley) $(emoji 1F603) $(emoji '=)') $(emoji ':-)') $(emoji ':)')
$(a bold 'Section 7: Color Bar')
$(hr '-')
$(i $I)\$(color-bar)
$(i $I)$(color-bar)
$(i $I)
$(i $I)\$(color-bar red green yellow blue magenta \\
$(i $I)$(i 15)cyan lightgray darkgray lightred \\
$(i $I)$(i 15)lightgreen lightyellow lightblue \\
$(i $I)$(i 15)lightmagenta lightcyan)
$(i $I)$(color-bar red green yellow blue magenta \
cyan lightgray darkgray lightred \
lightgreen lightyellow lightblue \
lightmagenta lightcyan)
$(i $I)Short Hand: $(a underline 'bar')
$(i $I)
$(i $I)\$(bar black yellow black yellow black yellow)
$(i $I)$(bar black yellow black yellow black yellow)
$(a bold "Section 8: $(color red "[EXPERIMENTAL]") Progress Bar")
$(hr '-')
$(i $I)Usage: progress [TITLE] [STEPS] [CHAR]
$(i $I) - 'title' defines the progress bar title
$(i $I) - 'steps' defines the number of steps for the progress bar to act upon
$(i $I) - 'char' defines the character to be displayed in the progress bar
$(i $I)Example:
$(i $I)echo "\$\(color green\)"
$(i $I)for i in \$(seq 0 10); do echo \$i; sleep .25; done | progress
$(i $I)echo "\$\(color end\)"
$(color green "$(i $I)Example [#################### ] (50%)")
$(i $I)'progress' supports overriding default values by setting the following variables:
$(i $I) - SHML_PROGRESS_WIDTH - width of progress bar, default 60
$(i $I) - SHML_PROGRESS_BREAK - put a new line at the end of the output, default 'true'
$(i $I) - SHML_PROGRESS_CLEAR - clear line at the end of the output, default 'false'
$(i $I) - SHML_PGOGRESS_NOCURSOR - hide the cursor, default 'true'
$(i $I)NOTE: These variables $(a bold 'must') be defined before sourcing 'shml'!
$(a bold "Section 9: $(color red "[EXPERIMENTAL]") Confirm")
$(hr '-')
$(i $I)Ask a yes or no question and handle results.
$(i $I)Usage: confirm QUESTION [SUCCESS_FUNCTION] [FAILURE_FUNCTION]
$(i $I)Supports the following as affirmitive responses by default:
$(for r in `echo "$__default_confirm_success_input"`; do echo "$(i $I) - '$r'"; done)
$(i $I)Default affirmtive responses can be overwritten by setting 'SHML_CONFIRM_SUCCESS'.
$(i $I)Example:
$(i $I)function on_success() {
$(i $I) echo \"yay\"
$(i $I)}
$(i $I)function on_failure() {
$(i $I) echo \"boo\"
$(i $I)}
$(i $I)confirm \"CREAM?\" \"on_success\" \"on_failure\"
$(a bold "Section 9: $(color red "[EXPERIMENTAL]") Dialog")
$(hr '-')
$(i $I)Asks a question and passes the answer to a response handler function.
$(i $I)Usage: dialog QUESTION [RESPONSE_FUNCTION]
$(i $I)Example:
$(i $I)function on_response() {
$(i $I) echo \"hello $1\"
$(i $I)}
$(i $I)dialog \"What is your name?\" \"on_response\"
" | less -r
fi
# vim: ft=sh:

View file

@ -1,309 +0,0 @@
# Configuration file for dircolors, a utility to help you set the
# LS_COLORS environment variable used by GNU ls with the --color option.
# Copyright (C) 1996, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
# Free Software Foundation, Inc.
# Copying and distribution of this file, with or without modification,
# are permitted provided the copyright notice and this notice are preserved.
#
# You can copy this file to .dir_colors in your $HOME directory to override
# the system defaults.
# Below, there should be one TERM entry for each termtype that is colorizable
TERM Eterm
TERM ansi
TERM color-xterm
TERM con132x25
TERM con132x30
TERM con132x43
TERM con132x60
TERM con80x25
TERM con80x28
TERM con80x30
TERM con80x43
TERM con80x50
TERM con80x60
TERM console
TERM cygwin
TERM dtterm
TERM gnome
TERM konsole
TERM kterm
TERM linux
TERM linux-c
TERM mach-color
TERM mlterm
TERM putty
TERM rxvt
TERM rxvt-cygwin
TERM rxvt-cygwin-native
TERM rxvt-unicode
TERM screen
TERM screen-256color
TERM screen-bce
TERM screen-w
TERM screen.linux
TERM vt100
TERM xterm
TERM xterm-256color
TERM xterm-color
TERM xterm-debian
# Special files
# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
NORMAL 00;37 # global default, although everything should be something.
FILE 01;34 # normal file
RESET 00;37 # reset to "normal" color
DIR 00;34 # directory
LINK 00;36 # symbolic link. (If you set this to 'target' instead of a
# numerical value, the color is as for the file pointed to.)
MULTIHARDLINK 00;37 # regular file with more than one link
FIFO 40;33 # pipe
SOCK 00;35 # socket
DOOR 00;35 # door
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver
ORPHAN 00;05;37;41 # orphaned syminks
MISSING 00;05;37;41 # ... and the files they point to
SETUID 37;41 # file that is setuid (u+s)
SETGID 30;43 # file that is setgid (g+s)
CAPABILITY 30;41 # file with capability
STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
OTHER_WRITABLE 04;34 # dir that is other-writable (o+w) and not sticky
STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable
EXEC 00;32 # This is for files with execute permission:
# If you use DOS-style suffixes, you may want to uncomment the following:
.cmd 00;33 # executables (bright green)
.exe 00;33
.com 00;33
.btm 00;33
.bat 00;33
## Archives or compressed (red)
.tar 01;31
.tgz 01;31
.arj 01;31
.taz 01;31
.lzh 01;31
.lzma 01;31
.tlz 01;31
.txz 01;31
.zip 01;31
.z 01;31
.Z 01;31
.dz 01;31
.gz 01;31
.lz 01;31
.xz 01;31
.bz 01;31
.bz2 01;31
.bzip2 01;31
.tbz 01;31
.tbz2 01;31
.tz 01;31
.deb 01;31
.rpm 01;31
.jar 01;31
.rar 01;31 # rar
.ace 01;31 # unace
.zoo 01;31 # zoo
.cpio 01;31 # cpio
.7z 01;31 # p7zip
.rz 01;31 # rzip
.apk 01;31 # rzip
.gem 01;31 # rzip
## image formats (magenta)
.jpg 00;35
.JPG 00;35
.jpeg 00;35
.gif 00;35
.bmp 00;35
.pbm 00;35
.pgm 00;35
.ppm 00;35
.tga 00;35
.xbm 00;35
.xpm 00;35
.tif 00;35
.tiff 00;35
.png 00;35
.svg 00;35
.svgz 00;35
.mng 00;35
.pcx 00;35
.dl 00;35
.xcf 00;35
.xwd 00;35
.yuv 00;35
.cgm 00;35
.emf 00;35
.eps 00;35
.CR2 00;35
.ico 00;35
## Document files (green)
.pdf 00;32
.ps 00;32
.txt 00;32
.html 00;32
.rst 00;32
.md 00;32
.patch 00;32
.diff 00;32
.tex 00;32
.doc 00;32
.xml 00;32
.xls 00;32
.xlsx 00;32
.doc 00;32
.docx 00;32
.ppt 00;32
.pptx 00;32
.key 00;32 # Keynote presentation
## Template files (bright green)
.pt 01;32 # Zope page template
.tmpl 01;32
.in 01;32
## Audio formats (bright red)
.aac 01;36
.au 01;36
.flac 01;36
.mid 01;36
.midi 01;36
.mka 01;36
.mp3 01;36
.mpc 01;36
.ogg 01;36
.ra 01;36
.wav 01;36
.m4a 01;36
.axa 01;36
.oga 01;36
.spx 01;36
.xspf 01;36
## Video formats (as audio + bold)
.mov 01;36
.mpg 01;36
.mpeg 01;36
.m2v 01;36
.mkv 01;36
.ogm 01;36
.mp4 01;36
.m4v 01;36
.mp4v 01;36
.vob 01;36
.qt 01;36
.nuv 01;36
.wmv 01;36
.asf 01;36
.rm 01;36
.rmvb 01;36
.flc 01;36
.avi 01;36
.fli 01;36
.flv 01;36
.gl 01;36
.m2ts 01;36
.divx 01;36
.webm 01;36
.axv 01;36
.anx 01;36
.ogv 01;36
.ogx 01;36
## Config files (cyan)
.conf 00;36
.cnf 00;36
.cfg 00;36
.ini 00;36
.properties 00;36
.yaml 00;36
.vcl 00;36 # Varnish
## Source code files (yellow)
.c 00;33
.cpp 00;33
.py 00;33
.coffesscript 00;33
.js 00;33
.rb 00;33
.sh 00;33
.zsh 00;33
.env 00;33
.bash 00;33
.php 00;33
.java 00;33
.zcml 00;33 # Zope configuration language
## Data / database (green)
.db 00;32
.sql 00;32
.json 00;32
.plist 00;32 # OSX properties
.fs 00;32 # ZODB Data.fs
## Files of special interest (base1 + bold)
.tex 01;37
.rdf 01;37
.owl 01;37
.n3 01;37
.ttl 01;37
.nt 01;37
.torrent 01;37
.xml 01;37
*Makefile 01;37
*Rakefile 01;37
*build.xml 01;37
*rc 01;37
.nfo 01;37
*README 01;37
*README.txt 01;37
*readme.txt 01;37
*README.markdown 01;37
*README.md 01;37
.ini 01;37
.yml 01;37
.cfg 01;37
.conf 01;37
.c 01;37
.cpp 01;37
.cc 01;37
## Machine generated files / non-important (bright black)
.log 01;30
.bak 01;30
.aux 01;30
.lof 01;30
.lol 01;30
.lot 01;30
.out 01;30
.toc 01;30
.bbl 01;30
.blg 01;30
*~ 01;30
*# 01;30
.part 01;30
.incomplete 01;30
.swp 01;30
.tmp 01;30
.temp 01;30
.o 01;30
.obj 01;30
.pyc 01;30
.pyo 01;30
.class 01;30
.cache 01;30
.egg-info 01;30

View file

@ -1,7 +0,0 @@
- clean: ['~']
- link:
~/.gitconfig: cfg/git/cfg
~/.zshrc: cfg/zsh/cfg.zsh
~/.ssh/config: cfg/ssh/cfg
~/dotfiles/bin/has: lib/has/has

View file

@ -1,101 +0,0 @@
[user]
email = nikolasweger@googlemail.com
name = Nikolas Weger
[alias]
exec = ! "exec"
st = status -sb
br = branch -vv
bra = branch -vv --all
bed = branch --edit-description
aa = add --all :/
ci = commit -v
ca = commit --amend -v
save = commit -a -m "Save"
co = checkout
di = diff
dis = diff --stat
diw = diff --color-words
dic = diff --color-words=.
dc = diff --cached
dcs = diff --cached --stat
dcw = diff --cached --color-words
dcc = diff --cached --color-words=.
dh = diff HEAD~
dhs = diff HEAD~ --stat
dhw = diff HEAD~ --color-words
dhc = diff HEAD~ --color-words=.
grp = grep -C 1
ff = merge --ff-only
noff = merge --no-ff
fa = fetch --all
deleted = remote prune --dry-run
prunable = ! "pr() { git remote | xargs -L 1 git deleted; }; pr"
pruneall = ! "pa() { git remote | xargs -L 1 git remote prune; }; pa"
pullff = pull --ff-only
pullrb = pull --rebase
mirror-remote = ! "mr() { git push \"${2}\" \"refs/remotes/${1}/*:refs/heads/*\" && git remote set-head \"${2}\" -a; }; mr"
count = diff --stat "4b825dc642cb6eb9a060e54bf8d69288fbee4904" # hash of empty tree
credit = shortlog -sn
linecredit = ! "lc() { git ls-tree --name-only -z -r HEAD | xargs -0 -n1 git diff --no-index --numstat /dev/null 2>/dev/null | grep -v '^-' | cut -f 3- | cut -d ' ' -f 3- | xargs -n1 git blame --line-porcelain | grep '^author ' | cut -d ' ' -f 2- | sort | uniq -c | sort -nr; }; lc"
cc = rev-list HEAD --count
cca = rev-list --all --count
lg = log -p
gr = log --graph --format=compact # graph
grl = log --graph --format=line # graph line
grd = log --graph --format=detail # graph detail
gra = log --graph --format=compact --all # graph all
gral = log --graph --format=line --all # graph all line
grad = log --graph --format=detail --all # graph all in detail
sf = show --format=fuller
sfs = show --format=fuller --stat
info = ! "inf() { if git rev-parse ${1} >/dev/null 2>&1; then git cat-file -p $(git rev-parse ${1}); else echo Invalid object; fi }; inf"
cleanall = clean -fdx # this is dangerous, so it's intentionally long to type
update-submodules = submodule update --init --recursive
upgrade-submodules = submodule update --init --remote
upgrade-all-submodules = submodule foreach git pull origin master
empty-tree-hash = hash-object -t tree /dev/null
root = rev-parse --show-toplevel
ctags = ! "ctg() { trap \"rm -f .git/tags.$$\" EXIT; ctags --tag-relative -Rf.git/tags.$$ --exclude=.git; mv .git/tags.$$ .git/tags; }; ctg"
tar = ! "tar() { git archive --format tar --prefix=\"${PWD##*/}/\" HEAD -o ${1}; }; tar"
targz = ! "targz() { git archive --format tar.gz --prefix=\"${PWD##*/}/\" HEAD -o ${1}; }; targz"
zip = ! "zip() { git archive --format zip --prefix=\"${PWD##*/}/\" HEAD -o ${1}; }; zip"
[color]
ui = auto
[color "grep"]
match = cyan bold
selected = blue
context = normal
filename = magenta
linenumber = green
separator = yellow
function = blue
[pretty]
line = "%C(auto)%h%d %s %C(yellow)by %C(blue)%an %C(green)%ar"
compact = "%C(auto)%h %s %C(green)%ar%n %C(auto)%d%n"
detail = "%C(auto)%h %s%n %C(yellow)by %C(blue)%an %C(magenta)<%ae> [%G?] %C(green)%ar%n %C(auto)%d%n"
[merge]
defaultToUpstream = true
tool = vimdiff
[mergetool]
keepBackup = false
[push]
default = upstream
[credential]
helper = cache --timeout=3600
[grep]
lineNumber = true
[advice]
detachedHead = false
[core]
excludesfile = ~/dotfiles/git/gitignore_global

View file

@ -1,31 +0,0 @@
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
*.pyc
# Editing tools and IDEs #
##########################
*.swp
*~
# Logs and databases #
######################
*.log
*.sql
*.sqlite
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db

View file

@ -1,4 +0,0 @@
Host web
ForwardX11 yes
HostName megumi.eeleater.org
User eeleater

View file

@ -1,2 +0,0 @@
set -g default-terminal $ZSH_TMUX_TERM
source $HOME/.tmux.conf

View file

@ -1 +0,0 @@
set -g default-terminal $ZSH_TMUX_TERM

View file

@ -1,49 +0,0 @@
# For Dotfiles
dotfls="${HOME}/dotfiles"
dotlib="${dotfls}/lib"
dotcfg="${dotfls}/cfg"
brewpr="$(/home/linuxbrew/.linuxbrew/bin/brew --prefix)"
gembin="$(ruby -e "puts Gem.user_dir")/bin"
BASHER_SHELL=zsh
BASHER_ROOT=/home/eeleater/.basher
# Path
path=(${brewpr}/sbin ${brewpr}/bin) # Homebrew
path+=(/usr/local/sbin /usr/local/bin) # Local Bin
path+=(/usr/sbin /usr/bin) # /usr/bin
path+=(${dotfls}/bin) # Bin in Dotfiles
path+=(${dotlib}/basher/bin ${BASHER_ROOT}/cellar/bin) # Basher
path+=(${gembin}) # Ruby Gems
path+=(/usr/lib/jvm/default/bin) # Java
if pacman -Qm android-sdk-build-tools &>/dev/null; then
asdkver="$(pacman -Qm android-sdk-build-tools | awk '{print $2}' | cut -d'-' -f1 | cut -d'r' -f2)"
path+=(/opt/android-sdk/build-tools/${asdkver}); # Android SDK
fi
path+=(/opt/phalcon-devtools)
PTOOLSPATH="/opt/phalcon-devtools/"
# Manpath
manpath+=(${brewpr}/share/man)
# Infopath
infopath+=(${brewpr}/share/info)
# XDG Data Dirs
XDG_DATA_DIRS+=(${brewpr}/share)
# Editor Setting
EDITOR='nano'
# Completions Paths
fpath+=(${dotlib}/completions/src)
fpath+=(${brewpr}/share/zsh/site-functions)
fpath+=(${dotlib}/local)
fpath+=(${BASHER_ROOT}/cellar/completions/zsh)
# Actually export
export dotlib dotcfg brewpr gembin PATH MANPATH INFOPATH EDITOR XDG_DATA_DIRS PTOOLSPATH
# Reload all Prompts
autoload -U promptinit && promptinit

View file

@ -1,4 +0,0 @@
export ZSH="${dotlib}/ohmyzsh"
DISABLE_AUTO_UPDATE="true"
ZSH_DISABLE_COMPFIX="true"
source ${ZSH}/oh-my-zsh.sh

View file

@ -1,173 +0,0 @@
typeset -g ZERO=${(%):-%N}
_zsh_highlight()
{
local ret=$?
if [[ $WIDGET == zle-isearch-update ]] && ! (( $+ISEARCHMATCH_ACTIVE )); then
region_highlight=()
return $ret
fi
setopt localoptions warncreateglobal noksharrays
local REPLY
local -a reply
[[ -n ${ZSH_HIGHLIGHT_MAXLENGTH:-} ]] && [[ $#BUFFER -gt $ZSH_HIGHLIGHT_MAXLENGTH ]] && return $ret
[[ $PENDING -gt 0 ]] && return $ret
if [[ $WIDGET == zle-line-finish ]] || _zsh_highlight_buffer_modified; then
-fast-highlight-init
-fast-highlight-process && region_highlight=( $reply ) || region_highlight=()
fi
{
local cache_place
local -a region_highlight_copy
if (( REGION_ACTIVE == 1 )); then
_zsh_highlight_apply_zle_highlight region standout "$MARK" "$CURSOR"
elif (( REGION_ACTIVE == 2 )); then
() {
local needle=$'\n'
integer min max
if (( MARK > CURSOR )) ; then
min=$CURSOR max=$MARK
else
min=$MARK max=$CURSOR
fi
(( min = ${${BUFFER[1,$min]}[(I)$needle]} ))
(( max += ${${BUFFER:($max-1)}[(i)$needle]} - 1 ))
_zsh_highlight_apply_zle_highlight region standout "$min" "$max"
}
fi
(( $+YANK_ACTIVE )) && (( YANK_ACTIVE )) && _zsh_highlight_apply_zle_highlight paste standout "$YANK_START" "$YANK_END"
(( $+ISEARCHMATCH_ACTIVE )) && (( ISEARCHMATCH_ACTIVE )) && _zsh_highlight_apply_zle_highlight isearch underline "$ISEARCHMATCH_START" "$ISEARCHMATCH_END"
(( $+SUFFIX_ACTIVE )) && (( SUFFIX_ACTIVE )) && _zsh_highlight_apply_zle_highlight suffix bold "$SUFFIX_START" "$SUFFIX_END"
return $ret
} always {
typeset -g _ZSH_HIGHLIGHT_PRIOR_BUFFER="$BUFFER"
typeset -g _ZSH_HIGHLIGHT_PRIOR_RACTIVE="$REGION_ACTIVE"
typeset -gi _ZSH_HIGHLIGHT_PRIOR_CURSOR=$CURSOR
}
}
_zsh_highlight_apply_zle_highlight() {
local entry="$1" default="$2"
integer first="$3" second="$4"
local region="${zle_highlight[(r)${entry}:*]}"
if [[ -z "$region" ]]; then
region=$default
else
region="${region#${entry}:}"
if [[ -z "$region" ]] || [[ "$region" == none ]]; then
return
fi
fi
integer start end
if (( first < second )); then
start=$first end=$second
else
start=$second end=$first
fi
region_highlight+=("$start $end $region")
}
_zsh_highlight_buffer_modified()
{
[[ "${_ZSH_HIGHLIGHT_PRIOR_BUFFER:-}" != "$BUFFER" ]] || [[ "$REGION_ACTIVE" != "$_ZSH_HIGHLIGHT_PRIOR_RACTIVE" ]] || { _zsh_highlight_cursor_moved && [[ "$REGION_ACTIVE" = 1 || "$REGION_ACTIVE" = 2 ]] }
}
_zsh_highlight_cursor_moved()
{
[[ -n $CURSOR ]] && [[ -n ${_ZSH_HIGHLIGHT_PRIOR_CURSOR-} ]] && (($_ZSH_HIGHLIGHT_PRIOR_CURSOR != $CURSOR))
}
_zsh_highlight_call_widget()
{
builtin zle "$@" && _zsh_highlight
}
_zsh_highlight_bind_widgets()
{
setopt localoptions noksharrays
typeset -F SECONDS
local prefix=orig-s$SECONDS-r$RANDOM
zmodload zsh/zleparameter 2>/dev/null || {
print -r -- >&2 'zsh-syntax-highlighting: failed loading zsh/zleparameter.'
return 1
}
local -U widgets_to_bind
widgets_to_bind=(${${(k)widgets}:#(.*|run-help|which-command|beep|set-local-history|yank)})
widgets_to_bind+=(zle-line-finish)
widgets_to_bind+=(zle-isearch-update)
local cur_widget
for cur_widget in $widgets_to_bind; do
case $widgets[$cur_widget] in
user:_zsh_highlight_widget_*);;
user:*) zle -N $prefix-$cur_widget ${widgets[$cur_widget]#*:}
eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget ${(q)prefix}-${(q)cur_widget} -- \"\$@\" }"
zle -N $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;;
completion:*) zle -C $prefix-$cur_widget ${${(s.:.)widgets[$cur_widget]}[2,3]}
eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget ${(q)prefix}-${(q)cur_widget} -- \"\$@\" }"
zle -N $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;;
builtin) eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _zsh_highlight_call_widget .${(q)cur_widget} -- \"\$@\" }"
zle -N $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;;
*)
if [[ $cur_widget == zle-* ]] && [[ -z $widgets[$cur_widget] ]]; then
_zsh_highlight_widget_${cur_widget}() { :; _zsh_highlight }
zle -N $cur_widget _zsh_highlight_widget_$cur_widget
else
print -r -- >&2 "zsh-syntax-highlighting: unhandled ZLE widget ${(qq)cur_widget}"
fi
esac
done
}
_zsh_highlight_bind_widgets || {
print -r -- >&2 'zsh-syntax-highlighting: failed binding ZLE widgets, exiting.'
return 1
}
_zsh_highlight_preexec_hook()
{
typeset -g _ZSH_HIGHLIGHT_PRIOR_BUFFER=
typeset -gi _ZSH_HIGHLIGHT_PRIOR_CURSOR=0
}
autoload -U add-zsh-hook
add-zsh-hook preexec _zsh_highlight_preexec_hook 2>/dev/null || {
print -r -- >&2 'zsh-syntax-highlighting: failed loading add-zsh-hook.'
}
ZSH_HIGHLIGHT_MAXLENGTH=10000
zmodload zsh/parameter 2>/dev/null
autoload -U is-at-least
source "${dotlib}/highlight"
[[ "${+termcap[Co]}" = 1 && "${termcap[Co]}" = "256" ]] && FAST_HIGHLIGHT_STYLES[variable]="fg=112"
-fast-highlight-fill-option-variables

View file

@ -1,467 +0,0 @@
autoload -Uz add-zsh-hook
zmodload zsh/zpty
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8'
ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
ZSH_AUTOSUGGEST_STRATEGY=default
ZSH_AUTOSUGGEST_CLEAR_WIDGETS=(
history-search-forward
history-search-backward
history-beginning-search-forward
history-beginning-search-backward
history-substring-search-up
history-substring-search-down
up-line-or-history
down-line-or-history
accept-line
)
ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=(
forward-char
end-of-line
vi-forward-char
vi-end-of-line
vi-add-eol
)
ZSH_AUTOSUGGEST_EXECUTE_WIDGETS=(
)
ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=(
forward-word
vi-forward-word
vi-forward-word-end
vi-forward-blank-word
vi-forward-blank-word-end
)
ZSH_AUTOSUGGEST_IGNORE_WIDGETS=(
orig-\*
beep
run-help
set-local-history
which-command
yank
)
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=
ZSH_AUTOSUGGEST_ASYNC_PTY_NAME=zsh_autosuggest_pty
_zsh_autosuggest_escape_command() {
setopt localoptions EXTENDED_GLOB
echo -E "${1//(#m)[\"\'\\()\[\]|*?~]/\\$MATCH}"
}
_zsh_autosuggest_feature_detect_zpty_returns_fd() {
typeset -g _ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD
typeset -h REPLY
zpty zsh_autosuggest_feature_detect '{ zshexit() { kill -KILL $$; sleep 1 } }'
if (( REPLY )); then
_ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD=1
else
_ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD=0
fi
zpty -d zsh_autosuggest_feature_detect
}
_zsh_autosuggest_incr_bind_count() {
if ((${+_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]})); then
((_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]++))
else
_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]=1
fi
bind_count=$_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]
}
_zsh_autosuggest_get_bind_count() {
if ((${+_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]})); then
bind_count=$_ZSH_AUTOSUGGEST_BIND_COUNTS[$1]
else
bind_count=0
fi
}
_zsh_autosuggest_bind_widget() {
typeset -gA _ZSH_AUTOSUGGEST_BIND_COUNTS
local widget=$1
local autosuggest_action=$2
local prefix=$ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX
local -i bind_count
case $widgets[$widget] in
# Already bound
user:_zsh_autosuggest_(bound|orig)_*);;
user:*)
_zsh_autosuggest_incr_bind_count $widget
zle -N $prefix${bind_count}-$widget ${widgets[$widget]#*:}
;;
builtin)
_zsh_autosuggest_incr_bind_count $widget
eval "_zsh_autosuggest_orig_${(q)widget}() { zle .${(q)widget} }"
zle -N $prefix${bind_count}-$widget _zsh_autosuggest_orig_$widget
;;
completion:*)
_zsh_autosuggest_incr_bind_count $widget
eval "zle -C $prefix${bind_count}-${(q)widget} ${${(s.:.)widgets[$widget]}[2,3]}"
;;
esac
_zsh_autosuggest_get_bind_count $widget
eval "_zsh_autosuggest_bound_${bind_count}_${(q)widget}() {
_zsh_autosuggest_widget_$autosuggest_action $prefix$bind_count-${(q)widget} \$@
}"
zle -N $widget _zsh_autosuggest_bound_${bind_count}_$widget
}
_zsh_autosuggest_bind_widgets() {
local widget
local ignore_widgets
ignore_widgets=(
.\*
_\*
zle-\*
autosuggest-\*
$ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX\*
$ZSH_AUTOSUGGEST_IGNORE_WIDGETS
)
for widget in ${${(f)"$(builtin zle -la)"}:#${(j:|:)~ignore_widgets}}; do
if [ ${ZSH_AUTOSUGGEST_CLEAR_WIDGETS[(r)$widget]} ]; then
_zsh_autosuggest_bind_widget $widget clear
elif [ ${ZSH_AUTOSUGGEST_ACCEPT_WIDGETS[(r)$widget]} ]; then
_zsh_autosuggest_bind_widget $widget accept
elif [ ${ZSH_AUTOSUGGEST_EXECUTE_WIDGETS[(r)$widget]} ]; then
_zsh_autosuggest_bind_widget $widget execute
elif [ ${ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS[(r)$widget]} ]; then
_zsh_autosuggest_bind_widget $widget partial_accept
else
_zsh_autosuggest_bind_widget $widget modify
fi
done
}
_zsh_autosuggest_invoke_original_widget() {
[ $# -gt 0 ] || return
local original_widget_name="$1"
shift
if [ $widgets[$original_widget_name] ]; then
zle $original_widget_name -- $@
fi
}
_zsh_autosuggest_highlight_reset() {
typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT
if [ -n "$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT" ]; then
region_highlight=("${(@)region_highlight:#$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT}")
unset _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT
fi
}
_zsh_autosuggest_highlight_apply() {
typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT
if [ $#POSTDISPLAY -gt 0 ]; then
_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT="$#BUFFER $(($#BUFFER + $#POSTDISPLAY)) $ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE"
region_highlight+=("$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT")
else
unset _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT
fi
}
_zsh_autosuggest_disable() {
typeset -g _ZSH_AUTOSUGGEST_DISABLED
_zsh_autosuggest_clear
}
_zsh_autosuggest_enable() {
unset _ZSH_AUTOSUGGEST_DISABLED
if [ $#BUFFER -gt 0 ]; then
_zsh_autosuggest_fetch
fi
}
_zsh_autosuggest_toggle() {
if [ -n "${_ZSH_AUTOSUGGEST_DISABLED+x}" ]; then
_zsh_autosuggest_enable
else
_zsh_autosuggest_disable
fi
}
_zsh_autosuggest_clear() {
unset POSTDISPLAY
_zsh_autosuggest_invoke_original_widget $@
}
_zsh_autosuggest_modify() {
local -i retval
local -i KEYS_QUEUED_COUNT
local orig_buffer="$BUFFER"
local orig_postdisplay="$POSTDISPLAY"
unset POSTDISPLAY
_zsh_autosuggest_invoke_original_widget $@
retval=$?
if [[ $PENDING > 0 ]] || [[ $KEYS_QUEUED_COUNT > 0 ]]; then
return $retval
fi
if [ $#BUFFER -gt $#orig_buffer ]; then
local added=${BUFFER#$orig_buffer}
if [ "$added" = "${orig_postdisplay:0:$#added}" ]; then
POSTDISPLAY="${orig_postdisplay:$#added}"
return $retval
fi
fi
if [ "$BUFFER" = "$orig_buffer" ]; then
POSTDISPLAY="$orig_postdisplay"
return $retval
fi
if [ -n "${_ZSH_AUTOSUGGEST_DISABLED+x}" ]; then
return $?
fi
if [ $#BUFFER -gt 0 ]; then
if [ -z "$ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE" -o $#BUFFER -le "$ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE" ]; then
_zsh_autosuggest_fetch
fi
fi
return $retval
}
_zsh_autosuggest_fetch() {
if zpty -t "$ZSH_AUTOSUGGEST_ASYNC_PTY_NAME" &>/dev/null; then
_zsh_autosuggest_async_request "$BUFFER"
else
local suggestion
_zsh_autosuggest_strategy_$ZSH_AUTOSUGGEST_STRATEGY "$BUFFER"
_zsh_autosuggest_suggest "$suggestion"
fi
}
_zsh_autosuggest_suggest() {
local suggestion="$1"
if [ -n "$suggestion" ] && [ $#BUFFER -gt 0 ]; then
POSTDISPLAY="${suggestion#$BUFFER}"
else
unset POSTDISPLAY
fi
}
_zsh_autosuggest_accept() {
local -i max_cursor_pos=$#BUFFER
if [ "$KEYMAP" = "vicmd" ]; then
max_cursor_pos=$((max_cursor_pos - 1))
fi
if [ $CURSOR -eq $max_cursor_pos ]; then
BUFFER="$BUFFER$POSTDISPLAY"
unset POSTDISPLAY
CURSOR=${#BUFFER}
fi
_zsh_autosuggest_invoke_original_widget $@
}
_zsh_autosuggest_execute() {
BUFFER="$BUFFER$POSTDISPLAY"
unset POSTDISPLAY
_zsh_autosuggest_invoke_original_widget "accept-line"
}
_zsh_autosuggest_partial_accept() {
local -i retval
local original_buffer="$BUFFER"
BUFFER="$BUFFER$POSTDISPLAY"
_zsh_autosuggest_invoke_original_widget $@
retval=$?
if [ $CURSOR -gt $#original_buffer ]; then
POSTDISPLAY="$RBUFFER"
BUFFER="$LBUFFER"
else
BUFFER="$original_buffer"
fi
return $retval
}
for action in clear modify fetch suggest accept partial_accept execute enable disable toggle; do
eval "_zsh_autosuggest_widget_$action() {
local -i retval
_zsh_autosuggest_highlight_reset
_zsh_autosuggest_$action \$@
retval=\$?
_zsh_autosuggest_highlight_apply
zle -R
return \$retval
}"
done
zle -N autosuggest-fetch _zsh_autosuggest_widget_fetch
zle -N autosuggest-suggest _zsh_autosuggest_widget_suggest
zle -N autosuggest-accept _zsh_autosuggest_widget_accept
zle -N autosuggest-clear _zsh_autosuggest_widget_clear
zle -N autosuggest-execute _zsh_autosuggest_widget_execute
zle -N autosuggest-enable _zsh_autosuggest_widget_enable
zle -N autosuggest-disable _zsh_autosuggest_widget_disable
zle -N autosuggest-toggle _zsh_autosuggest_widget_toggle
_zsh_autosuggest_strategy_default() {
emulate -L zsh
setopt EXTENDED_GLOB
local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}"
suggestion="${history[(r)$prefix*]}"
}
_zsh_autosuggest_strategy_match_prev_cmd() {
local prefix="${1//(#m)[\\()\[\]|*?~]/\\$MATCH}"
local history_match_keys
history_match_keys=(${(k)history[(R)$prefix*]})
local histkey="${history_match_keys[1]}"
local prev_cmd="$(_zsh_autosuggest_escape_command "${history[$((HISTCMD-1))]}")"
for key in "${(@)history_match_keys[1,200]}"; do
[[ $key -gt 1 ]] || break
if [[ "${history[$((key - 1))]}" == "$prev_cmd" ]]; then
histkey="$key"
break
fi
done
suggestion="$history[$histkey]"
}
_zsh_autosuggest_async_server() {
emulate -R zsh
zshexit() {
kill -KILL $$
sleep 1
}
stty -onlcr
exec 2>/dev/null
local strategy=$1
local last_pid
while IFS='' read -r -d $'\0' query; do
kill -KILL $last_pid &>/dev/null
(
local suggestion
_zsh_autosuggest_strategy_$ZSH_AUTOSUGGEST_STRATEGY "$query"
echo -n -E "$suggestion"$'\0'
) &
last_pid=$!
done
}
_zsh_autosuggest_async_request() {
zpty -w -n $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME "${1}"$'\0'
}
_zsh_autosuggest_async_response() {
setopt LOCAL_OPTIONS EXTENDED_GLOB
local suggestion
zpty -rt $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME suggestion '*'$'\0' 2>/dev/null
zle autosuggest-suggest -- "${suggestion%%$'\0'##}"
}
_zsh_autosuggest_async_pty_create() {
typeset -h REPLY
if [ $_ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD -eq 0 ]; then
integer -l zptyfd
exec {zptyfd}>&1
exec {zptyfd}>&-
fi
zpty -b $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME "_zsh_autosuggest_async_server _zsh_autosuggest_strategy_$ZSH_AUTOSUGGEST_STRATEGY"
if (( REPLY )); then
_ZSH_AUTOSUGGEST_PTY_FD=$REPLY
else
_ZSH_AUTOSUGGEST_PTY_FD=$zptyfd
fi
zle -F $_ZSH_AUTOSUGGEST_PTY_FD _zsh_autosuggest_async_response
}
_zsh_autosuggest_async_pty_destroy() {
if zpty -t $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME &>/dev/null; then
zle -F $_ZSH_AUTOSUGGEST_PTY_FD &>/dev/null
zpty -d $ZSH_AUTOSUGGEST_ASYNC_PTY_NAME &>/dev/null
fi
}
_zsh_autosuggest_async_pty_recreate() {
_zsh_autosuggest_async_pty_destroy
_zsh_autosuggest_async_pty_create
}
_zsh_autosuggest_async_start() {
typeset -g _ZSH_AUTOSUGGEST_PTY_FD
_zsh_autosuggest_feature_detect_zpty_returns_fd
_zsh_autosuggest_async_pty_recreate
add-zsh-hook precmd _zsh_autosuggest_async_pty_recreate
}
_zsh_autosuggest_start() {
add-zsh-hook -d precmd _zsh_autosuggest_start
_zsh_autosuggest_bind_widgets
add-zsh-hook precmd _zsh_autosuggest_bind_widgets
if [ -n "${ZSH_AUTOSUGGEST_USE_ASYNC+x}" ]; then
_zsh_autosuggest_async_start
fi
}
add-zsh-hook precmd _zsh_autosuggest_start

View file

@ -1,4 +0,0 @@
alias brews='brew list -1'
alias bubo='brew update && brew outdated'
alias bubc='brew upgrade && brew cleanup'
alias bubu='bubo && bubc'

View file

@ -1,219 +0,0 @@
if (( $+commands[trizen] )); then
alias trconf='trizen -C'
alias trupg='trizen -Syua'
alias trsu='trizen -Syua --noconfirm'
alias trin='trizen -S'
alias trins='trizen -U'
alias trre='trizen -R'
alias trrem='trizen -Rns'
alias trrep='trizen -Si'
alias trreps='trizen -Ss'
alias trloc='trizen -Qi'
alias trlocs='trizen -Qs'
alias trlst='trizen -Qe'
alias trorph='trizen -Qtd'
alias trinsd='trizen -S --asdeps'
alias trmir='trizen -Syy'
if (( $+commands[abs] && $+commands[aur] )); then
alias trupd='trizen -Sy && sudo abs && sudo aur'
elif (( $+commands[abs] )); then
alias trupd='trizen -Sy && sudo abs'
elif (( $+commands[aur] )); then
alias trupd='trizen -Sy && sudo aur'
else
alias trupd='trizen -Sy'
fi
fi
if (( $+commands[yaourt] )); then
alias yaconf='yaourt -C'
alias yaupg='yaourt -Syua'
alias yasu='yaourt -Syua --noconfirm'
alias yain='yaourt -S'
alias yains='yaourt -U'
alias yare='yaourt -R'
alias yarem='yaourt -Rns'
alias yarep='yaourt -Si'
alias yareps='yaourt -Ss'
alias yaloc='yaourt -Qi'
alias yalocs='yaourt -Qs'
alias yalst='yaourt -Qe'
alias yaorph='yaourt -Qtd'
alias yainsd='yaourt -S --asdeps'
alias yamir='yaourt -Syy'
if (( $+commands[abs] && $+commands[aur] )); then
alias yaupd='yaourt -Sy && sudo abs && sudo aur'
elif (( $+commands[abs] )); then
alias yaupd='yaourt -Sy && sudo abs'
elif (( $+commands[aur] )); then
alias yaupd='yaourt -Sy && sudo aur'
else
alias yaupd='yaourt -Sy'
fi
fi
if (( $+commands[yay] )); then
alias yaconf='yay -Pg'
alias yaupg='yay -Syu'
alias yasu='yay -Syu --noconfirm'
alias yain='yay -S'
alias yains='yay -U'
alias yare='yay -R'
alias yarem='yay -Rns'
alias yarep='yay -Si'
alias yareps='yay -Ss'
alias yaloc='yay -Qi'
alias yalocs='yay -Qs'
alias yalst='yay -Qe'
alias yaorph='yay -Qtd'
alias yainsd='yay -S --asdeps'
alias yamir='yay -Syy'
if (( $+commands[abs] && $+commands[aur] )); then
alias yaupd='yay -Sy && sudo abs && sudo aur'
elif (( $+commands[abs] )); then
alias yaupd='yay -Sy && sudo abs'
elif (( $+commands[aur] )); then
alias yaupd='yay -Sy && sudo aur'
else
alias yaupd='yay -Sy'
fi
fi
if (( $+commands[pacaur] )); then
alias paupg='pacaur -Syu'
alias pasu='pacaur -Syu --noconfirm'
alias pain='pacaur -S'
alias pains='pacaur -U'
alias pare='pacaur -R'
alias parem='pacaur -Rns'
alias parep='pacaur -Si'
alias pareps='pacaur -Ss'
alias paloc='pacaur -Qi'
alias palocs='pacaur -Qs'
alias palst='pacaur -Qe'
alias paorph='pacaur -Qtd'
alias painsd='pacaur -S --asdeps'
alias pamir='pacaur -Syy'
if (( $+commands[abs] && $+commands[aur] )); then
alias paupd='pacaur -Sy && sudo abs && sudo aur'
elif (( $+commands[abs] )); then
alias paupd='pacaur -Sy && sudo abs'
elif (( $+commands[aur] )); then
alias paupd='pacaur -Sy && sudo aur'
else
alias paupd='pacaur -Sy'
fi
fi
if (( $+commands[trizen] )); then
function upgrade() {
trizen -Syu
}
elif (( $+commands[pacaur] )); then
function upgrade() {
pacaur -Syu
}
elif (( $+commands[yaourt] )); then
function upgrade() {
yaourt -Syu
}
elif (( $+commands[yay] )); then
function upgrade() {
yay -Syu
}
else
function upgrade() {
sudo pacman -Syu
}
fi
# Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
alias pacupg='sudo pacman -Syu'
alias pacin='sudo pacman -S'
alias pacins='sudo pacman -U'
alias pacre='sudo pacman -R'
alias pacrem='sudo pacman -Rns'
alias pacrep='pacman -Si'
alias pacreps='pacman -Ss'
alias pacloc='pacman -Qi'
alias paclocs='pacman -Qs'
alias pacinsd='sudo pacman -S --asdeps'
alias pacmir='sudo pacman -Syy'
alias paclsorphans='sudo pacman -Qdt'
alias pacrmorphans='sudo pacman -Rs $(pacman -Qtdq)'
alias pacfileupg='sudo pacman -Fy'
alias pacfiles='pacman -Fs'
alias pacls='pacman -Ql'
alias pacown='pacman -Qo'
if (( $+commands[abs] && $+commands[aur] )); then
alias pacupd='sudo pacman -Sy && sudo abs && sudo aur'
elif (( $+commands[abs] )); then
alias pacupd='sudo pacman -Sy && sudo abs'
elif (( $+commands[aur] )); then
alias pacupd='sudo pacman -Sy && sudo aur'
else
alias pacupd='sudo pacman -Sy'
fi
function paclist() {
# Source: https://bbs.archlinux.org/viewtopic.php?id=93683
LC_ALL=C pacman -Qei $(pacman -Qu | cut -d " " -f 1) | \
awk 'BEGIN {FS=":"} /^Name/{printf("\033[1;36m%s\033[1;37m", $2)} /^Description/{print $2}'
}
function pacdisowned() {
emulate -L zsh
tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$
db=$tmp/db
fs=$tmp/fs
mkdir "$tmp"
trap 'rm -rf "$tmp"' EXIT
pacman -Qlq | sort -u > "$db"
find /bin /etc /lib /sbin /usr ! -name lost+found \
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
comm -23 "$fs" "$db"
}
function pacmanallkeys() {
emulate -L zsh
curl -s https://www.archlinux.org/people/{developers,trustedusers}/ | \
awk -F\" '(/pgp.mit.edu/) { sub(/.*search=0x/,""); print $1}' | \
xargs sudo pacman-key --recv-keys
}
function pacmansignkeys() {
emulate -L zsh
for key in $*; do
sudo pacman-key --recv-keys $key
sudo pacman-key --lsign-key $key
printf 'trust\n3\n' | sudo gpg --homedir /etc/pacman.d/gnupg \
--no-permission-warning --command-fd 0 --edit-key $key
done
}
if (( $+commands[xdg-open] )); then
function pacweb() {
pkg="$1"
infos="$(pacman -Si "$pkg")"
if [[ -z "$infos" ]]; then
return
fi
repo="$(grep '^Repo' <<< "$infos" | grep -oP '[^ ]+$')"
arch="$(grep '^Arch' <<< "$infos" | grep -oP '[^ ]+$')"
xdg-open "https://www.archlinux.org/packages/$repo/$arch/$pkg/" &>/dev/null
}
fi

View file

@ -1,8 +0,0 @@
cmds=(status show start stop reload restart enable disable daemon-reload)
for cmd in $cmds; do
alias sc-$cmd="sudo systemctl $cmd"
done
alias sc-enablenow="sc-enable --now"
alias sc-disablenow="sc-disable --now"

View file

@ -1 +0,0 @@
[[ -e /usr/share/doc/pkgfile/command-not-found.zsh ]] && source /usr/share/doc/pkgfile/command-not-found.zsh

View file

@ -1 +0,0 @@
eval `dircolors ${dotcfg}/dir/cfg`

View file

@ -1,72 +0,0 @@
alias x=extract
extract() {
local remove_archive
local success
local extract_dir
if (( $# == 0 )); then
cat <<-'EOF' >&2
Usage: extract [-option] [file ...]
Options:
-r, --remove Remove archive.
EOF
fi
remove_archive=1
if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then
remove_archive=0
shift
fi
while (( $# > 0 )); do
if [[ ! -f "$1" ]]; then
echo "extract: '$1' is not a valid file" >&2
shift
continue
fi
success=0
extract_dir="${1:t:r}"
case "$1" in
(*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;;
(*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;;
(*.tar.xz|*.txz)
tar --xz --help &> /dev/null \
&& tar --xz -xvf "$1" \
|| xzcat "$1" | tar xvf - ;;
(*.tar.zma|*.tlz)
tar --lzma --help &> /dev/null \
&& tar --lzma -xvf "$1" \
|| lzcat "$1" | tar xvf - ;;
(*.tar) tar xvf "$1" ;;
(*.gz) (( $+commands[pigz] )) && pigz -d "$1" || gunzip "$1" ;;
(*.bz2) bunzip2 "$1" ;;
(*.xz) unxz "$1" ;;
(*.lzma) unlzma "$1" ;;
(*.Z) uncompress "$1" ;;
(*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk) unzip "$1" -d $extract_dir ;;
(*.rar) unrar x -ad "$1" ;;
(*.7z) 7za x "$1" ;;
(*.deb)
mkdir -p "$extract_dir/control"
mkdir -p "$extract_dir/data"
cd "$extract_dir"; ar vx "../${1}" > /dev/null
cd control; tar xzvf ../control.tar.gz
cd ../data; extract ../data.tar.*
cd ..; rm *.tar.* debian-binary
cd ..
;;
(*)
echo "extract: '$1' cannot be extracted" >&2
success=1
;;
esac
(( success = $success > 0 ? $success : $? ))
(( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1"
shift
done
}

View file

@ -1,4 +0,0 @@
[[ $- == *i* && -f "/usr/share/fzf/completion.zsh" ]] && source "/usr/share/fzf/completion.zsh" 2> /dev/null
[[ -f "/usr/share/fzf/key-bindings.zsh" ]] && source "/usr/share/fzf/key-bindings.zsh"
[[ $- == *i* && -f "/home/linuxbrew/.linuxbrew/opt/fzf/shell/completion.zsh" ]] && source "/home/linuxbrew/.linuxbrew/opt/fzf/shell/completion.zsh" 2> /dev/null
[[ -f "/home/linuxbrew/.linuxbrew/opt/fzf/shell/key-bindings.zsh" ]] && source "/home/linuxbrew/.linuxbrew/opt/fzf/shell/key-bindings.zsh"

View file

@ -1,53 +0,0 @@
ZSH_PLUGIN_GITIGNORE_PATH=$(dirname $0)
ZSH_PLUGIN_GITIGNORE_TEMPLATE_PATHS=${dotlib}/gitignore
function gie () { ${EDITOR} .gitignore }
function gi() {
if [[ $# -eq 0 ]]; then
cat .gitignore
return 0
fi
for t in $*; do
get_gitignore_template $t
done
}
function gii() {
if [[ $# -eq 0 ]]; then
cat .gitignore
return 0
fi
gi $* >>! .gitignore
}
function get_gitignore_template() {
for tpath in ${(@s/:/)ZSH_PLUGIN_GITIGNORE_TEMPLATE_PATHS}; do;
local file=$(find $tpath -iname "$1.gitignore")
if [[ ! -z $file ]]; then
comment=$(basename $file | sed -e 's/.gitignore$//')
echo
echo "### $comment"
cat $file
break;
fi
done;
}
_gitignore_get_template_list() {
(for tpath in ${(@s/:/)ZSH_PLUGIN_GITIGNORE_TEMPLATE_PATHS}; do; find $tpath -type f -name "*.gitignore"; done) \
| xargs -n 1 basename \
| sed -e 's/.gitignore$//' -e 's/\(.*\)/\L\1/' \
| sort -u
}
_gitignore () {
compset -P '*,'
compadd -S '' `_gitignore_get_template_list`
}
compdef _gitignore gi
compdef _gitignore gii

View file

@ -1,63 +0,0 @@
alias ta='tmux attach -t'
alias tad='tmux attach -d -t'
alias ts='tmux new-session -s'
alias tl='tmux list-sessions'
alias tksv='tmux kill-server'
alias tkss='tmux kill-session -t'
if which tmux &> /dev/null
then
[[ -n "$ZSH_TMUX_AUTOSTART" ]] || ZSH_TMUX_AUTOSTART=false
[[ -n "$ZSH_TMUX_AUTOSTART_ONCE" ]] || ZSH_TMUX_AUTOSTART_ONCE=true
[[ -n "$ZSH_TMUX_AUTOCONNECT" ]] || ZSH_TMUX_AUTOCONNECT=true
[[ -n "$ZSH_TMUX_AUTOQUIT" ]] || ZSH_TMUX_AUTOQUIT=$ZSH_TMUX_AUTOSTART
[[ -n "$ZSH_TMUX_FIXTERM" ]] || ZSH_TMUX_FIXTERM=true
[[ -n "$ZSH_TMUX_ITERM2" ]] || ZSH_TMUX_ITERM2=false
[[ -n "$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR" ]] || ZSH_TMUX_FIXTERM_WITHOUT_256COLOR="screen"
[[ -n "$ZSH_TMUX_FIXTERM_WITH_256COLOR" ]] || ZSH_TMUX_FIXTERM_WITH_256COLOR="screen-256color"
local zsh_tmux_plugin_path=${dotcfg}/tmux
if [[ `tput colors` == "256" ]]
then
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITH_256COLOR
else
export ZSH_TMUX_TERM=$ZSH_TMUX_FIXTERM_WITHOUT_256COLOR
fi
if [[ "$ZSH_TMUX_ITERM2" == "false" ]] && [[ -f $HOME/.tmux.conf || -h $HOME/.tmux.conf ]]
then
_ZSH_TMUX_FIXED_CONFIG="$zsh_tmux_plugin_path/tmux.extra.conf"
else
_ZSH_TMUX_FIXED_CONFIG="$zsh_tmux_plugin_path/tmux.only.conf"
fi
function _zsh_tmux_plugin_run()
{
if [[ -n "$@" ]]
then
\tmux $@
elif [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]]
then
\tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` attach || \tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` `[[ "$ZSH_TMUX_FIXTERM" == "true" ]] && echo '-f '$_ZSH_TMUX_FIXED_CONFIG` new-session
[[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && exit
else
\tmux `[[ "$ZSH_TMUX_ITERM2" == "true" ]] && echo '-CC '` `[[ "$ZSH_TMUX_FIXTERM" == "true" ]] && echo '-f '$_ZSH_TMUX_FIXED_CONFIG`
[[ "$ZSH_TMUX_AUTOQUIT" == "true" ]] && exit
fi
}
compdef _tmux _zsh_tmux_plugin_run
alias tmux=_zsh_tmux_plugin_run
if [[ ! -n "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" ]]
then
if [[ "$ZSH_TMUX_AUTOSTART_ONCE" == "false" || "$ZSH_TMUX_AUTOSTARTED" != "true" ]]
then
export ZSH_TMUX_AUTOSTARTED=true
_zsh_tmux_plugin_run
fi
fi
else
print "zsh tmux plugin: tmux not found. Please install tmux before using this plugin."
fi

View file

@ -1,3 +0,0 @@
# Fix MobaXterm Home/End key with ZSH
bindkey '^[[H' beginning-of-line
bindkey '^[[F' end-of-line

View file

@ -1,10 +0,0 @@
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias la='ls -lAh'
for file in ${dotcfg}/zsh/cfg.d/source.d/*.zsh; do
source $file
done
source /usr/share/lmod/lmod/init/zsh

View file

@ -1,7 +0,0 @@
# Source all files
for file in ${HOME}/dotfiles/cfg/zsh/cfg.d/*.zsh; do
source $file
done
# Prompt
prompt z4rr3t

View file

@ -1,6 +0,0 @@
#!/bin/bash
cd ${HOME}/dotfiles
echo "Installing Dotfiles - Please Wait!"
git submodule update --init --recursive
lib/dotbot/bin/dotbot -d . -c cfg/dotbot/cfg ${@}

@ -1 +0,0 @@
Subproject commit dcf5c0dd9e033712fdac3da2bfdfeb430f13d16a

@ -1 +0,0 @@
Subproject commit b512d57b6d0d2b85368a8068ec1a13288a93d267

@ -1 +0,0 @@
Subproject commit d20984f5acbb439347399ced4bd242e4ab9ccb07

@ -1 +0,0 @@
Subproject commit 499ae899e7b54e701e878759f73d9092302fd07a

@ -1 +0,0 @@
Subproject commit bdf7c2ffe6f6dd3a2dcfb9ef7d4794b5ffc4402b

View file

@ -1,715 +0,0 @@
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2010-2016 zsh-syntax-highlighting contributors
# Copyright (c) 2016-2017 Sebastian Gniazdowski (modifications)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
typeset -gA __fast_highlight_main__command_type_cache
# Define default styles. You can set this after loading the plugin in
# Zshrc and use 256 via numbers, like: fg=150
typeset -gA FAST_HIGHLIGHT_STYLES
: ${FAST_HIGHLIGHT_STYLES[default]:=none}
: ${FAST_HIGHLIGHT_STYLES[unknown-token]:=fg=red,bold}
: ${FAST_HIGHLIGHT_STYLES[reserved-word]:=fg=yellow}
: ${FAST_HIGHLIGHT_STYLES[alias]:=fg=green}
: ${FAST_HIGHLIGHT_STYLES[suffix-alias]:=fg=green}
: ${FAST_HIGHLIGHT_STYLES[builtin]:=fg=green}
: ${FAST_HIGHLIGHT_STYLES[function]:=fg=green}
: ${FAST_HIGHLIGHT_STYLES[command]:=fg=green}
: ${FAST_HIGHLIGHT_STYLES[precommand]:=fg=green}
: ${FAST_HIGHLIGHT_STYLES[commandseparator]:=none}
: ${FAST_HIGHLIGHT_STYLES[hashed-command]:=fg=green}
: ${FAST_HIGHLIGHT_STYLES[path]:=fg=magenta}
: ${FAST_HIGHLIGHT_STYLES[path_pathseparator]:=}
: ${FAST_HIGHLIGHT_STYLES[globbing]:=fg=blue,bold}
: ${FAST_HIGHLIGHT_STYLES[history-expansion]:=fg=blue,bold}
: ${FAST_HIGHLIGHT_STYLES[single-hyphen-option]:=fg=cyan}
: ${FAST_HIGHLIGHT_STYLES[double-hyphen-option]:=fg=cyan}
: ${FAST_HIGHLIGHT_STYLES[back-quoted-argument]:=none}
: ${FAST_HIGHLIGHT_STYLES[single-quoted-argument]:=fg=yellow}
: ${FAST_HIGHLIGHT_STYLES[double-quoted-argument]:=fg=yellow}
: ${FAST_HIGHLIGHT_STYLES[dollar-quoted-argument]:=fg=yellow}
: ${FAST_HIGHLIGHT_STYLES[back-or-dollar-double-quoted-argument]:=fg=cyan}
: ${FAST_HIGHLIGHT_STYLES[back-dollar-quoted-argument]:=fg=cyan}
: ${FAST_HIGHLIGHT_STYLES[assign]:=none}
: ${FAST_HIGHLIGHT_STYLES[redirection]:=none}
: ${FAST_HIGHLIGHT_STYLES[comment]:=fg=black,bold}
: ${FAST_HIGHLIGHT_STYLES[variable]:=none}
typeset -gA __FAST_HIGHLIGHT_TOKEN_TYPES
__FAST_HIGHLIGHT_TOKEN_TYPES=(
# Precommand
'builtin' 1
'command' 1
'exec' 1
'nocorrect' 1
'noglob' 1
'pkexec' 1 # immune to #121 because it's usually not passed --option flags
# Control flow
# Tokens that, at (naively-determined) "command position", are followed by
# a de jure command position. All of these are reserved words.
$'\x7b' 2 # block
$'\x28' 2 # subshell
'()' 2 # anonymous function
'while' 2
'until' 2
'if' 2
'then' 2
'elif' 2
'else' 2
'do' 2
'time' 2
'coproc' 2
'!' 2 # reserved word; unrelated to $histchars[1]
# Command separators
'|' 3
'||' 3
';' 3
'&' 3
'&&' 3
'|&' 3
'&!' 3
'&|' 3
# ### 'case' syntax, but followed by a pattern, not by a command
# ';;' ';&' ';|'
)
# A hash instead of multiple globals
typeset -gA FAST_HIGHLIGHT
# Get the type of a command.
#
# Uses the zsh/parameter module if available to avoid forks, and a
# wrapper around 'type -w' as fallback.
#
# Takes a single argument.
#
# The result will be stored in REPLY.
-fast-highlight-main-type() {
REPLY=$__fast_highlight_main__command_type_cache[(e)$1]
[[ -z "$REPLY" ]] && {
if zmodload -e zsh/parameter; then
if (( $+aliases[(e)$1] )); then
REPLY=alias
elif (( $+functions[(e)$1] )); then
REPLY=function
elif (( $+builtins[(e)$1] )); then
REPLY=builtin
elif (( $+commands[(e)$1] )); then
REPLY=command
elif (( $+saliases[(e)${1##*.}] )); then
REPLY='suffix alias'
elif (( $reswords[(Ie)$1] )); then
REPLY=reserved
# zsh 5.2 and older have a bug whereby running 'type -w ./sudo' implicitly
# runs 'hash ./sudo=/usr/local/bin/./sudo' (assuming /usr/local/bin/sudo
# exists and is in $PATH). Avoid triggering the bug, at the expense of
# falling through to the $() below, incurring a fork. (Issue #354.)
#
# The second disjunct mimics the isrelative() C call from the zsh bug.
elif [[ $1 != */* || "${+ZSH_ARGZERO}" = "1" ]] && ! builtin type -w -- $1 >/dev/null 2>&1; then
REPLY=none
fi
fi
[[ -z "$REPLY" ]] && REPLY="${$(LC_ALL=C builtin type -w -- $1 2>/dev/null)##*: }"
[[ "$REPLY" = "none" ]] && {
[[ -d "$1" ]] && REPLY="dirpath" || {
for cdpath_dir in $cdpath; do
[[ -d "$cdpath_dir/$1" ]] && { REPLY="dirpath"; break; }
done
}
}
__fast_highlight_main__command_type_cache[(e)$1]=$REPLY
}
}
# Below are variables that must be defined in outer
# scope so that they are reachable in *-process()
-fast-highlight-fill-option-variables() {
if [[ -o ignore_braces ]] || eval '[[ -o ignore_close_braces ]] 2>/dev/null'; then
FAST_HIGHLIGHT[right_brace_is_recognised_everywhere]=0
else
FAST_HIGHLIGHT[right_brace_is_recognised_everywhere]=1
fi
if [[ -o path_dirs ]]; then
FAST_HIGHLIGHT[path_dirs_was_set]=1
else
FAST_HIGHLIGHT[path_dirs_was_set]=0
fi
if [[ -o multi_func_def ]]; then
FAST_HIGHLIGHT[multi_func_def]=1
else
FAST_HIGHLIGHT[multi_func_def]=0
fi
if [[ -o interactive_comments ]]; then
FAST_HIGHLIGHT[ointeractive_comments]=1
else
FAST_HIGHLIGHT[ointeractive_comments]=0
fi
}
# Main syntax highlighting function.
-fast-highlight-process()
{
emulate -L zsh
setopt extendedglob bareglobqual nonomatch noksharrays
[[ $CONTEXT == "select" ]] && return 0
(( FAST_HIGHLIGHT[path_dirs_was_set] )) && setopt PATH_DIRS
(( FAST_HIGHLIGHT[ointeractive_comments] )) && local interactive_comments= # _set_ to empty
# Variable declarations and initializations
# in_array_assignment true between 'a=(' and the matching ')'
# braces_stack: "R" for round, "Q" for square, "Y" for curly
# mybuf, cdpath_dir are used in sub-functions
local start_pos=0 end_pos start end highlight_glob=1 arg style in_array_assignment=0 MATCH expanded_path braces_stack buf="$PREBUFFER$BUFFER" mybuf cdpath_dir cur_cmd alias_target
# arg_type can be 0, 1, 2 or 3, i.e. precommand, control flow, command separator
# idx and end_idx are used in sub-functions
# for this_word and next_word look below at commented integers and at state machine description
integer arg_type=0 MBEGIN MEND in_redirection len=${#buf} already_added offset idx end_idx this_word=1 next_word=0 insane_alias pos
local -a match mbegin mend
# integer BIT_start=1 BIT_regular=2 BIT_sudo_opt=4 BIT_sudo_arg=8 BIT_always=16
# State machine
#
# The states are:
# - :start: Command word
# - :sudo_opt: A leading-dash option to sudo (such as "-u" or "-i")
# - :sudo_arg: The argument to a sudo leading-dash option that takes one,
# when given as a separate word; i.e., "foo" in "-u foo" (two
# words) but not in "-ufoo" (one word).
# - :regular: "Not a command word", and command delimiters are permitted.
# Mainly used to detect premature termination of commands.
# - :always: The word 'always' in the «{ foo } always { bar }» syntax.
#
# When the kind of a word is not yet known, $this_word / $next_word may contain
# multiple states. For example, after "sudo -i", the next word may be either
# another --flag or a command name, hence the state would include both :start:
# and :sudo_opt:.
#
# The tokens are always added with both leading and trailing colons to serve as
# word delimiters (an improvised array); [[ $x == *:foo:* ]] and x=${x//:foo:/}
# will DTRT regardless of how many elements or repetitions $x has..
#
# Handling of redirections: upon seeing a redirection token, we must stall
# the current state --- that is, the value of $this_word --- for two iterations
# (one for the redirection operator, one for the word following it representing
# the redirection target). Therefore, we set $in_redirection to 2 upon seeing a
# redirection operator, decrement it each iteration, and stall the current state
# when it is non-zero. Thus, upon reaching the next word (the one that follows
# the redirection operator and target), $this_word will still contain values
# appropriate for the word immediately following the word that preceded the
# redirection operator.
#
# The "the previous word was a redirection operator" state is not communicated
# to the next iteration via $next_word/$this_word as usual, but via
# $in_redirection. The value of $next_word from the iteration that processed
# the operator is discarded.
#
# Processing buffer
local proc_buf="$buf" needle
for arg in ${interactive_comments-${(z)buf}} \
${interactive_comments+${(zZ+c+)buf}}; do
# Initialize $next_word to its default value?
(( in_redirection )) && (( --in_redirection ))
(( in_redirection == 0 )) && next_word=2 # else Stall $next_word.
# Initialize per-"simple command" [zshmisc(1)] variables:
#
# $already_added (see next paragraph)
# $style how to highlight $arg
# $in_array_assignment boolean flag for "between '(' and ')' of array assignment"
# $highlight_glob boolean flag for "'noglob' is in effect"
#
# $already_added is set to 1 to disable adding an entry to region_highlight
# for this iteration. Currently, that is done for "" and $'' strings,
# which add the entry early so escape sequences within the string override
# the string's color.
already_added=0
style=unknown-token
if (( this_word & 1 )); then
in_array_assignment=0
[[ $arg == 'noglob' ]] && highlight_glob=0
fi
# Compute the new $start_pos and $end_pos, skipping over whitespace in $buf.
if [[ $arg == ';' ]] ; then
# We're looking for either a semicolon or a newline, whichever comes
# first. Both of these are rendered as a ";" (SEPER) by the ${(z)..}
# flag.
#
# We can't use the (Z+n+) flag because that elides the end-of-command
# token altogether, so 'echo foo\necho bar' (two commands) becomes
# indistinguishable from 'echo foo echo bar' (one command with three
# words for arguments).
needle=$'[;\n]'
offset=$(( ${proc_buf[(i)$needle]} - 1 ))
(( start_pos += offset ))
(( end_pos = start_pos + $#arg ))
# Do not run default code for case when there is a new line
# It shouldn't be treated as ';', i.e. shouldn't be highlighted
# as unknown-token when appears after command-starting arg like "{"
if [[ "${proc_buf[offset+1]}" = $'\n' ]]; then
(( in_array_assignment )) && (( this_word = 2 )) || { (( this_word = 1 )); highlight_glob=1; }
in_redirection=0
proc_buf="${proc_buf[offset + $#arg + 1,len]}"
start_pos=$end_pos
continue
else
# One more short path for ';' command separator
(( in_array_assignment )) && (( this_word = 2 )) || { (( this_word = 1 )); highlight_glob=1; }
in_redirection=0
[[ "${FAST_HIGHLIGHT_STYLES[commandseparator]}" != "none" ]] && (( start=start_pos-${#PREBUFFER}, end=end_pos-${#PREBUFFER}, start >= 0 )) && reply+=("$start $end ${FAST_HIGHLIGHT_STYLES[commandseparator]}")
proc_buf="${proc_buf[offset + $#arg + 1,len]}"
start_pos=$end_pos
continue
fi
arg_type=3
else
offset=0
if [[ "$proc_buf" = (#b)(#s)(([[:space:]]|\\[[:space:]])##)* ]]; then
# The first, outer parenthesis
offset="${mend[1]}"
fi
((start_pos+=offset))
((end_pos=start_pos+${#arg}))
# No-hit will result in value 0
arg_type=${__FAST_HIGHLIGHT_TOKEN_TYPES[$arg]}
fi
proc_buf="${proc_buf[offset + $#arg + 1,len]}"
# Handle the INTERACTIVE_COMMENTS option.
#
# We use the (Z+c+) flag so the entire comment is presented as one token in $arg.
if [[ -n ${interactive_comments+'set'} && $arg[1] == $histchars[3] ]]; then
if (( this_word & 3 )); then
style=comment
else
style=unknown-token # prematurely terminated
fi
# ADD
(( start=start_pos-${#PREBUFFER}, end=end_pos-${#PREBUFFER}, start >= 0 )) && reply+=("$start $end ${FAST_HIGHLIGHT_STYLES[$style]}")
start_pos=$end_pos
continue
fi
# Analyse the current word.
if [[ $arg == (<0-9>|)(\<|\>)* ]] && [[ $arg != (\<|\>)$'\x28'* ]]; then
# A '<' or '>', possibly followed by a digit
in_redirection=2
fi
# Special-case the first word after 'sudo'.
if (( ! in_redirection )); then
if (( this_word & 4 )) && [[ $arg != -* ]]; then
(( this_word = this_word ^ 4 ))
fi
# Parse the sudo command line
if (( this_word & 4 )); then
case "$arg" in
# Flag that requires an argument
'-'[Cgprtu])
(( this_word & 1 )) && (( this_word = this_word ^ 1 ))
(( next_word = 8 ))
;;
# This prevents misbehavior with sudo -u -otherargument
'-'*)
(( this_word & 1 )) && (( this_word = this_word ^ 1 ))
(( next_word = next_word | 1 ))
(( next_word = next_word | 4 ))
;;
*) ;;
esac
elif (( this_word & 8 )); then
(( next_word = next_word | 4 ))
(( next_word = next_word | 1 ))
fi
fi
expanded_path=""
# The Great Fork: is this a command word? Is this a non-command word?
if (( this_word & 16 )) && [[ $arg == 'always' ]]; then
# try-always construct
style=reserved-word # de facto a reserved word, although not de jure
(( next_word = 1 ))
elif (( this_word & 1 )) && (( in_redirection == 0 )); then # $arg is the command word
cur_cmd="$arg"
if (( arg_type == 1 )); then
style=precommand
elif [[ "$arg" = "sudo" ]]; then
style=precommand
(( next_word & 2 )) && (( next_word = next_word ^ 2 ))
(( next_word = next_word | 4 ))
(( next_word = next_word | 1 ))
else
# Special-case: command word is '$foo', like that, without braces or anything.
#
# That's not entirely correct --- if the parameter's value happens to be a reserved
# word, the parameter expansion will be highlighted as a reserved word --- but that
# incorrectness is outweighed by the usability improvement of permitting the use of
# parameters that refer to commands, functions, and builtins.
if [[ ${arg[1]} == \$ ]] && (( ${+parameters} )) && [[ ${arg:1} = (#m)([a-zA-Z_][a-zA-Z0-9_]#|[0-9]##) ]] && (( ${+parameters[${MATCH}]} )); then
-fast-highlight-main-type ${(P)MATCH}
else
: ${expanded_path::=${(Q)~arg}}
-fast-highlight-main-type $expanded_path
fi
case $REPLY in
reserved) # reserved word
style=reserved-word
if [[ $arg == $'\x7b' ]]; then
braces_stack='Y'"$braces_stack"
elif [[ $arg == $'\x7d' && $braces_stack[1] == "Y" ]]; then
# We're at command word, so no need to check right_brace_is_recognised_everywhere
braces_stack[1]=""
style=reserved-word
(( next_word = next_word | 16 ))
elif [[ $arg == "[[" ]]; then
braces_stack='A'"$braces_stack"
fi
;;
'suffix alias') style=suffix-alias;;
alias)
insane_alias=0
case $arg in
# Issue #263: aliases with '=' on their LHS.
#
# There are three cases:
#
# - Unsupported, breaks 'alias -L' output, but invokable:
('='*) :;;
# - Unsupported, not invokable:
(*'='*) insane_alias=1;;
# - The common case:
(*) :;;
esac
if (( insane_alias )); then
style=unknown-token
else
style=alias
zmodload -e zsh/parameter && alias_target=${aliases[$arg]} || alias_target="${"$(alias -- $arg)"#*=}"
[[ ${__FAST_HIGHLIGHT_TOKEN_TYPES[$alias_target]} = "1" && "$arg_type" != "1" ]] && __FAST_HIGHLIGHT_TOKEN_TYPES[$arg]="1"
fi
;;
builtin) style=builtin;;
function) style=function;;
command) style=command;;
hashed) style=hashed-command;;
dirpath) style=path;;
none) # Assign?
if [[ $arg == [[:alpha:]_][[:alnum:]_]#(|\[[^\]]#\])(|[+])=* ]] || [[ $arg == [0-9]##(|[+])=* ]]; then
style=assign
# Assignment to a scalar parameter or to array
# (For array assignments, the command doesn't start until the ")" token.)
[[ $arg[-1] == '(' ]] && in_array_assignment=1 || (( next_word = next_word | 1 ))
elif [[ $arg[1] = $histchars[1] && -n "${arg[2]}" ]]; then
style=history-expansion
elif [[ $arg[1] == $histchars[2] ]]; then
style=history-expansion
elif (( arg_type == 3 )); then
# This highlights empty commands (semicolon follows nothing) as an error.
# Zsh accepts them, though.
(( this_word & 2 )) && style=commandseparator
elif [[ $arg[1,2] == '((' ]]; then
# Arithmetic evaluation.
#
# Note: prior to zsh-5.1.1-52-g4bed2cf (workers/36669), the ${(z)...}
# splitter would only output the '((' token if the matching '))' had
# been typed. Therefore, under those versions of zsh, BUFFER="(( 42"
# would be highlighted as an error until the matching "))" are typed.
#
# We highlight just the opening parentheses, as a reserved word; this
# is how [[ ... ]] is highlighted, too.
# ADD
(( start=start_pos-${#PREBUFFER}, end=end_pos-${#PREBUFFER}, start >= 0 )) && reply+=("$start $(( start + 2 )) ${FAST_HIGHLIGHT_STYLES[reserved-word]}")
already_added=1
# ADD
[[ $arg[-2,-1] == '))' ]] && (( start=start_pos-${#PREBUFFER}, end=end_pos-${#PREBUFFER}, start >= 0 )) && reply+=("$(( end - 2 )) $end ${FAST_HIGHLIGHT_STYLES[reserved-word]}")
elif [[ $arg == '()' ]]; then
# anonymous function
style=reserved-word
elif [[ $arg == $'\x28' ]]; then
# subshell
style=reserved-word
braces_stack='R'"$braces_stack"
elif [[ $arg == $'\x29' ]]; then
[[ $braces_stack[1] == "R" ]] && { braces_stack[1]=""; style=reserved-word; }
elif (( this_word & 14 )); then
style=default
fi
;;
*)
# ADD
# (( start=start_pos-${#PREBUFFER}, end=end_pos-${#PREBUFFER}, start >= 0 )) && reply+=("$start $end commandtypefromthefuture-$REPLY")
already_added=1
;;
esac
fi
# in_redirection || BIT_regular || BIT_sudo_opt || BIT_sudo_arg
elif (( in_redirection + this_word & 14 ))
then # $arg is a non-command word
case $arg in
']]')
style=reserved-word
[[ $braces_stack[1] == "A" ]] && braces_stack[1]=""
;;
']')
style=builtin
;;
$'\x28')
# '(' inside [[
style=reserved-word
braces_stack='R'"$braces_stack"
;;
$'\x29') # subshell or end of array assignment
if (( in_array_assignment )); then
style=assign
in_array_assignment=0
(( next_word = next_word | 1 ))
elif [[ $braces_stack[1] == "R" ]]; then
braces_stack[1]=""
style=reserved-word
fi;;
$'\x28\x29') # possibly a function definition
# || false # TODO: or if the previous word was a command word
(( FAST_HIGHLIGHT[multi_func_def] )) && (( next_word = next_word | 1 ))
style=reserved-word
# Remove possible annoying unknown-token style, or misleading function style
reply[-1]=()
;;
'--'*) style=double-hyphen-option;;
'-'*) style=single-hyphen-option;;
"'"*) style=single-quoted-argument;;
'"'*)
# ADD
(( start=start_pos-${#PREBUFFER}, end=end_pos-${#PREBUFFER}, start >= 0 )) && reply+=("$start $end ${FAST_HIGHLIGHT_STYLES[double-quoted-argument]}")
-fast-highlight-string
already_added=1
;;
\$\'*)
# ADD
(( start=start_pos-${#PREBUFFER}, end=end_pos-${#PREBUFFER}, start >= 0 )) && reply+=("$start $end ${FAST_HIGHLIGHT_STYLES[dollar-quoted-argument]}")
-fast-highlight-dollar-string
already_added=1
;;
\$[^\(]*)
style=variable
;;
'`'*) style=back-quoted-argument;;
[*?]*|*[^\\][*?]*)
(( highlight_glob )) && style=globbing || style=default;;
*) if [[ $arg = $'\x7d' && $braces_stack[1] == "Y" && "$FAST_HIGHLIGHT[right_brace_is_recognised_everywhere]" = "1" ]]; then
# right brace
# Parsing rule: # {
#
# Additionally, `tt(})' is recognized in any position if neither the
# tt(IGNORE_BRACES) option nor the tt(IGNORE_CLOSE_BRACES) option is set."""
braces_stack[1]=""
style=reserved-word
(( next_word = next_word | 16 ))
elif [[ $arg[1] = $histchars[1] && -n "${arg[2]}" ]]; then
style=history-expansion
elif (( arg_type == 3 )); then
style=commandseparator
elif (( in_redirection == 2 )); then
style=redirection
else
if [[ -z "${FAST_HIGHLIGHT[no_check_paths]}" ]] && -fast-highlight-check-path; then
# ADD
(( start=start_pos-${#PREBUFFER}, end=end_pos-${#PREBUFFER}, start >= 0 )) && reply+=("$start $end ${FAST_HIGHLIGHT_STYLES[path]}")
already_added=1
[[ -n "$FAST_HIGHLIGHT_STYLES[path_pathseparator]" && "$FAST_HIGHLIGHT_STYLES[path]" != "$FAST_HIGHLIGHT_STYLES[path_pathseparator]" ]] && {
for (( pos = start_pos; pos <= end_pos; pos++ )) ; do
# ADD
[[ ${buf[pos]} == "/" ]] && (( start=pos-${#PREBUFFER}, start >= 0 )) && reply+=("$(( start - 1 )) $start ${FAST_HIGHLIGHT_STYLES[path_pathseparator]}")
done
}
else
style=default
fi
fi
;;
esac
fi
# ADD
(( already_added == 0 )) && [[ "${FAST_HIGHLIGHT_STYLES[$style]}" != "none" ]] && (( start=start_pos-${#PREBUFFER}, end=end_pos-${#PREBUFFER}, start >= 0 )) && reply+=("$start $end ${FAST_HIGHLIGHT_STYLES[$style]}")
if (( arg_type == 3 )); then
if [[ $arg == ';' ]] && (( in_array_assignment )); then
# literal newline inside an array assignment
(( next_word = 2 ))
elif [[ -n "${braces_stack[(r)A]}" ]]; then
(( next_word = 2 ))
else
(( next_word = 1 ))
highlight_glob=1
fi
elif (( arg_type == 1 || arg_type == 2 )) && (( this_word & 1 )); then
(( next_word = 1 ))
elif [[ $arg == "repeat" ]] && (( this_word & 1 )); then
# skip the repeat-count word
in_redirection=2
# The redirection mechanism assumes $this_word describes the word
# following the redirection. Make it so.
#
# That word can be a command word with shortloops (`repeat 2 ls`)
# or a command separator (`repeat 2; ls` or `repeat 2; do ls; done`).
#
# The repeat-count word will be handled like a redirection target.
(( this_word = 3 ))
fi
start_pos=$end_pos
# This is the default/common codepath.
(( in_redirection == 0 )) && (( this_word = next_word )) #else # Stall $this_word.
done
return 0
}
# Check if $arg is a path.
# If yes, return 0 and in $REPLY the style to use.
# Else, return non-zero (and the contents of $REPLY is undefined).
-fast-highlight-check-path()
{
: ${expanded_path:=${(Q)~arg}}
[[ -z $expanded_path ]] && return 1
[[ -e $expanded_path ]] && return 0
# Search the path in CDPATH, only for CD command
[[ "$cur_cmd" = "cd" ]] && for cdpath_dir in $cdpath ; do
[[ -e "$cdpath_dir/$expanded_path" ]] && return 0
done
# It's not a path.
return 1
}
# Highlight special chars inside double-quoted strings
-fast-highlight-string()
{
mybuf="$arg"
idx=start_pos
while [[ "$mybuf" = (#b)[^\$\\]#((\$(#B)([a-zA-Z_:][a-zA-Z0-9_:]#|[0-9]##)(#b)(\[[^\]]#\])(#c0,1))|(\$[{](\([a-zA-Z0@%#]##\))(#c0,1)[a-zA-Z0-9_:#]##(\[[^\]]#\])(#c0,1)[}])|[\\][\'\"\$]|[\\](*))(*) ]]; do
[[ -n "${match[7]}" ]] && {
# Skip following char it is quoted. Choice is
# made to not highlight such quoting
idx+=${mbegin[1]}+1
mybuf="${match[7]:1}"
} || {
idx+=${mbegin[1]}-1
end_idx=idx+${mend[1]}-${mbegin[1]}+1
mybuf="${match[8]}"
# ADD
(( start=idx-${#PREBUFFER}, end=end_idx-${#PREBUFFER}, start >= 0 )) && reply+=("$start $end ${FAST_HIGHLIGHT_STYLES[back-or-dollar-double-quoted-argument]}")
idx=end_idx
}
done
}
# Highlight special chars inside dollar-quoted strings
-fast-highlight-dollar-string()
{
local i j k style
local AA
integer c
# Starting dollar-quote is at 1:2, so start parsing at offset 3 in the string.
for (( i = 3 ; i < end_pos - start_pos ; i += 1 )) ; do
(( j = i + start_pos - 1 ))
(( k = j + 1 ))
case "$arg[$i]" in
"\\") style=back-dollar-quoted-argument
for (( c = i + 1 ; c <= end_pos - start_pos ; c += 1 )); do
[[ "$arg[$c]" != ([0-9xXuUa-fA-F]) ]] && break
done
AA=$arg[$i+1,$c-1]
# Matching for HEX and OCT values like \0xA6, \xA6 or \012
if [[ "$AA" =~ "^(x|X)[0-9a-fA-F]{1,2}"
|| "$AA" =~ "^[0-7]{1,3}"
|| "$AA" =~ "^u[0-9a-fA-F]{1,4}"
|| "$AA" =~ "^U[0-9a-fA-F]{1,8}"
]]; then
(( k += $#MATCH ))
(( i += $#MATCH ))
else
if (( $#arg > $i+1 )) && [[ $arg[$i+1] == [xXuU] ]]; then
# \x not followed by hex digits is probably an error
style=unknown-token
fi
(( k += 1 )) # Color following char too.
(( i += 1 )) # Skip parsing the escaped char.
fi
;;
*) continue ;;
esac
# ADD
(( start=j-${#PREBUFFER}, end=k-${#PREBUFFER}, start >= 0 )) && reply+=("$start $end ${FAST_HIGHLIGHT_STYLES[$style]}")
done
}
# -------------------------------------------------------------------------------------------------
# Main highlighter initialization
# -------------------------------------------------------------------------------------------------
-fast-highlight-init() {
__fast_highlight_main__command_type_cache=()
}
# vim:ft=zsh:sw=2:sts=2
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-

View file

@ -1,34 +0,0 @@
#compdef desk
#autoload
_all_desks() {
desks=($(desk list --only-names))
}
local expl
local -a desks
local -a _subcommands
_subcommands=(
'help:Print a help message.'
'init:Initialize your desk configuration.'
'list:List available desks'
'ls:List available desks'
'edit:Edit or create a desk, defaults to current desk'
'go:Activate a desk'
'.:Activate a desk'
'run:Run a command within a desk environment'
'version:Show the desk version.'
)
if (( CURRENT == 2 )); then
_describe -t commands 'desk subcommand' _subcommands
return
fi
case "$words[2]" in
go|.|edit|run)
_all_desks
_wanted desks expl 'desks' compadd -a desks ;;
esac

File diff suppressed because it is too large Load diff

View file

@ -1,456 +0,0 @@
#compdef docker-compose
# Description
# -----------
# zsh completion for docker-compose
# https://github.com/sdurrheimer/docker-compose-zsh-completion
# -------------------------------------------------------------------------
# Version
# -------
# 1.5.0
# -------------------------------------------------------------------------
# Authors
# -------
# * Steve Durrheimer <s.durrheimer@gmail.com>
# -------------------------------------------------------------------------
# Inspiration
# -----------
# * @albers docker-compose bash completion script
# * @felixr docker zsh completion script : https://github.com/felixr/docker-zsh-completion
# -------------------------------------------------------------------------
__docker-compose_q() {
docker-compose 2>/dev/null $compose_options "$@"
}
# All services defined in docker-compose.yml
__docker-compose_all_services_in_compose_file() {
local already_selected
local -a services
already_selected=$(echo $words | tr " " "|")
__docker-compose_q config --services \
| grep -Ev "^(${already_selected})$"
}
# All services, even those without an existing container
__docker-compose_services_all() {
[[ $PREFIX = -* ]] && return 1
integer ret=1
services=$(__docker-compose_all_services_in_compose_file)
_alternative "args:services:($services)" && ret=0
return ret
}
# All services that have an entry with the given key in their docker-compose.yml section
__docker-compose_services_with_key() {
local already_selected
local -a buildable
already_selected=$(echo $words | tr " " "|")
# flatten sections to one line, then filter lines containing the key and return section name.
__docker-compose_q config \
| sed -n -e '/^services:/,/^[^ ]/p' \
| sed -n 's/^ //p' \
| awk '/^[a-zA-Z0-9]/{printf "\n"};{printf $0;next;}' \
| grep " \+$1:" \
| cut -d: -f1 \
| grep -Ev "^(${already_selected})$"
}
# All services that are defined by a Dockerfile reference
__docker-compose_services_from_build() {
[[ $PREFIX = -* ]] && return 1
integer ret=1
buildable=$(__docker-compose_services_with_key build)
_alternative "args:buildable services:($buildable)" && ret=0
return ret
}
# All services that are defined by an image
__docker-compose_services_from_image() {
[[ $PREFIX = -* ]] && return 1
integer ret=1
pullable=$(__docker-compose_services_with_key image)
_alternative "args:pullable services:($pullable)" && ret=0
return ret
}
__docker-compose_get_services() {
[[ $PREFIX = -* ]] && return 1
integer ret=1
local kind
declare -a running paused stopped lines args services
docker_status=$(docker ps > /dev/null 2>&1)
if [ $? -ne 0 ]; then
_message "Error! Docker is not running."
return 1
fi
kind=$1
shift
[[ $kind =~ (stopped|all) ]] && args=($args -a)
lines=(${(f)"$(_call_program commands docker $docker_options ps $args)"})
services=(${(f)"$(_call_program commands docker-compose 2>/dev/null $compose_options ps -q)"})
# Parse header line to find columns
local i=1 j=1 k header=${lines[1]}
declare -A begin end
while (( j < ${#header} - 1 )); do
i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 ))
j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 ))
k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 ))
begin[${header[$i,$((j-1))]}]=$i
end[${header[$i,$((j-1))]}]=$k
done
lines=(${lines[2,-1]})
# Container ID
local line s name
local -a names
for line in $lines; do
if [[ ${services[@]} == *"${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}"* ]]; then
names=(${(ps:,:)${${line[${begin[NAMES]},-1]}%% *}})
for name in $names; do
s="${${name%_*}#*_}:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}"
s="$s, ${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}"
s="$s, ${${${line[${begin[IMAGE]},${end[IMAGE]}]}/:/\\:}%% ##}"
if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then
stopped=($stopped $s)
else
if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = *\(Paused\)* ]]; then
paused=($paused $s)
fi
running=($running $s)
fi
done
fi
done
[[ $kind =~ (running|all) ]] && _describe -t services-running "running services" running "$@" && ret=0
[[ $kind =~ (paused|all) ]] && _describe -t services-paused "paused services" paused "$@" && ret=0
[[ $kind =~ (stopped|all) ]] && _describe -t services-stopped "stopped services" stopped "$@" && ret=0
return ret
}
__docker-compose_pausedservices() {
[[ $PREFIX = -* ]] && return 1
__docker-compose_get_services paused "$@"
}
__docker-compose_stoppedservices() {
[[ $PREFIX = -* ]] && return 1
__docker-compose_get_services stopped "$@"
}
__docker-compose_runningservices() {
[[ $PREFIX = -* ]] && return 1
__docker-compose_get_services running "$@"
}
__docker-compose_services() {
[[ $PREFIX = -* ]] && return 1
__docker-compose_get_services all "$@"
}
__docker-compose_caching_policy() {
oldp=( "$1"(Nmh+1) ) # 1 hour
(( $#oldp ))
}
__docker-compose_commands() {
local cache_policy
zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
if [[ -z "$cache_policy" ]]; then
zstyle ":completion:${curcontext}:" cache-policy __docker-compose_caching_policy
fi
if ( [[ ${+_docker_compose_subcommands} -eq 0 ]] || _cache_invalid docker_compose_subcommands) \
&& ! _retrieve_cache docker_compose_subcommands;
then
local -a lines
lines=(${(f)"$(_call_program commands docker-compose 2>&1)"})
_docker_compose_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I) *]}]}## #}/ ##/:})
(( $#_docker_compose_subcommands > 0 )) && _store_cache docker_compose_subcommands _docker_compose_subcommands
fi
_describe -t docker-compose-commands "docker-compose command" _docker_compose_subcommands
}
__docker-compose_subcommand() {
local opts_help opts_force_recreate opts_no_recreate opts_no_build opts_remove_orphans opts_timeout opts_no_color opts_no_deps
opts_help='(: -)--help[Print usage]'
opts_force_recreate="(--no-recreate)--force-recreate[Recreate containers even if their configuration and image haven't changed. Incompatible with --no-recreate.]"
opts_no_recreate="(--force-recreate)--no-recreate[If containers already exist, don't recreate them. Incompatible with --force-recreate.]"
opts_no_build="(--build)--no-build[Don't build an image, even if it's missing.]"
opts_remove_orphans="--remove-orphans[Remove containers for services not defined in the Compose file]"
opts_timeout=('(-t --timeout)'{-t,--timeout}"[Specify a shutdown timeout in seconds. (default: 10)]:seconds: ")
opts_no_color='--no-color[Produce monochrome output.]'
opts_no_deps="--no-deps[Don't start linked services.]"
integer ret=1
case "$words[1]" in
(build)
_arguments \
$opts_help \
'--force-rm[Always remove intermediate containers.]' \
'--no-cache[Do not use cache when building the image.]' \
'--pull[Always attempt to pull a newer version of the image.]' \
'*:services:__docker-compose_services_from_build' && ret=0
;;
(bundle)
_arguments \
$opts_help \
'(--output -o)'{--output,-o}'[Path to write the bundle file to. Defaults to "<project name>.dab".]:file:_files' && ret=0
;;
(config)
_arguments \
$opts_help \
'(--quiet -q)'{--quiet,-q}"[Only validate the configuration, don't print anything.]" \
'--services[Print the service names, one per line.]' && ret=0
;;
(create)
_arguments \
$opts_help \
$opts_force_recreate \
$opts_no_recreate \
$opts_no_build \
"(--no-build)--build[Build images before creating containers.]" \
'*:services:__docker-compose_services_all' && ret=0
;;
(down)
_arguments \
$opts_help \
"--rmi[Remove images. Type must be one of: 'all': Remove all images used by any service. 'local': Remove only images that don't have a custom tag set by the \`image\` field.]:type:(all local)" \
'(-v --volumes)'{-v,--volumes}"[Remove named volumes declared in the \`volumes\` section of the Compose file and anonymous volumes attached to containers.]" \
$opts_remove_orphans && ret=0
;;
(events)
_arguments \
$opts_help \
'--json[Output events as a stream of json objects]' \
'*:services:__docker-compose_services_all' && ret=0
;;
(exec)
_arguments \
$opts_help \
'-d[Detached mode: Run command in the background.]' \
'--privileged[Give extended privileges to the process.]' \
'--user=[Run the command as this user.]:username:_users' \
'-T[Disable pseudo-tty allocation. By default `docker-compose exec` allocates a TTY.]' \
'--index=[Index of the container if there are multiple instances of a service \[default: 1\]]:index: ' \
'(-):running services:__docker-compose_runningservices' \
'(-):command: _command_names -e' \
'*::arguments: _normal' && ret=0
;;
(help)
_arguments ':subcommand:__docker-compose_commands' && ret=0
;;
(kill)
_arguments \
$opts_help \
'-s[SIGNAL to send to the container. Default signal is SIGKILL.]:signal:_signals' \
'*:running services:__docker-compose_runningservices' && ret=0
;;
(logs)
_arguments \
$opts_help \
'(-f --follow)'{-f,--follow}'[Follow log output]' \
$opts_no_color \
'--tail=[Number of lines to show from the end of the logs for each container.]:number of lines: ' \
'(-t --timestamps)'{-t,--timestamps}'[Show timestamps]' \
'*:services:__docker-compose_services_all' && ret=0
;;
(pause)
_arguments \
$opts_help \
'*:running services:__docker-compose_runningservices' && ret=0
;;
(port)
_arguments \
$opts_help \
'--protocol=[tcp or udp \[default: tcp\]]:protocol:(tcp udp)' \
'--index=[index of the container if there are multiple instances of a service \[default: 1\]]:index: ' \
'1:running services:__docker-compose_runningservices' \
'2:port:_ports' && ret=0
;;
(ps)
_arguments \
$opts_help \
'-q[Only display IDs]' \
'*:services:__docker-compose_services_all' && ret=0
;;
(pull)
_arguments \
$opts_help \
'--ignore-pull-failures[Pull what it can and ignores images with pull failures.]' \
'*:services:__docker-compose_services_from_image' && ret=0
;;
(push)
_arguments \
$opts_help \
'--ignore-push-failures[Push what it can and ignores images with push failures.]' \
'*:services:__docker-compose_services' && ret=0
;;
(rm)
_arguments \
$opts_help \
'(-f --force)'{-f,--force}"[Don't ask to confirm removal]" \
'-v[Remove any anonymous volumes attached to containers]' \
'*:stopped services:__docker-compose_stoppedservices' && ret=0
;;
(run)
_arguments \
$opts_help \
'-d[Detached mode: Run container in the background, print new container name.]' \
'*-e[KEY=VAL Set an environment variable (can be used multiple times)]:environment variable KEY=VAL: ' \
'--entrypoint[Overwrite the entrypoint of the image.]:entry point: ' \
'--name=[Assign a name to the container]:name: ' \
$opts_no_deps \
'(-p --publish)'{-p,--publish=}"[Publish a container's port(s) to the host]" \
'--rm[Remove container after run. Ignored in detached mode.]' \
"--service-ports[Run command with the service's ports enabled and mapped to the host.]" \
'-T[Disable pseudo-tty allocation. By default `docker-compose run` allocates a TTY.]' \
'(-u --user)'{-u,--user=}'[Run as specified username or uid]:username or uid:_users' \
'(-w --workdir)'{-w,--workdir=}'[Working directory inside the container]:workdir: ' \
'(-):services:__docker-compose_services' \
'(-):command: _command_names -e' \
'*::arguments: _normal' && ret=0
;;
(scale)
_arguments \
$opts_help \
$opts_timeout \
'*:running services:__docker-compose_runningservices' && ret=0
;;
(start)
_arguments \
$opts_help \
'*:stopped services:__docker-compose_stoppedservices' && ret=0
;;
(stop|restart)
_arguments \
$opts_help \
$opts_timeout \
'*:running services:__docker-compose_runningservices' && ret=0
;;
(unpause)
_arguments \
$opts_help \
'*:paused services:__docker-compose_pausedservices' && ret=0
;;
(up)
_arguments \
$opts_help \
'(--abort-on-container-exit)-d[Detached mode: Run containers in the background, print new container names. Incompatible with --abort-on-container-exit.]' \
$opts_no_color \
$opts_no_deps \
$opts_force_recreate \
$opts_no_recreate \
$opts_no_build \
"(--no-build)--build[Build images before starting containers.]" \
"(-d)--abort-on-container-exit[Stops all containers if any container was stopped. Incompatible with -d.]" \
'(-t --timeout)'{-t,--timeout}"[Use this timeout in seconds for container shutdown when attached or when containers are already running. (default: 10)]:seconds: " \
$opts_remove_orphans \
'*:services:__docker-compose_services_all' && ret=0
;;
(version)
_arguments \
$opts_help \
"--short[Shows only Compose's version number.]" && ret=0
;;
(*)
_message 'Unknown sub command' && ret=1
;;
esac
return ret
}
_docker-compose() {
# Support for subservices, which allows for `compdef _docker docker-shell=_docker_containers`.
# Based on /usr/share/zsh/functions/Completion/Unix/_git without support for `ret`.
if [[ $service != docker-compose ]]; then
_call_function - _$service
return
fi
local curcontext="$curcontext" state line
integer ret=1
typeset -A opt_args
_arguments -C \
'(- :)'{-h,--help}'[Get help]' \
'(-f --file)'{-f,--file}'[Specify an alternate docker-compose file (default: docker-compose.yml)]:file:_files -g "*.yml"' \
'(-p --project-name)'{-p,--project-name}'[Specify an alternate project name (default: directory name)]:project name:' \
'--verbose[Show more output]' \
'(- :)'{-v,--version}'[Print version and exit]' \
'(-H --host)'{-H,--host}'[Daemon socket to connect to]:host:' \
'--tls[Use TLS; implied by --tlsverify]' \
'--tlscacert=[Trust certs signed only by this CA]:ca path:' \
'--tlscert=[Path to TLS certificate file]:client cert path:' \
'--tlskey=[Path to TLS key file]:tls key path:' \
'--tlsverify[Use TLS and verify the remote]' \
"--skip-hostname-check[Don't check the daemon's hostname against the name specified in the client certificate (for example if your docker host is an IP address)]" \
'(-): :->command' \
'(-)*:: :->option-or-argument' && ret=0
local -a relevant_compose_flags relevant_docker_flags compose_options docker_options
relevant_compose_flags=(
"--file" "-f"
"--host" "-H"
"--project-name" "-p"
"--tls"
"--tlscacert"
"--tlscert"
"--tlskey"
"--tlsverify"
"--skip-hostname-check"
)
relevant_docker_flags=(
"--host" "-H"
"--tls"
"--tlscacert"
"--tlscert"
"--tlskey"
"--tlsverify"
)
for k in "${(@k)opt_args}"; do
if [[ -n "${relevant_docker_flags[(r)$k]}" ]]; then
docker_options+=$k
if [[ -n "$opt_args[$k]" ]]; then
docker_options+=$opt_args[$k]
fi
fi
if [[ -n "${relevant_compose_flags[(r)$k]}" ]]; then
compose_options+=$k
if [[ -n "$opt_args[$k]" ]]; then
compose_options+=$opt_args[$k]
fi
fi
done
case $state in
(command)
__docker-compose_commands && ret=0
;;
(option-or-argument)
curcontext=${curcontext%:*:*}:docker-compose-$words[1]:
__docker-compose_subcommand && ret=0
;;
esac
return ret
}
_docker-compose "$@"

View file

@ -1,8 +0,0 @@
#compdef extract
#autoload
_arguments \
'(-r --remove)'{-r,--remove}'[Remove archive.]' \
"*::archive file:_files -g '(#i)*.(7z|Z|apk|bz2|deb|gz|ipsw|jar|lzma|rar|sublime-package|tar|tar.bz2|tar.gz|tar.xz|tar.zma|tbz|tbz2|tgz|tlz|txz|war|xpi|xz|zip)(-.)'" \
&& return 0

View file

@ -1,61 +0,0 @@
#compdef lj
###
# List of log levels
###
_levels=(
'emergency'
'alert'
'critical'
'error'
'warning'
'notice'
'info'
'debug'
)
###
# Describe log levels
###
function _lumberjack_log_levels() {
_describe -t levels 'levels' _levels "$@"
}
###
# Lumberjack completion
###
function _lumberjack() {
typeset -A opt_args
local context state line curcontext="$curcontext"
# Set option arguments
_arguments -A \
'(-h --help)'{-h,--help}'[show help text and exit]' \
'(-v --version)'{-v,--version}'[show version information and exit]' \
'(-f --file)'{-f,--file}'[set log file and exit]' \
'(-l --level)'{-l,--level}'[set log level and exit]' \
# Set log level arguments
_arguments \
'1: :_lumberjack_log_levels' \
'*::arg:->args'
# Complete option arguments
case "$state" in
args )
case "$words[1]" in
--file|-f )
_arguments \
'1:file:_files'
;;
--level|-l )
_arguments \
'1:level:_lumberjack_log_levels'
;;
esac
;;
esac
}
_lumberjack "$@"

View file

@ -1,34 +0,0 @@
#compdef revolver
_commands=(
'start:start the spinner process'
'update:update the message'
'stop:stop the spinner process'
'demo:display a demo of each style'
)
###
# Complete revolver commands
###
function _revolver_commands() {
_describe -t commands 'commands' _commands "$@"
}
###
# Revolver completion
###
function _revolver() {
typeset -A opt_args
local context state line curcontext="$curcontext"
# Set option arguments
_arguments -A \
'(-h --help)'{-h,--help}'[show help text and exit]' \
'(-v --version)'{-v,--version}'[show version information and exit]'
# Set log level arguments
_arguments \
'1: :_revolver_commands'
}
_revolver "$@"

View file

@ -1,131 +0,0 @@
#compdef vagrant
#autoload
# vagrant zsh completion
local -a _1st_arguments
_1st_arguments=(
'box:Box commands'
'connect:Connects to a remotely shared Vagrant environment'
'destroy:Destroys the vagrant environment'
'docker-logs:Outputs the logs from the Docker container'
'docker-run:Run a one-off command in the context of a container'
'global-status:Reports the status of all active Vagrant environments on the system'
'halt:Halts the currently running vagrant environment'
'help:Shows the help for a subcommand'
'init:[box_name] [box_url] Initializes current folder for Vagrant usage'
'list-commands:Outputs all available Vagrant subcommands, even non-primary ones'
'login:Authenticates against a Vagrant Cloud server to access protected boxes'
'package:Packages a vagrant environment for distribution'
'plugin:Plugin commands'
'provision:Run the provisioner'
'push:Deploys code in this environment to a configured destination'
'rdp:Connects to machine via RDP'
'reload:Reload the vagrant environment'
'resume:Resumes a suspend vagrant environment'
'rsync:Syncs rsync synced folders to remote machine'
'rsync-auto:Syncs rsync synced folders automatically when files change'
'share:Shares your Vagrant environment with anyone in the world'
'snapshot:Manage snapshots with the guest machine'
'ssh:SSH into the currently running environment'
'ssh-config:Outputs .ssh/config valid syntax for connecting to this environment via ssh'
'status:Shows the status of the current Vagrant environment'
'suspend:Suspends the currently running vagrant environment'
'snapshot:Used to manage snapshots with the guest machine'
'up:Creates the vagrant environment'
'version:Prints current and latest Vagrant version'
'--help:[TASK] Describe available tasks or one specific task'
'--version:Prints the Vagrant version information'
)
local -a _box_arguments
_box_arguments=(
'add:ADDRESS Adds a box to the system'
'help:COMMAND List subcommands'
'list:Lists all installed boxes'
'outdated:Checks if a box has newer version'
'remove:NAME Removes a box from the system'
'repackage:NAME PROVIDER VERSION Repackages an installed box into a `.box` file'
'update:Updates box to a newer version, if available'
)
__task_list ()
{
local expl
declare -a tasks
tasks=(box destroy halt init package provision reload resume ssh ssh_config status suspend up version)
_wanted tasks expl 'help' compadd $tasks
}
__box_list ()
{
_wanted application expl 'command' compadd $(command vagrant box list | sed -e 's/ /\\ /g')
}
__vm_list ()
{
_wanted application expl 'command' compadd $(command grep Vagrantfile -oe '^[^#]*\.vm\.define *[:"]\([a-zA-Z0-9_-]\+\)' 2>/dev/null | awk '{print substr($2, 2)}')
_wanted application expl 'command' compadd $(command ls .vagrant/machines/ 2>/dev/null)
}
__vagrant-box ()
{
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments -C \
':command:->command' \
'*::options:->options'
case $state in
(command)
_describe -t commands "gem subcommand" _box_arguments
return
;;
(options)
case $line[1] in
(repackage|remove)
_arguments ':feature:__box_list'
;;
esac
;;
esac
}
local expl
local -a boxes installed_boxes
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments -C \
':command:->command' \
'*::options:->options'
case $state in
(command)
_describe -t commands "gem subcommand" _1st_arguments
return
;;
(options)
case $line[1] in
(help)
_arguments ':feature:__task_list'
;;
(box)
__vagrant-box
;;
(up|provision|package|destroy|reload|ssh|ssh-config|halt|resume|status)
_arguments ':feature:__vm_list'
esac
;;
esac

View file

@ -1,135 +0,0 @@
# z4rr3t
# by Garret Jennings
# https://github.com/inimicus/z4rr3t
# Based on Pure
# by Sindre Sorhus
# https://github.com/sindresorhus/pure
# MIT License
# For my own and others sanity
# git:
# %b => current branch
# %a => current action (rebase/merge)
# prompt:
# %F => color dict
# %f => reset color
# %~ => current path
# %* => time
# %n => username
# %m => shortname host
# %(?..) => prompt conditional - %(condition.true.false)
# turns seconds into human readable time
# 165392 => 1d 21h 56m 32s
prompt_z4rr3t_human_time() {
echo -n " "
local tmp=$1
local days=$(( tmp / 60 / 60 / 24 ))
local hours=$(( tmp / 60 / 60 % 24 ))
local minutes=$(( tmp / 60 % 60 ))
local seconds=$(( tmp % 60 ))
(( $days > 0 )) && echo -n "${days}d "
(( $hours > 0 )) && echo -n "${hours}h "
(( $minutes > 0 )) && echo -n "${minutes}m "
echo "${seconds}s"
}
# fastest possible way to check if repo is dirty
prompt_z4rr3t_git_dirty() {
# check if we're in a git repo
[[ "$(command git rev-parse --is-inside-work-tree 2>/dev/null)" == "true" ]] || return
# check if it's dirty
[[ "$Z4RR3T_GIT_UNTRACKED_DIRTY" == 0 ]] && local umode="-uno" || local umode="-unormal"
command test -n "$(git status --porcelain --ignore-submodules ${umode})"
(($? == 0)) && echo '*'
}
# displays the exec time of the last command if set threshold was exceeded
prompt_z4rr3t_cmd_exec_time() {
local stop=$EPOCHSECONDS
local start=${cmd_timestamp:-$stop}
integer elapsed=$stop-$start
(($elapsed > ${Z4RR3T_CMD_MAX_EXEC_TIME:=10})) && prompt_z4rr3t_human_time $elapsed
}
prompt_z4rr3t_preexec() {
cmd_timestamp=$EPOCHSECONDS
# shows the current dir and executed command in the title when a process is active
print -Pn "\e]0;"
echo -nE "$PWD:t: $2"
print -Pn "\a"
}
# string length ignoring ansi escapes
prompt_z4rr3t_string_length() {
echo $(( ${#${(S%%)1//(\%([KF1]|)\{*\}|\%[Bbkf])}} ))
}
prompt_z4rr3t_precmd() {
# shows the full path in the title
print -Pn '\e]0;%~\a'
# git info
vcs_info
local prompt_z4rr3t_preprompt="$prompt_z4rr3t_username%F{blue}%~%F{242}$vcs_info_msg_0_`prompt_z4rr3t_git_dirty`%f%F{yellow}`prompt_z4rr3t_cmd_exec_time`%f"
print -P $prompt_z4rr3t_preprompt
# check async if there is anything to pull
(( ${Z4RR3T_GIT_PULL:-1} )) && {
# check if we're in a git repo
[[ "$(command git rev-parse --is-inside-work-tree 2>/dev/null)" == "true" ]] &&
# make sure working tree is not $HOME
[[ "$(command git rev-parse --show-toplevel)" != "$HOME" ]] &&
# check check if there is anything to pull
command git fetch &>/dev/null &&
# check if there is an upstream configured for this branch
command git rev-parse --abbrev-ref @'{u}' &>/dev/null && {
local arrows=''
(( $(command git rev-list --right-only --count HEAD...@'{u}' 2>/dev/null) > 0 )) && arrows='⇣'
(( $(command git rev-list --left-only --count HEAD...@'{u}' 2>/dev/null) > 0 )) && arrows+='⇡'
print -Pn "\e7\e[A\e[1G\e[`prompt_z4rr3t_string_length $prompt_z4rr3t_preprompt`C%F{cyan}${arrows}%f\e8"
}
} &!
# reset value since `preexec` isn't always triggered
unset cmd_timestamp
}
prompt_z4rr3t_setup() {
# prevent percentage showing up
# if output doesn't end with a newline
export PROMPT_EOL_MARK=''
# disable auth prompting on git 2.3+
export GIT_TERMINAL_PROMPT=0
prompt_opts=(cr subst percent)
zmodload zsh/datetime
autoload -Uz add-zsh-hook
autoload -Uz vcs_info
add-zsh-hook precmd prompt_z4rr3t_precmd
add-zsh-hook preexec prompt_z4rr3t_preexec
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:git*' formats ' %b'
zstyle ':vcs_info:git*' actionformats ' %b|%a'
# show username@host if logged in through SSH
[[ "$SSH_CONNECTION" != '' ]] && prompt_z4rr3t_username='%F{yellow}%n%F{white}@%F{242}%m '
# show username@host if root, with username in white
[[ $UID -eq 0 ]] && prompt_z4rr3t_username='%F{white}%n%F{red}@%F{242}%m '
# prompt turns red if the previous command didn't exit with 0
PROMPT="%(?.%F{magenta}.%F{red})${Z4RR3T_PROMPT_SYMBOL:-}%f "
}
prompt_z4rr3t_setup "$@"

@ -1 +0,0 @@
Subproject commit 08beebd89f9eec956c126c732a287ec5a5a197a8