Axel Liljencrantz wrote: > On 10/10/07, Fernando Canizo <[EMAIL PROTECTED]> wrote: >> I just did: >> >> echo 'some handy function definition' > ~/.config/fish/config.fish >> >> Was in a hurry and didn't noticed the '>' instead of '>>', result: >> config gone! > > Ouch. I'm sorry to hear that.
yeah, ouch, more on this at the end since clobbering files is something I wanna discuss in deep. > There is no way to get the exact definition of the config file, but > you can get a listing of all current variable definitions. > > Just use the 'set' command to list currently defined variables. You > can filter the output to only show exported variable using 'set -x' > and so on. You'll have to go over the list manually and remove things > that you sholdn't set yourself, like PATH. What does this mean exactly? What's the issue with PATH? Why shouldn't set it *myself*? I was messing around with PATH and I cannot add my local directories (aka: /usr/local/bin /home/conan/bin) which contains some handy scripts for my day to day work. I can do a 'set -l' but I don't know if that's the right thing to do. > That said, there aren't many situations where the config.fish is the > easiest way to configure fish. The 'right' way to define functions is > a two-step process: You have opened a new path of discovery for me with that, I was using fish like bash, with a big configuration file full of stuff here and there, now I have reduced it to this: $ cat .config/fish/config.fish umask 077 if status --is-interactive command fortune end > This has a few benefits: > * You can try out the function until you get it just right. > * You don't accidentally delete your config file.;-) > * All the other running shells will automatically have access to your > new function. > * If you update the definition of an existing function, all running > shells will automatically reload it when needed. Last two totally worth the money :) >> Q2. Is there some way to emulate this from bash: >> >> set -o noclobber >> >> that set disables '>' to overwrite existing files (and you can bypass it >> also, so is pretty useful) >> >> Possible Request: if there's no way to achieve Q2, what about including >> it in the next fish release? I think that set is in the spirit of fish. > > Unfortunatly, that is not currently possible. I am not a big fan of > configuration options, so I am a bit hesitant about making the way IO > redirections perform be configurable. Indeed, I forgot when I wrote it that another thing in fish philosophy is to try to avoid configurabilititis. So: > I see the value in what you > propose, but if possible I'd rather try to figure out another way to > reach the same goal. First thing I tried was to make it a function, dead end there. So here is what I've thought. When using > there are two possible cases relating to file creation/writing: 1. what to do if file doesn't exists 2. what to do if file exists In the former case solution is simple: create the file and write to it. But in case 2 there are 3 possible courses of action: a. overwrite the file (current default, and default for others shells too) b. append to the file c. refuse to write to the file Now 'a' is what I'm trying to avoid. 'b' can be eliminated from the picture since we already have '>>'. 'c' is what I think should be the default for a shell which claims to be "friendly" and to be consistent with this sentence: "But even well designed, powerful programs sometimes need to be updated to remove some of the old mistakes." :) The only thing left is that sometimes one will really want to truncate a file. In bash this is achieved with this syntax (when noclobber is set): echo "nothing" >| file_to_be_truncated Now the syntax could be anything, it's not important, but it's important to have a way to overcome the default. And voilá, no configuration needed. Just sane defaults. I ask you kindly to give this issue a second thought. Programs should not eliminate your precious data. We, humans, make mistakes. -- Fernando Canizo - http://muriandre.homelinux.org/~conan/ ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Fish-users mailing list Fish-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/fish-users