Moves includes into includes folder
This commit is contained in:
parent
3933e1b17b
commit
c9291ffcbf
45 changed files with 19 additions and 5229 deletions
24
shells/zsh/includes/aliases.zsh
Normal file
24
shells/zsh/includes/aliases.zsh
Normal file
|
@ -0,0 +1,24 @@
|
|||
source ~/.dotfiles/shells/shared/aliases
|
||||
|
||||
###########################################
|
||||
# #
|
||||
# Suffex Aliases #
|
||||
# #
|
||||
###########################################
|
||||
|
||||
alias -s html=$EDITOR
|
||||
alias -s htm=$EDITOR
|
||||
|
||||
alias -s php=$EDITOR
|
||||
|
||||
alias -s less=$EDITOR
|
||||
alias -s css=$EDITOR
|
||||
|
||||
alias -s js=$EDITOR
|
||||
alias -s es6=$EDITOR
|
||||
|
||||
alias -s gitignore=$EDITOR
|
||||
|
||||
alias -s json=$EDITOR
|
||||
|
||||
#unalias gf
|
26
shells/zsh/includes/completion.zsh
Normal file
26
shells/zsh/includes/completion.zsh
Normal file
|
@ -0,0 +1,26 @@
|
|||
compdef sshrc=ssh
|
||||
|
||||
autoload bashcompinit
|
||||
bashcompinit
|
||||
_wp_complete() {
|
||||
local OLD_IFS="$IFS"
|
||||
local cur=${COMP_WORDS[COMP_CWORD]}
|
||||
IFS=$'\n'; # want to preserve spaces at the end
|
||||
local opts="$(wp cli completions --line="$COMP_LINE" --point="$COMP_POINT")"
|
||||
if [[ "$opts" =~ \<file\>\s* ]]
|
||||
then
|
||||
COMPREPLY=( $(compgen -f -- $cur) )
|
||||
elif [[ $opts = "" ]]
|
||||
then
|
||||
COMPREPLY=( $(compgen -f -- $cur) )
|
||||
else
|
||||
COMPREPLY=( ${opts[*]} )
|
||||
fi
|
||||
IFS="$OLD_IFS"
|
||||
return 0
|
||||
}
|
||||
complete -o nospace -F _wp_complete wp
|
||||
|
||||
_comp_options+=(globdots)
|
||||
|
||||
fpath+="$(dirname $0)/completion"
|
1
shells/zsh/includes/functions.zsh
Normal file
1
shells/zsh/includes/functions.zsh
Normal file
|
@ -0,0 +1 @@
|
|||
source ~/.dotfiles/shells/shared/functions
|
193
shells/zsh/includes/fzf.zsh
Normal file
193
shells/zsh/includes/fzf.zsh
Normal file
|
@ -0,0 +1,193 @@
|
|||
# this rg command will get a list of files that are not in gitignore or similar
|
||||
export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --exclude .git --exclude .PlayOnLinux --exclude \"PlayOnLinux\'s virtual drives\""
|
||||
export FZF_DEFAULT_OPTS="--preview '[[ \$(file -L --mime {}) =~ binary ]] && echo {} is a binary file || ( bat --style=numbers --color=always {} || cat {}) 2> /dev/null | head -500'"
|
||||
export FZF_CTRL_R_OPTS="--no-preview"
|
||||
# this is the argument completeion optionm, use the same command
|
||||
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
|
||||
if [ -e /usr/share/fzf/key-bindings.zsh ]; then
|
||||
source /usr/share/fzf/key-bindings.zsh
|
||||
source /usr/share/fzf/completion.zsh
|
||||
|
||||
# CTRL-W to select a wordlist
|
||||
__fsel_wordlist() {
|
||||
local cmd="$FZF_DEFAULT_COMMAND --exclude \*.md --exclude \*.gif --exclude \*.jpg --exclude \*.png --exclude \*.lua --exclude \*.jar --exclude \*.pl '' /usr/share/wordlists/ | sed 's#^/usr/share/wordlists/##'"
|
||||
setopt localoptions pipefail 2> /dev/null
|
||||
eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS --preview 'bat --color=always /usr/share/wordlists/{}'" $(__fzfcmd) -m "$@" | while read item; do
|
||||
echo -n "/usr/share/wordlists/${(q)item} "
|
||||
done
|
||||
local ret=$?
|
||||
echo
|
||||
return $ret
|
||||
}
|
||||
|
||||
fzf-wordlist-widget() {
|
||||
LBUFFER="${LBUFFER}$(__fsel_wordlist)"
|
||||
local ret=$?
|
||||
zle reset-prompt
|
||||
return $ret
|
||||
}
|
||||
#zle -N fzf-wordlist-widget
|
||||
#bindkey '^W' fzf-wordlist-widget
|
||||
|
||||
# CTRL-P to select an IP address from project host
|
||||
__fsel_ip() {
|
||||
setopt localoptions pipefail 2> /dev/null
|
||||
project hosts ip --fzf
|
||||
|
||||
local ret=$?
|
||||
return $ret
|
||||
}
|
||||
|
||||
fzf-ip-widget() {
|
||||
LBUFFER="${LBUFFER}$(project hosts ip --fzf) "
|
||||
local ret=$?
|
||||
zle reset-prompt
|
||||
return $ret
|
||||
}
|
||||
#zle -N fzf-ip-widget
|
||||
#bindkey '^P' fzf-ip-widget
|
||||
|
||||
|
||||
jhComplete(){
|
||||
local comp=$(echo $1 | cut -d':' -f1)
|
||||
local prompt=$(echo $1 | cut -d':' -f2)
|
||||
local currentProject=$(project current --path)
|
||||
find "$HOME/.local/share/snippets/" -name \*.func | while read line; do
|
||||
source "$line"
|
||||
done
|
||||
case "${comp}" in
|
||||
ip)
|
||||
if [ -n "$currentProject" ]; then
|
||||
project hosts ip --fzf
|
||||
fi
|
||||
;;
|
||||
myip)
|
||||
ip route | grep -oE '(dev|src) [^ ]+' | sed 'N;s/\n/,/;s/src //' | awk -F',' '{print $2 " " $1}' | sort -u | fzf --no-preview | cut -d' ' -f1
|
||||
;;
|
||||
pf)
|
||||
if [ -n "$currentProject" ]; then
|
||||
find "$currentProject" -type f | fzf
|
||||
fi
|
||||
;;
|
||||
pd)
|
||||
if [ -n "$currentProject" ]; then
|
||||
find "$currentProject" -type d | fzf --no-preview
|
||||
fi
|
||||
;;
|
||||
wl|wordlist)
|
||||
__fsel_wordlist
|
||||
;;
|
||||
snip)
|
||||
snippets
|
||||
;;
|
||||
network-interface|int)
|
||||
ip -o link show | cut -d' ' -f2- | sed -E 's/[^:]+(UP|DOWN).*/\1/' | tr ':' ' ' | fzf --preview="interface=\$(echo {} | cut -f1 -d' ');ip address show \$interface" | cut -d' ' -f1
|
||||
;;
|
||||
*)
|
||||
if command -v "jhcomplete::$comp" > /dev/null; then
|
||||
"jhcomplete::$comp"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
esac
|
||||
}
|
||||
|
||||
jhswap(){
|
||||
local orig="$1"
|
||||
local inside=$(echo "$orig" | grep -Eo '<[^>]+>' | tr -d '<>')
|
||||
local new=$(jhComplete "$inside")
|
||||
echo "${orig/$inside/$new}" | tr -d '<>'
|
||||
}
|
||||
|
||||
on_word_replace(){
|
||||
setopt localoptions noshwordsplit noksh_arrays noposixbuiltins
|
||||
local word="${LBUFFER##* }${RBUFFER%% *}"
|
||||
if [ -n "$word" ]; then
|
||||
local changeto=$(jhswap "$word" )
|
||||
local lastWord="$changeto"
|
||||
local LWORDS=$(echo $LBUFFER | tr ' ' '\n' | wc -l)
|
||||
local RWORDS=$(echo $RBUFFER | tr ' ' '\n' | wc -l)
|
||||
if [ "$LWORDS" -gt "1" ]; then
|
||||
LBUFFER="${LBUFFER% *} $lastWord"
|
||||
else
|
||||
LBUFFER="$lastWord"
|
||||
fi
|
||||
if [ "$RWORDS" -gt "1" ]; then
|
||||
RBUFFER=" ${RBUFFER#* }"
|
||||
else
|
||||
RBUFFER=""
|
||||
fi
|
||||
zle reset-prompt
|
||||
zle -R
|
||||
return 0
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# I want my tab complete to be based on "current" word I am typing sometimes, before the command
|
||||
custom_tabcomplete(){
|
||||
local tokens cmd prefix trigger tail fzf matches lbuf d_cmds
|
||||
export FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS --reverse --height 40%"
|
||||
setopt localoptions noshwordsplit noksh_arrays noposixbuiltins
|
||||
|
||||
if [ -n "$RBUFFER" ]; then
|
||||
if [[ "${RBUFFER[1]}" != " " ]]; then
|
||||
on_word_replace
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# http://zsh.sourceforge.net/FAQ/zshfaq03.html
|
||||
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
|
||||
tokens=(${(z)LBUFFER})
|
||||
if [ ${#tokens} -lt 1 ]; then
|
||||
zle ${fzf_default_completion:-expand-or-complete}
|
||||
return
|
||||
fi
|
||||
cmd=${tokens[1]}
|
||||
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}${append}"
|
||||
zle reset-prompt
|
||||
return $ret
|
||||
return 0
|
||||
fi
|
||||
#local newLBuffer="${tokens:1:${#tokens[@]}-1}"
|
||||
local newLBuffer
|
||||
for i in $(seq 1 $((${#tokens[@]} - 1)) ); do
|
||||
newLBuffer="${newLBuffer}${tokens[i]} "
|
||||
done
|
||||
|
||||
|
||||
if [[ "${LBUFFER[-1]}" == " " ]]; then
|
||||
fzf-completion
|
||||
else
|
||||
local new=$(jhComplete "${tokens[-1]}")
|
||||
if [ -n "$new" ]; then
|
||||
LBUFFER="${newLBuffer}${new} "
|
||||
local ret=$?
|
||||
zle reset-prompt
|
||||
return $ret
|
||||
else
|
||||
fzf-completion
|
||||
fi
|
||||
fi
|
||||
}
|
||||
zle -N custom_tabcomplete
|
||||
bindkey '^I' custom_tabcomplete
|
||||
|
||||
|
||||
|
||||
fi
|
1
shells/zsh/includes/globals.zsh
Normal file
1
shells/zsh/includes/globals.zsh
Normal file
|
@ -0,0 +1 @@
|
|||
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8'
|
12
shells/zsh/includes/lfcd.zsh
Normal file
12
shells/zsh/includes/lfcd.zsh
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Use lf to switch directories and bind it to ctrl-o
|
||||
lfcd () {
|
||||
tmp="$(mktemp)"
|
||||
lf -last-dir-path="$tmp" "$@"
|
||||
if [ -f "$tmp" ]; then
|
||||
dir="$(cat "$tmp")"
|
||||
rm -f "$tmp"
|
||||
[ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
|
||||
fi
|
||||
}
|
||||
alias lf="lfcd"
|
||||
bindkey -s '^o' 'lf\n'
|
140
shells/zsh/includes/promptconfig.zsh
Normal file
140
shells/zsh/includes/promptconfig.zsh
Normal file
|
@ -0,0 +1,140 @@
|
|||
# This is the config I use for Powerlevel9k
|
||||
|
||||
# Custom dir command
|
||||
function my_dir(){
|
||||
homeIcon=""
|
||||
wpPluginsIcon=".p."
|
||||
wpThemesIcon=".t."
|
||||
siteIcon=" "
|
||||
wpSiteIcon=" "
|
||||
magentoSiteIcon=" "
|
||||
dropboxIcon=""
|
||||
seperator=" "
|
||||
seperatorDual=" "
|
||||
root="$seperator"
|
||||
# Gets the path.
|
||||
local current_path="$(print -P "%~")"
|
||||
|
||||
# Replace either ~ or ~/ with
|
||||
current_path=$(echo $current_path | sed -r -e "s/\~/$homeIcon/")
|
||||
|
||||
# Replace wp-content/themes with theme icon if in theme
|
||||
# current_path=$(echo $current_path | sed -r -e "s/wp\-content\/themes/$wpThemesIcon/")
|
||||
|
||||
# Replace wp-content/plugins with plugin icon if in plugin
|
||||
# current_path=$(echo $current_path | sed -r -e "s/wp\-content\/plugins/$wpPluginsIcon/")
|
||||
|
||||
current_project_full="$(project current --path)"
|
||||
if [ -n "$current_project_full" ]; then
|
||||
if echo "$PWD" | grep -q "$current_project_full"; then
|
||||
current_path=$(echo $PWD | sed -r -e "s#$current_project_full##" | sed -r -e 's/^\///')
|
||||
current_path="$current_path"
|
||||
fi
|
||||
fi
|
||||
#
|
||||
#This is used for checking if wp or magento
|
||||
local ph=${PWD%/public_html*}/public_html
|
||||
# If in a site folder and a wp site, replace home/Sites/<site-name>/public_html with siteIcon <site-url>
|
||||
if [[ -d $ph ]]; then
|
||||
local icon=$siteIcon
|
||||
if [[ -e "$ph/wp-config.php" ]]; then #If WordPress
|
||||
icon=$wpSiteIcon
|
||||
|
||||
# Change wp-content in sub folders
|
||||
current_path=$(echo $current_path | sed -r -e "s/wp\-content\//wpc\//")
|
||||
|
||||
if [[ $(tput cols) -lt 100 ]]; then
|
||||
current_path=$(echo $current_path | sed -r -e "s/wpc\/themes\//\//")
|
||||
current_path=$(echo $current_path | sed -r -e "s/wpc\/plugins\//\//")
|
||||
fi
|
||||
|
||||
elif [[ -e "$ph/bin/magento" ]]; then #If magento
|
||||
icon=$magentoSiteIcon
|
||||
fi
|
||||
current_path=$(echo $current_path | sed -r -e "s/$homeIcon\/Sites\/([a-z_\-]*)\/public_html/$icon\1/")
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# Replace Dropbox with icon
|
||||
current_path=$(echo $current_path | sed -r -e "s/$homeIcon\/Dropbox/$dropboxIcon/")
|
||||
|
||||
# Set the root
|
||||
current_path=$(echo $current_path | sed -r -e "s/^\//$root/g")
|
||||
|
||||
# Set the dual seperator
|
||||
current_path=$(echo $current_path | sed -r -e "s/\/\//$seperatorDual/g")
|
||||
|
||||
# Set the seperator
|
||||
current_path=$(echo $current_path | sed -r -e "s/\//$seperator/g")
|
||||
|
||||
# If seperator is at the end, remove it (this should only be the case if in root directory)
|
||||
current_path=$(echo $current_path | sed -r -e "s/$seperator\$//g")
|
||||
|
||||
echo $current_path
|
||||
|
||||
}
|
||||
POWERLEVEL9K_CUSTOM_DIR="my_dir"
|
||||
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
|
||||
POWERLEVEL9K_CUSTOM_DIR_BACKGROUND="green"
|
||||
POWERLEVEL9K_CUSTOM_DIR_FOREGROUND="black"
|
||||
else
|
||||
POWERLEVEL9K_CUSTOM_DIR_BACKGROUND="blue"
|
||||
POWERLEVEL9K_CUSTOM_DIR_FOREGROUND="black"
|
||||
fi
|
||||
|
||||
# POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR="\ue0c0"
|
||||
# POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR="\ue0c2"
|
||||
|
||||
function Capslock(){
|
||||
x=$(xset -q | grep Caps) 2> /dev/null || exit 0
|
||||
x=${x:22:1}
|
||||
if [[ $x == "n" ]]; then
|
||||
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
POWERLEVEL9K_CUSTOM_CAPS="Capslock"
|
||||
POWERLEVEL9K_CUSTOM_CAPS_BACKGROUND="red"
|
||||
POWERLEVEL9K_CUSTOM_CAPS_FOREGROUND="white"
|
||||
|
||||
|
||||
function prompt_project() {
|
||||
local segment_content state icon
|
||||
local parent_process="$(ps -ocommand -p $PPID | grep -v 'COMMAND' | cut -d' ' -f1)"
|
||||
local current_project_full="$(project current --path)"
|
||||
local current_project_name="$(project current)"
|
||||
if [[ "$parent_process" == "/usr/bin/script" ]]; then
|
||||
segment_content="辶"
|
||||
fi
|
||||
# If there is a current project
|
||||
if [ -n "$current_project_name" ]; then
|
||||
segment_content="${segment_content}$current_project_name"
|
||||
# If in the current project
|
||||
if echo "$PWD" | grep -q "$current_project_full"; then
|
||||
state="INSIDE"
|
||||
elif echo "$PWD" | grep -q "$HOME/Projects/"; then
|
||||
state="WRONG"
|
||||
else
|
||||
state="OUTSIDE"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$segment_content" ]; then
|
||||
"$1_prompt_segment" "${0}_${state}" "$2" $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$segment_content" "$icon"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
POWERLEVEL9K_PROJECT_DEFAULT_FOREGROUND="black"
|
||||
POWERLEVEL9K_PROJECT_WRONG_BACKGROUND="red"
|
||||
POWERLEVEL9K_PROJECT_OUTSIDE_BACKGROUND="yellow"
|
||||
POWERLEVEL9K_PROJECT_INSIDE_BACKGROUND="green"
|
||||
|
||||
# Left Prompt
|
||||
if [[ "$(basename "/"$(ps -f -p $(cat /proc/$(echo $$)/stat | cut -d \ -f 4) | tail -1 | sed 's/^.* //'))" != "$(echo $USER)" ]]; then
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(project custom_dir vcs custom_caps)
|
||||
fi
|
||||
|
||||
# Right Prompt
|
||||
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator)
|
12
shells/zsh/includes/rangercd.zsh
Normal file
12
shells/zsh/includes/rangercd.zsh
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Use ranger to switch directories and bind it to ctrl-o
|
||||
rangercd () {
|
||||
tmp="$(mktemp)"
|
||||
ranger --choosedir="$tmp" "$@"
|
||||
if [ -f "$tmp" ]; then
|
||||
dir="$(cat "$tmp")"
|
||||
rm -f "$tmp"
|
||||
[ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
|
||||
fi
|
||||
}
|
||||
alias ranger="rangercd"
|
||||
#bindkey -s '^o' 'ranger\n'
|
13
shells/zsh/includes/shortcuts.zsh
Normal file
13
shells/zsh/includes/shortcuts.zsh
Normal file
|
@ -0,0 +1,13 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
function append_date() {
|
||||
# Prepend "info" to the command line and run it.
|
||||
BUFFER="$BUFFER-$(date '+%Y-%m-%d')"
|
||||
zle end-of-line
|
||||
}
|
||||
|
||||
# Define a widget called "run_info", mapped to our function above.
|
||||
zle -N append_date
|
||||
|
||||
# Bind it to ESC-i.
|
||||
#bindkey "" append_date
|
Loading…
Add table
Add a link
Reference in a new issue