Skip to content

Instantly share code, notes, and snippets.

@bjeanes
Created September 11, 2009 09:28
Show Gist options
  • Save bjeanes/185187 to your computer and use it in GitHub Desktop.
Save bjeanes/185187 to your computer and use it in GitHub Desktop.

A bit of regex, a bit of fish, and I get Fish shell method missing for super pastable efficiency!!!

#!/usr/bin/env ruby
# In ~/.config/fish/bin
command = ARGV.shift
case command
when /^git(@|:\/\/).*\.git$/
system("git clone #{command.inspect}")
when /^(?:ftp|https?):\/\/.+\.t(?:ar\.)?gz$/
system("curl #{command.inspect} | tar xzv")
else
$stderr.puts "No default action defined in #{__FILE__.inspect}"
end
# In ~/.config/fish/functions
function method_missing --on-event fish_command_not_found
fish_method_missing.rb $argv
end
# No handler assigned:
bjeanes@cort ~/Code $ > rastienarstein
fish: Unknown command 'rastienarstein'
No default action defined in "/Users/bjeanes/.config/fish/bin/fish_method_missing"
# Git handler
bjeanes@cort ~/Code $ > [email protected]:bjeanes/ghost.git
fish: Unknown command '[email protected]:bjeanes/ghost.git'
Initialized empty Git repository in /Users/bjeanes/Code/ghost/.git/
remote: Counting objects: 300, done.
remote: Compressing objects: 100% (163/163), done.
remote: Total 300 (delta 149), reused 213 (delta 104)
Receiving objects: 100% (300/300), 41.15 KiB, done.
Resolving deltas: 100% (149/149), done.
# tar.gz URL handler
bjeanes@cort ~/Code $ > http://istatd.googlecode.com/files/istatd-0.5.4.tar.gz
fish: Unknown command 'http://istatd.googlecode.com/files/istatd-0.5.4.tar.gz'
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
9 144k 9 14180 0 0 9752 0 0:00:15 0:00:01 0:00:14 10766x istatd-0.5.4/
x istatd-0.5.4/utility.cpp
x istatd-0.5.4/argument.cpp
x istatd-0.5.4/depcomp
x istatd-0.5.4/aclocal.m4
x istatd-0.5.4/isr.h
x istatd-0.5.4/resource/
x istatd-0.5.4/resource/istat.conf
x istatd-0.5.4/resource/Makefile.am
x istatd-0.5.4/resource/Makefile.in
x istatd-0.5.4/resource/istat.conf.5
x istatd-0.5.4/resource/istatd.1
x istatd-0.5.4/configure
x istatd-0.5.4/AUTHORS.txt
x istatd-0.5.4/libfslabel/
x istatd-0.5.4/libfslabel/fslabel.c
x istatd-0.5.4/libfslabel/fslabel.h
x istatd-0.5.4/libfslabel/LICENSE
x istatd-0.5.4/libfslabel/ext.c
x istatd-0.5.4/libfslabel/Makefile.am
x istatd-0.5.4/libfslabel/Makefile.in
x istatd-0.5.4/libfslabel/fsident.c
x istatd-0.5.4/libfslabel/p_fslabel.h
x istatd-0.5.4/configure.ac
x istatd-0.5.4/main.cpp
75 144k 75 108k 0 0 47855 0 0:00:03 0:00:02 0:00:01 50837
x istatd-0.5.4/install-sh
x istatd-0.5.4/clientset.h
x istatd-0.5.4/config.sub
x istatd-0.5.4/missing
x istatd-0.5.4/stats.h
x istatd-0.5.4/clientset.cpp
x istatd-0.5.4/daemon.cpp
x istatd-0.5.4/conf.h
x istatd-0.5.4/conf.cpp
x istatd-0.5.4/avahi.cpp
x istatd-0.5.4/Makefile.am
x istatd-0.5.4/Makefile.in
x istatd-0.5.4/token.h
x istatd-0.5.4/token.cpp
x istatd-0.5.4/main.h
100 144k 100 144k 0 0 62398 0 0:00:02 0:00:02 --:--:-- 66218
x istatd-0.5.4/socket.cpp
x istatd-0.5.4/socketset.cpp
x istatd-0.5.4/probes/
x istatd-0.5.4/probes/kvm.c
x istatd-0.5.4/probes/kstat.c
x istatd-0.5.4/probes/Makefile.am
x istatd-0.5.4/probes/Makefile.in
x istatd-0.5.4/probes/swapctl.c
x istatd-0.5.4/probes/sysctl.c
x istatd-0.5.4/probes/statfs.c
x istatd-0.5.4/probes/procfs.c
x istatd-0.5.4/probes/getloadavg.c
x istatd-0.5.4/socketset.h
x istatd-0.5.4/system.h
x istatd-0.5.4/DEVELOPERS.txt
x istatd-0.5.4/switchboard.cpp
x istatd-0.5.4/argument.h
x istatd-0.5.4/stats.cpp
x istatd-0.5.4/avahi.h
x istatd-0.5.4/CHANGELOG.txt
x istatd-0.5.4/daemon.h
x istatd-0.5.4/switchboard.h
x istatd-0.5.4/isr.cpp
x istatd-0.5.4/utility.h
x istatd-0.5.4/socket.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment