bjeanes (owner)

Revisions

gist: 185187 Download_button fork
public
Public Clone URL: git://gist.github.com/185187.git
Embed All Files: show embed
_SWEEEEEET.md #

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

fish_method_missing.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/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
method_missing.fish #
1
2
3
4
5
# In ~/.config/fish/functions
function method_missing --on-event fish_command_not_found
fish_method_missing.rb $argv
end
 
result.txt #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# 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 $ > git@github.com:bjeanes/ghost.git
fish: Unknown command 'git@github.com: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