mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00: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
1 changed files with 32 additions and 0 deletions
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…
Reference in a new issue