mcfly
This commit is contained in:
parent
39bb964dd8
commit
efd9b88838
4 changed files with 144 additions and 125 deletions
|
@ -3,20 +3,26 @@ set -ex
|
|||
|
||||
PATH="$PATH:$HOME/.local/bin"
|
||||
|
||||
if [[ $(whoami) == "root" ]]; then
|
||||
SUDO=""
|
||||
else
|
||||
SUDO="sudo"
|
||||
fi
|
||||
|
||||
if [[ $(command -v ansible) ]]; then
|
||||
printf "ansible already installed\n"
|
||||
elif [[ $(uname) == "Linux" ]]; then
|
||||
if [[ $(command -v pacman) ]]; then
|
||||
sudo pacman -Sy --noconfirm ansible
|
||||
$SUDO pacman -Sy --noconfirm ansible
|
||||
elif [[ $(command -v zypper) ]]; then
|
||||
sudo zypper install -y ansible
|
||||
sudo ln -sf /usr/bin/python3 /usr/bin/python
|
||||
$SUDO zypper install -y ansible
|
||||
$SUDO ln -sf /usr/bin/python3 /usr/bin/python
|
||||
elif [[ $(command -v apt) ]]; then
|
||||
sudo apt install -y ansible python3-apt python-is-python3
|
||||
$SUDO apt install -y ansible python3-apt python-is-python3
|
||||
elif [[ $(command -v dnf) ]]; then
|
||||
sudo dnf install ansible -y
|
||||
$SUDO dnf install ansible -y
|
||||
elif [[ $(command -v emerge) ]]; then
|
||||
sudo emerge ansible
|
||||
$SUDO emerge ansible
|
||||
fi
|
||||
elif [[ $(uname) == "Darwin" ]]; then
|
||||
if [[ ! $(command -v brew) ]]; then
|
||||
|
@ -26,7 +32,7 @@ elif [[ $(uname) == "Darwin" ]]; then
|
|||
/usr/local/bin/brew install ansible
|
||||
fi
|
||||
|
||||
ANSIBLE_PYTHON_INTERPRETER="$(which python)"
|
||||
ANSIBLE_PYTHON_INTERPRETER="$(command -v python)"
|
||||
ansible-galaxy install kewlfft.aur
|
||||
ansible-galaxy collection install community.general
|
||||
ansible-playbook --ask-become-pass -i inventory main.yml
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
---
|
||||
- aur: name=paru
|
||||
- name: Install paru
|
||||
aur: name=paru
|
||||
become: yes
|
||||
become_user: aur_builder
|
||||
|
||||
- aur: name=neovim-nightly
|
||||
- name: Install neovim-nightly
|
||||
aur: name=neovim-nightly
|
||||
become: yes
|
||||
become_user: aur_builder
|
||||
when:
|
||||
- nightly_neovim == true
|
||||
|
||||
- aur: name=mcfly
|
||||
- name: Install mcfly
|
||||
aur: name=mcfly
|
||||
become: yes
|
||||
become_user: aur_builder
|
||||
when:
|
||||
|
|
|
@ -1,118 +1,120 @@
|
|||
#!/usr/bin/env zsh
|
||||
if zmodload zsh/parameter 2>/dev/null && (( ${+options} )); then
|
||||
__skim_key_bindings_options="options=(${(j: :)${(kv)options[@]}})"
|
||||
else
|
||||
() {
|
||||
__skim_key_bindings_options="setopt"
|
||||
local __skim_opt
|
||||
for __skim_opt in "${(@)${(@f)$(set -o)}%% *}"; do
|
||||
if [[ -o "$__skim_opt" ]]; then
|
||||
__skim_key_bindings_options+=" -o $__skim_opt"
|
||||
else
|
||||
__skim_key_bindings_options+=" +o $__skim_opt"
|
||||
fi
|
||||
done
|
||||
}
|
||||
fi
|
||||
|
||||
emulate zsh -o no_aliases
|
||||
|
||||
{
|
||||
|
||||
[[ -o interactive ]] || return 0
|
||||
|
||||
# CTRL-T - Paste the selected file path(s) into the command line
|
||||
__fsel() {
|
||||
local cmd="${SKIM_CTRL_T_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
|
||||
-o -type f -print \
|
||||
-o -type d -print \
|
||||
-o -type l -print 2> /dev/null | cut -b3-"}"
|
||||
setopt localoptions pipefail no_aliases 2> /dev/null
|
||||
REPORTTIME_=$REPORTTIME
|
||||
unset REPORTTIME
|
||||
eval "$cmd" | SKIM_DEFAULT_OPTIONS="--height ${SKIM_TMUX_HEIGHT:-40%} --reverse $SKIM_DEFAULT_OPTIONS $SKIM_CTRL_T_OPTS" $(__skimcmd) -m "$@" | while read item; do
|
||||
echo -n "${(q)item} "
|
||||
done
|
||||
local ret=$?
|
||||
echo
|
||||
REPORTTIME=$REPORTTIME_
|
||||
unset REPORTTIME_
|
||||
return $ret
|
||||
}
|
||||
|
||||
__skimcmd() {
|
||||
[ -n "$TMUX_PANE" ] && { [ "${SKIM_TMUX:-0}" != 0 ] || [ -n "$SKIM_TMUX_OPTS" ]; } &&
|
||||
echo "sk-tmux ${SKIM_TMUX_OPTS:--d${SKIM_TMUX_HEIGHT:-40%}} -- " || echo "sk"
|
||||
}
|
||||
|
||||
skim-file-widget() {
|
||||
LBUFFER="${LBUFFER}$(__fsel)"
|
||||
local ret=$?
|
||||
zle reset-prompt
|
||||
return $ret
|
||||
}
|
||||
zle -N skim-file-widget
|
||||
bindkey '^T' skim-file-widget
|
||||
|
||||
# Ensure precmds are run after cd
|
||||
skim-redraw-prompt() {
|
||||
local precmd
|
||||
for precmd in $precmd_functions; do
|
||||
$precmd
|
||||
done
|
||||
zle reset-prompt
|
||||
}
|
||||
zle -N skim-redraw-prompt
|
||||
|
||||
# ALT-C - cd into the selected directory
|
||||
skim-cd-widget() {
|
||||
local cmd="${SKIM_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
|
||||
-o -type d -print 2> /dev/null | cut -b3-"}"
|
||||
setopt localoptions pipefail no_aliases 2> /dev/null
|
||||
REPORTTIME_=$REPORTTIME
|
||||
unset REPORTTIME
|
||||
local dir="$(eval "$cmd" | SKIM_DEFAULT_OPTIONS="--height ${SKIM_TMUX_HEIGHT:-40%} --reverse $SKIM_DEFAULT_OPTIONS $SKIM_ALT_C_OPTS" $(__skimcmd) --no-multi)"
|
||||
REPORTTIME=$REPORTTIME_
|
||||
unset REPORTTIME_
|
||||
if [[ -z "$dir" ]]; then
|
||||
zle redisplay
|
||||
return 0
|
||||
fi
|
||||
if [ -z "$BUFFER" ]; then
|
||||
BUFFER="cd ${(q)dir}"
|
||||
zle accept-line
|
||||
else
|
||||
print -sr "cd ${(q)dir}"
|
||||
cd "$dir"
|
||||
fi
|
||||
local ret=$?
|
||||
unset dir # ensure this doesn't end up appearing in prompt expansion
|
||||
zle skim-redraw-prompt
|
||||
return $ret
|
||||
}
|
||||
zle -N skim-cd-widget
|
||||
bindkey '\ec' skim-cd-widget
|
||||
|
||||
# CTRL-R - Paste the selected command from history into the command line
|
||||
skim-history-widget() {
|
||||
local selected num
|
||||
setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2> /dev/null
|
||||
selected=( $(fc -rl 1 | perl -ne 'print if !$seen{(/^\s*[0-9]+\**\s+(.*)/, $1)}++' |
|
||||
SKIM_DEFAULT_OPTIONS="--height ${SKIM_TMUX_HEIGHT:-40%} $SKIM_DEFAULT_OPTIONS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $SKIM_CTRL_R_OPTS --query=${(qqq)LBUFFER} --no-multi" $(__skimcmd)) )
|
||||
local ret=$?
|
||||
if [ -n "$selected" ]; then
|
||||
num=$selected[1]
|
||||
if [ -n "$num" ]; then
|
||||
zle vi-fetch-history -n $num
|
||||
if [[ ${MCFLY_USED} != 1 ]]; then
|
||||
if zmodload zsh/parameter 2>/dev/null && (( ${+options} )); then
|
||||
__skim_key_bindings_options="options=(${(j: :)${(kv)options[@]}})"
|
||||
else
|
||||
() {
|
||||
__skim_key_bindings_options="setopt"
|
||||
local __skim_opt
|
||||
for __skim_opt in "${(@)${(@f)$(set -o)}%% *}"; do
|
||||
if [[ -o "$__skim_opt" ]]; then
|
||||
__skim_key_bindings_options+=" -o $__skim_opt"
|
||||
else
|
||||
__skim_key_bindings_options+=" +o $__skim_opt"
|
||||
fi
|
||||
done
|
||||
}
|
||||
fi
|
||||
fi
|
||||
zle reset-prompt
|
||||
return $ret
|
||||
}
|
||||
zle -N skim-history-widget
|
||||
bindkey '^R' skim-history-widget
|
||||
|
||||
} always {
|
||||
eval $__skim_key_bindings_options
|
||||
'unset' '__skim_key_bindings_options'
|
||||
}
|
||||
emulate zsh -o no_aliases
|
||||
|
||||
{
|
||||
|
||||
[[ -o interactive ]] || return 0
|
||||
|
||||
# CTRL-T - Paste the selected file path(s) into the command line
|
||||
__fsel() {
|
||||
local cmd="${SKIM_CTRL_T_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
|
||||
-o -type f -print \
|
||||
-o -type d -print \
|
||||
-o -type l -print 2> /dev/null | cut -b3-"}"
|
||||
setopt localoptions pipefail no_aliases 2> /dev/null
|
||||
REPORTTIME_=$REPORTTIME
|
||||
unset REPORTTIME
|
||||
eval "$cmd" | SKIM_DEFAULT_OPTIONS="--height ${SKIM_TMUX_HEIGHT:-40%} --reverse $SKIM_DEFAULT_OPTIONS $SKIM_CTRL_T_OPTS" $(__skimcmd) -m "$@" | while read item; do
|
||||
echo -n "${(q)item} "
|
||||
done
|
||||
local ret=$?
|
||||
echo
|
||||
REPORTTIME=$REPORTTIME_
|
||||
unset REPORTTIME_
|
||||
return $ret
|
||||
}
|
||||
|
||||
__skimcmd() {
|
||||
[ -n "$TMUX_PANE" ] && { [ "${SKIM_TMUX:-0}" != 0 ] || [ -n "$SKIM_TMUX_OPTS" ]; } &&
|
||||
echo "sk-tmux ${SKIM_TMUX_OPTS:--d${SKIM_TMUX_HEIGHT:-40%}} -- " || echo "sk"
|
||||
}
|
||||
|
||||
skim-file-widget() {
|
||||
LBUFFER="${LBUFFER}$(__fsel)"
|
||||
local ret=$?
|
||||
zle reset-prompt
|
||||
return $ret
|
||||
}
|
||||
zle -N skim-file-widget
|
||||
bindkey '^T' skim-file-widget
|
||||
|
||||
# Ensure precmds are run after cd
|
||||
skim-redraw-prompt() {
|
||||
local precmd
|
||||
for precmd in $precmd_functions; do
|
||||
$precmd
|
||||
done
|
||||
zle reset-prompt
|
||||
}
|
||||
zle -N skim-redraw-prompt
|
||||
|
||||
# ALT-C - cd into the selected directory
|
||||
skim-cd-widget() {
|
||||
local cmd="${SKIM_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
|
||||
-o -type d -print 2> /dev/null | cut -b3-"}"
|
||||
setopt localoptions pipefail no_aliases 2> /dev/null
|
||||
REPORTTIME_=$REPORTTIME
|
||||
unset REPORTTIME
|
||||
local dir="$(eval "$cmd" | SKIM_DEFAULT_OPTIONS="--height ${SKIM_TMUX_HEIGHT:-40%} --reverse $SKIM_DEFAULT_OPTIONS $SKIM_ALT_C_OPTS" $(__skimcmd) --no-multi)"
|
||||
REPORTTIME=$REPORTTIME_
|
||||
unset REPORTTIME_
|
||||
if [[ -z "$dir" ]]; then
|
||||
zle redisplay
|
||||
return 0
|
||||
fi
|
||||
if [ -z "$BUFFER" ]; then
|
||||
BUFFER="cd ${(q)dir}"
|
||||
zle accept-line
|
||||
else
|
||||
print -sr "cd ${(q)dir}"
|
||||
cd "$dir"
|
||||
fi
|
||||
local ret=$?
|
||||
unset dir # ensure this doesn't end up appearing in prompt expansion
|
||||
zle skim-redraw-prompt
|
||||
return $ret
|
||||
}
|
||||
zle -N skim-cd-widget
|
||||
bindkey '\ec' skim-cd-widget
|
||||
|
||||
# CTRL-R - Paste the selected command from history into the command line
|
||||
skim-history-widget() {
|
||||
local selected num
|
||||
setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2> /dev/null
|
||||
selected=( $(fc -rl 1 | perl -ne 'print if !$seen{(/^\s*[0-9]+\**\s+(.*)/, $1)}++' |
|
||||
SKIM_DEFAULT_OPTIONS="--height ${SKIM_TMUX_HEIGHT:-40%} $SKIM_DEFAULT_OPTIONS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $SKIM_CTRL_R_OPTS --query=${(qqq)LBUFFER} --no-multi" $(__skimcmd)) )
|
||||
local ret=$?
|
||||
if [ -n "$selected" ]; then
|
||||
num=$selected[1]
|
||||
if [ -n "$num" ]; then
|
||||
zle vi-fetch-history -n $num
|
||||
fi
|
||||
fi
|
||||
zle reset-prompt
|
||||
return $ret
|
||||
}
|
||||
zle -N skim-history-widget
|
||||
bindkey '^R' skim-history-widget
|
||||
|
||||
} always {
|
||||
eval $__skim_key_bindings_options
|
||||
'unset' '__skim_key_bindings_options'
|
||||
}
|
||||
fi
|
||||
|
|
|
@ -135,6 +135,14 @@ if [[ -d $HOME/.anyenv ]]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
if [[ $(whence -p mcfly 2> /dev/null) ]]; then
|
||||
znap eval mcfly 'mcfly init zsh'
|
||||
export MCFLY_KEY_SCHEME=vim
|
||||
export MCFLY_FUZZY=true
|
||||
export MCFLY_RESULTS=50
|
||||
export MCFLY_USED=1
|
||||
fi
|
||||
|
||||
path+=($(yarn global bin))
|
||||
export PATH
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue