mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-15 23:22:53 +08:00
Add a shellscript function 'save'function' for saving the current definition of a function to file
darcs-hash:20061027225004-ac50b-2454152687ff84deec90e3d938a0288e62dc34e6.gz
This commit is contained in:
parent
561ec7d5f5
commit
09c348bef2
32
share/functions/save_function.fish
Normal file
32
share/functions/save_function.fish
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
function save_function -d (N_ "Save the current definition of all specified functions to file")
|
||||||
|
|
||||||
|
set -l res 0
|
||||||
|
|
||||||
|
set -l configdir ~/.config
|
||||||
|
if set -q XDG_CONFIG_HOME
|
||||||
|
set configdir $XDG_CONFIG_HOME
|
||||||
|
end
|
||||||
|
|
||||||
|
for i in $configdir $configdir/fish $configdir/fish/functions
|
||||||
|
if not test -d
|
||||||
|
if not builtin mkdir $configdir >/dev/null
|
||||||
|
printf (_ "%s: Could not create configuration directory\n") save_function
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for i in $argv
|
||||||
|
if functions -q $i
|
||||||
|
functions $i > $configdir/fish/functions/$i.fish
|
||||||
|
functions -e $i
|
||||||
|
else
|
||||||
|
printf (_ "%s: Unknown function '%s'\n") save_function $i
|
||||||
|
set res 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return $res
|
||||||
|
end
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user