Last active
February 1, 2019 03:34
-
-
Save Wintus/7a2bb056753c8fc12f3fa583969cd162 to your computer and use it in GitHub Desktop.
Fish functions
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
# Defined in - @ line 0 | |
function arg --description 'alias arg xargs -n 1' | |
xargs -n 1 $argv; | |
end |
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
function cdf --description 'cd to dir on Finder window' | |
set -l target (osascript -e 'tell application "Finder" to if (count of Finder windows) > 0 then get POSIX path of (target of front Finder window as text)') | |
if test -n $target | |
cd "$target" | |
pwd | |
else | |
echo "No finder window found" ^&2 | |
end | |
end |
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
function cmdranking --description 'Show command history ordered by frequency' | |
history | awk '{print $1}' | sort | uniq -c | sort -nr | |
end |
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
function compws --description 'Trim out spaces and squeeze spaces in-between' | |
echo $argv | awk '{$1=$1;print}' | |
end |
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
function fish_prompt | |
echo "" | |
echo -n "[" | |
set_color blue | |
echo -n (date "+%m/%d-%T") | |
set_color normal | |
echo -n "] " | |
set_color cyan | |
echo -n (whoami) | |
set_color normal | |
echo -n ": " | |
set_color brown | |
echo (prompt_pwd) | |
set_color green | |
echo -n " ><(((*> " | |
set_color normal | |
end |
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
function dicuse --description 'Look up usages of a word from EJJE dic' | |
set --local head "用例" | |
w3m -dump -cols 200 "http://ejje.weblio.jp/content/$argv" \ | |
| grep "$head" \ | |
| sed -E -e 's/\[.+MorePl\]//' -e "s/^.*$head +//" \ | |
| grep -E --color=always "\b$argv" \ | |
| nl | |
end | |
alias dic 'dicuse' |
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
# Defined in /var/folders/_w/m31lypps4bv10q598fdcgcnm0000gn/T//fish.lBf6wB/double-quote.fish @ line 2 | |
function double-quote | |
echo '"'$argv'"' | |
end |
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
# Defined in - @ line 0 | |
function e --description 'alias e emacsclient --alternate-editor /usr/local/bin/vim -c' | |
emacsclient --alternate-editor /usr/local/bin/vim -c $argv & | |
end |
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
# Defined in /var/folders/_w/m31lypps4bv10q598fdcgcnm0000gn/T//fish.MEtOhZ/each.fish @ line 2 | |
function each | |
fmt -1 $argv | |
end |
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
function err --description 'Print string into STDERR' | |
echo "["(date +%FT%T%z)"]: $argv" ^&2 | |
end |
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
function f | |
open . | |
end |
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
# Defined in - @ line 0 | |
function g --description 'alias g cd (ghq root)/(ghq list | peco)' | |
cd (ghq root)/(ghq list | peco) $argv; | |
end |
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
# Wrap git automatically by adding the following to ~/.config/fish/functions/git.fish: | |
function git --description 'Alias for hub, which wraps git to provide extra functionality with GitHub.' | |
hub $argv | |
end |
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
function h | |
cd ~ $argv; | |
end |
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
function highlight --description 'highlight <pattern> <file>' | |
# set p $argv[1] | |
# set --erase $argv[1] | |
grep --color -E "\$|$argv[1]" $argv[2..-1] | |
end |
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
function isodate | |
date -I $argv; | |
end |
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
function l | |
ls $argv; | |
end |
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
# Defined in - @ line 0 | |
function lesf --description 'alias lesf less +F -R' | |
less +F -R $argv; | |
end |
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
# Defined in /var/folders/_w/m31lypps4bv10q598fdcgcnm0000gn/T//fish.GwYDvG/ll.fish @ line 2 | |
function ll --description 'alias ll exa -lh --git --time-style iso' | |
exa -Falh --git --time-style iso $argv; | |
end |
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
function maze | |
command maze --format color --interactive $argv; | |
end |
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
function peco-lscd --description 'peco the current directory and cd to the selection' | |
set -l dir (find (pwd) -maxdepth 1 -type d | sed -e 's|\./||' | peco) | |
if test -n dir | |
cd "$dir" | |
end | |
end |
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
function ppjson | |
python -c 'import sys,json;print json.dumps(json.loads(sys.stdin.read()),indent=4,ensure_ascii=False)' $argv; | |
end |
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
function rand | |
od -A n -t u4 -N 4 /dev/urandom | tr -d "[:blank:]" $argv; | |
end |
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
function relogin | |
exec fish -l | |
end |
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
function repeat --description 'repeat command. arg: number command' | |
set -l n $argv[1] | |
for i in (seq $n) | |
eval $argv[2..-1] | |
end | |
end |
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
function sha1 --description 'Encode by sha1' | |
echo $argv | shasum | perl -pe "s|^\s*(\w+)\s+.*\$|\$1|" | |
end |
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
function tmp --description 'alias tmp cd (mktemp -d)' | |
cd (mktemp -d) $argv; | |
end |
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
function tmpfile --description 'create temp file with extension' | |
set -lx ext $argv[1] | |
set -lx filename (mktemp -q) | |
mv $filename{,.$ext} | |
echo $filename.$ext | |
end |
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
function up --description "go up n directories" | |
cd (ruby -e 'n = ($*.first || 1).to_i; path = %(../) * n; puts path' $argv); | |
end |
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
# Defined in - @ line 0 | |
function urldecode --description 'alias urldecode nkf -w --url-input' | |
nkf -w --url-input $argv; | |
end |
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
# Defined in /var/folders/_w/m31lypps4bv10q598fdcgcnm0000gn/T//fish.uba9Pm/urlencode.fish @ line 2 | |
function urlencode --description url-encode | |
echo $argv | nkf -WwMQ | tr '=' '%' | |
end |
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
function vulnerablility | |
env x="() { :;}; echo this bash is vulnerable" bash -c : $argv; | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
dicuse
may be rewritable by scrapy?https://scrapy.org/