Last active
May 9, 2017 05:12
-
-
Save matsu-chara/cb7c3eb81ffd909e922db39e87fec873 to your computer and use it in GitHub Desktop.
abbr on pipe position for fish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# basically from http://qiita.com/masa0x80/items/346b4b9c0ff08205995e | |
function __insert_abbreviation | |
commandline | read -l buffer | |
switch (string trim -r $buffer | string split ' ')[-1] | |
case G | |
string replace "G" "| grep" $buffer | read replaced | |
case X | |
string replace "X" "| xargs -I {}" $buffer | read replaced | |
case H | |
string replace "H" "| head" $buffer | read replaced | |
case T | |
string replace "T" "| tail" $buffer | read replaced | |
case J | |
string replace "J" "| jq '.'" $buffer | read replaced | |
case S | |
string replace "H" "| show_n 1" $buffer | read replaced | |
case SO | |
string replace "SO" "| sort -n" $buffer | read replaced | |
case SED | |
string replace "SED" "| sed -e 's/" $buffer | read replaced | |
case C | |
string replace "C" "| cut -d ' ' -f 1" $buffer | read replaced | |
case P | |
string replace "P" "| pbcopy" $buffer | read replaced | |
case W | |
string replace "W" "| wc" $buffer | read replaced | |
case A | |
string replace "A" "| awk -F ' ' '{print $1;}" $buffer | read replaced | |
case L | |
string replace "L" "| less" $buffer | read replaced | |
case EDN | |
string replace "EDN" "2>&1 > /dev/null" $buffer | read replaced | |
case DN | |
string replace "DN" "> /dev/null" $buffer | read replaced | |
case '*' | |
# noop | |
end | |
if [ -n "$replaced" ] | |
commandline --replace "$replaced " | |
else | |
commandline --insert " " | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in
.config/fish/config.fish