Work on hashcat completion

Jonathan Hodgson 5 years ago
parent 7641d72058
commit dd4858168c
  1. 1
      shells/zsh/oh-my-zsh-custom/completion.zsh
  2. 144
      shells/zsh/oh-my-zsh-custom/completion/_pass
  3. 15
      shells/zsh/oh-my-zsh-custom/fzf.zsh

@ -23,3 +23,4 @@ complete -o nospace -F _wp_complete wp
_comp_options+=(globdots)
fpath+="$(dirname $0)/completion"

@ -0,0 +1,144 @@
#compdef pass
#autoload
# Copyright (C) 2012 - 2014:
# Johan Venant <jvenant@invicem.pro>
# Brian Mattern <rephorm@rephorm.com>
# Jason A. Donenfeld <Jason@zx2c4.com>.
# All Rights Reserved.
# This file is licensed under the GPLv2+. Please see COPYING for more information.
# If you use multiple repositories, you can configure completion like this:
#
# compdef _pass workpass
# zstyle ':completion::complete:workpass::' prefix "$HOME/work/pass"
# workpass() {
# PASSWORD_STORE_DIR=$HOME/work/pass pass $@
# }
_pass () {
local cmd
if (( CURRENT > 2)); then
cmd=${words[2]}
# Set the context for the subcommand.
curcontext="${curcontext%:*:*}:pass-$cmd"
# Narrow the range of words we are looking at to exclude `pass'
(( CURRENT-- ))
shift words
# Run the completion for the subcommand
case "${cmd}" in
init)
_arguments : \
"-p[gpg-id will only be applied to this subfolder]" \
"--path[gpg-id will only be applied to this subfolder]"
_pass_complete_keys
;;
ls|list|edit)
_pass_complete_entries_with_subdirs
;;
insert)
_arguments : \
"-e[echo password to console]" \
"--echo[echo password to console]" \
"-m[multiline]" \
"--multiline[multiline]"
_pass_complete_entries_with_subdirs
;;
generate)
_arguments : \
"-n[don't include symbols in password]" \
"--no-symbols[don't include symbols in password]" \
"-c[copy password to the clipboard]" \
"--clip[copy password to the clipboard]" \
"-f[force overwrite]" \
"--force[force overwrite]" \
"-i[replace first line]" \
"--in-place[replace first line]"
_pass_complete_entries_with_subdirs
;;
cp|copy|mv|rename)
_arguments : \
"-f[force rename]" \
"--force[force rename]"
_pass_complete_entries_with_subdirs
;;
rm)
_arguments : \
"-f[force deletion]" \
"--force[force deletion]" \
"-r[recursively delete]" \
"--recursive[recursively delete]"
_pass_complete_entries_with_subdirs
;;
git)
local -a subcommands
subcommands=(
"init:Initialize git repository"
"push:Push to remote repository"
"pull:Pull from remote repository"
"config:Show git config"
"log:Show git log"
"reflog:Show git reflog"
)
_describe -t commands 'pass git' subcommands
;;
show|*)
_pass_cmd_show
;;
esac
else
local -a subcommands
subcommands=(
"init:Initialize new password storage"
"ls:List passwords"
"find:Find password files or directories based on pattern"
"grep:Search inside decrypted password files for matching pattern"
"show:Decrypt and print a password"
"insert:Insert a new password"
"generate:Generate a new password using pwgen"
"edit:Edit a password with \$EDITOR"
"mv:Rename the password"
"cp:Copy the password"
"rm:Remove the password"
"git:Call git on the password store"
"version:Output version information"
"help:Output help message"
)
_describe -t commands 'pass' subcommands
_arguments : \
"--version[Output version information]" \
"--help[Output help message]"
_pass_cmd_show
fi
}
_pass_cmd_show () {
_arguments : \
"-c[put it on the clipboard]" \
"--clip[put it on the clipboard]"
_pass_complete_entries
}
_pass_complete_entries_helper () {
local IFS=$'\n'
local prefix
zstyle -s ":completion:${curcontext}:" prefix prefix || prefix="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
_values -C 'passwords' ${$(find -L "$prefix" \( -name .git -o -name .gpg-id \) -prune -o $@ -print 2>/dev/null | sed -e "s#${prefix}/\{0,1\}##" -e 's#\.gpg##' -e 's#\\#\\\\#' | sort):-""}
}
_pass_complete_entries_with_subdirs () {
_pass_complete_entries_helper
}
_pass_complete_entries () {
_pass_complete_entries_helper -type f
}
_pass_complete_keys () {
local IFS=$'\n'
# Extract names and email addresses from gpg --list-keys
_values 'gpg keys' $(gpg2 --list-secret-keys --with-colons | cut -d : -f 10 | sort -u | sed '/^$/d')
}
_pass

@ -146,12 +146,20 @@ jhswap(){
return
fi
cmd=${tokens[1]}
if [[ "$cmd" == "hashcat" && "${tokens[-1]}" == "-m" ]]; then
mode=$(hashcat --example-hashes | awk -v RS="\n\n" -F "\t" '{gsub("\n","\t",$0); print $1 "\t" $2 "\t" $3}' | sed 's/MODE: //; s/TYPE: //' | fzf -d "\t" --header="Mode Type" --with-nth='1,2' --preview='echo {3}' --preview-window=up:1 | cut -d' ' -f1)
append=""
if [[ "$cmd" == "hashcat" ]]; then
if [[ "${tokens[-1]}" == "-m" || "${tokens[-1]}" == "--hash-type" ]]; then
append=$(hashcat --example-hashes | awk -v RS="\n\n" -F "\t" '{gsub("\n","\t",$0); print $1 "\t" $2 "\t" $3}' | sed 's/MODE: //; s/TYPE: //' | fzf -d "\t" --header="Mode Type" --with-nth='1,2' --preview='echo {3}' --preview-window=up:1 | cut -d' ' -f1)
#else
# append=$(hashcat --help | sed -n '/Options Short/,/^$/p' | sed -E 's/ +/ /g' | sed '/==============/d' | column -t -s '|' -o " " | fzf -d " " --with-nth="1,3" --tabstop=2 --header-lines="1" --no-preview | cut -d' ' -f1 | sed 's/\s*$//' | grep -Eo '\S+$')
fi
fi
if [ -n "$append" ]; then
# Make sure that we are adding a space
if [[ "${LBUFFER[-1]}" != " " ]]; then
LBUFFER="${LBUFFER} "
fi
LBUFFER="${LBUFFER}${mode}"
LBUFFER="${LBUFFER}${append}"
zle reset-prompt
return $ret
return 0
@ -163,7 +171,6 @@ jhswap(){
done
# Some of my completions should only work when in a project
if [[ "${LBUFFER[-1]}" == " " ]]; then
fzf-completion
else

Loading…
Cancel
Save