-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathe.fish
42 lines (30 loc) · 901 Bytes
/
e.fish
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
function e -d 'Edit file, searching in a few different places' -w type
if test ( count $argv ) -ne 1
printf "usage: %s filename" (status current-command)
return
end
if test -f $argv[1]
eval $EDITOR $argv[1]
return
end
if not type -q $argv[1]
printf "%s: '%s' not found, or not a file\n" (status current-command) $argv[1]
return
end
switch ( type -t $argv[1] )
case file
if file ( type -p $argv[1] ) | grep text >/dev/null
eval $EDITOR ( type -p $argv[1] )
else
echo "error: '$argv[1]' is not a text file"
end
case function
if test -f $HOME/.config/fish/functions/$argv[1].fish
eval $EDITOR $HOME/.config/fish/functions/$argv[1].fish
else
echo "error: '$argv[1]' not defined in $HOME/.config/fish/functions"
end
case '*'
echo "error: '$argv[1]' not found"
end
end