move functions to separate files to enable lazy loading

This commit is contained in:
Rico Ullmann 2016-04-24 16:00:06 +02:00
parent a9a51e7d82
commit b54f7adafc
6 changed files with 73 additions and 77 deletions

View File

@ -1,77 +0,0 @@
function df --description 'df should always be human readable'
command df -h $argv
end
function ds --description 'calculate size of current or a given dir and sort by size'
switch (count $argv)
case 0
du -hsx * .[a-zA-Z0-9_]* 2> /dev/null | \
egrep '^ *[0-9.]*[MG]' | sort -n > /tmp/list
egrep '^ *[0-9.]*M' /tmp/list
egrep '^ *[0-9.]*G' /tmp/list
rm -rf /tmp/list
case 1
du -hx $argv .[a-zA-Z0-9_]* 2> /dev/null | \
egrep '^ *[0-9.]*[MG]' | sort -n > /tmp/list
egrep '^ *[0-9.]*M' /tmp/list
egrep '^ *[0-9.]*G' /tmp/list
rm -rf /tmp/list
case \*
echo "Only none or 1 argument is valid!"
return 1
end
end
function psgrep --description 'show matching processes for $argv'
switch (count $argv)
case 0
echo -e "No argument given!\nDo you expect me to guess what you're looking for?"
return 1
case 1
ps aux | grep $argv | grep -v grep
case \*
echo "Only 1 argument is valid!"
return 1
end
end
function nsgrep --description 'show open ports for $argv'
switch (count $argv)
case 0
echo -e "No argument given!\nDo you expect me to guess what you're looking for?"
return 1
case 1
netstat -tulpen | grep $1 | grep -v grep
case \*
echo "Only 1 argument is valid!"
return 1
end
end
function randpw --description 'generate a password'
switch (count $argv)
case 0
tr -dc 'a-zA-Z0-9_@#%&,;()-' < /dev/urandom | head -c32;echo;
case 1
tr -dc 'a-zA-Z0-9_@#%&,;()-' < /dev/urandom | head -c$argv;echo;
case \*
echo "Only none or 1 argument is valid!"
return 1
end
end

3
functions/df.fish Normal file
View File

@ -0,0 +1,3 @@
function df --description 'df should always be human readable'
command df -h $argv
end

23
functions/ds.fish Normal file
View File

@ -0,0 +1,23 @@
function ds --description 'calculate size of current or a given dir and sort by size'
switch (count $argv)
case 0
du -hsx * .[a-zA-Z0-9_]* 2> /dev/null | \
egrep '^ *[0-9.]*[MG]' | sort -n > /tmp/list
egrep '^ *[0-9.]*M' /tmp/list
egrep '^ *[0-9.]*G' /tmp/list
rm -rf /tmp/list
case 1
du -hx $argv .[a-zA-Z0-9_]* 2> /dev/null | \
egrep '^ *[0-9.]*[MG]' | sort -n > /tmp/list
egrep '^ *[0-9.]*M' /tmp/list
egrep '^ *[0-9.]*G' /tmp/list
rm -rf /tmp/list
case \*
echo "Only none or 1 argument is valid!"
return 1
end
end

16
functions/nsgrep.fish Normal file
View File

@ -0,0 +1,16 @@
function nsgrep --description 'show open ports for $argv'
switch (count $argv)
case 0
echo -e "No argument given!\nDo you expect me to guess what you're looking for?"
return 1
case 1
netstat -tulpen | grep $1 | grep -v grep
case \*
echo "Only 1 argument is valid!"
return 1
end
end

16
functions/psgrep.fish Normal file
View File

@ -0,0 +1,16 @@
function psgrep --description 'show matching processes for $argv'
switch (count $argv)
case 0
echo -e "No argument given!\nDo you expect me to guess what you're looking for?"
return 1
case 1
ps aux | grep $argv | grep -v grep
case \*
echo "Only 1 argument is valid!"
return 1
end
end

15
functions/randpw.fish Normal file
View File

@ -0,0 +1,15 @@
function randpw --description 'generate a password'
switch (count $argv)
case 0
tr -dc 'a-zA-Z0-9_@#%&,;()-' < /dev/urandom | head -c32;echo;
case 1
tr -dc 'a-zA-Z0-9_@#%&,;()-' < /dev/urandom | head -c$argv;echo;
case \*
echo "Only none or 1 argument is valid!"
return 1
end
end