...
 
Commits (6)
complete -xc pxm -d "Image" -a "*.{png,jpg,jpeg,psd}"
complete -xc pxm -d "Pixelmator" -a "*.acorn"
function __regex_from_args -d 'Helper to create greedy regular expression from multiple arguments'
set -l options "f/fuzzy"
argparse $options -- $argv
if set -q _flag_fuzzy
printf '.*%s' (echo "$argv"|sed -E 's/ +//g'|sed -E 's/(.)/\1.*/g')
else
echo "$argv" | sed -E 's/ /.*/g'
end
end
function cdd -d 'Choose cd dir from menu (fzf)'
set -l needle (__regex_from_args -f $argv)
set -l target (fd -E .git -H -d 5 -t d | rg $needle'[^/]*$' | fzf -s 20 -1 -0 -q "$argv")
if test "$target" = ""
echo "No match"
return 1
else
cd "$target"
end
end
function fssh --description 'Fuzzy-search powered SSH'
set ansible_path ~/Sources/ansible/samedi
set fssh_cache ~/.ssh/fssh.cache
set -l ansible_path ~/Sources/ansible/samedi
set -l fssh_cache ~/.ssh/fssh.cache
if not test -s $fssh_cache
cd $ansible_path
ansible-inventory --list | jq '.[] | .hosts? | .[]? ' | sort | uniq > $fssh_cache
ansible-inventory --list | jq '.[] | .hosts? | .[]? ' | gsed 's/"//g' | sort | uniq > $fssh_cache
prevd
end
# if no arguments passed, connect
if not count $argv > /dev/null
set argv connect
end
set -l needle (__regex_from_args -f $argv)
set -l target (rg $needle'[^/]*$' $fssh_cache | fzf -s 20 -1 -0 --prompt="ssh > " -q "$argv")
# print & switch all the things!
switch $argv
case cc clear-cache
rm $fssh_cache
echo "Cache cleared!"
case uc update-cache
cd $ansible_path
ansible-inventory --list | jq '.[] | .hosts? | .[]? ' | sort | uniq > $fssh_cache
prevd
case c connect
set -l target (cat $fssh_cache | gsed 's/"//g' | fzf --no-hscroll --ansi +m --prompt="ssh > ")
if not test -s $target
ssh $target
end
case '*'
echo Wrong usage you bastardo\!
if not test -s $target
ssh $target
else
echo "No match"\!
return 1
end
end
function ips -d 'Display all ip addresses for this host'
ifconfig | grep "inet " | awk '{ print $2 }'
echo "External: "(myip)
end
function pxm -d 'Open Pixelmator PRo.app with optional file (completion available)'
open -a Pixelmator\ Pro $argv
end
# Defined in /var/folders/2j/pnxj71tx24g0ct1nb1m5n0s40000gn/T//fish.P7p1D3/quote.fish @ line 1
function quote
curl -s https://api.quotable.io/random | jq -jr '.content, " —— ", .author'
end