Find: Parameter format not correct - cygwin

I keep hearing this is a path issue with cygwin. It is prevent emacs from working within my cygwin. When I execute find on the cli (not bash/cygwin) I get the same error not matter what I type. I've read this is a problem with path creation within cygwin and that it should be prepending itself to the path. As you can see it is doing that.
Here is my /etc/profile
PATH=/usr/local/bin:/usr/bin:/bin:$PATH
export PATH

Problem is that as everyone else stated, emacs is using find.exe provided by windows. To change this, you need to change your %userprofile%.emacs file.
As nobody else states (even faq!), this file is not created automatically anymore. Go into Options > Save options the mini-buffer (one line at the bottom of emacs) will tell you where the file is being written to.
Go in there and add this line (You've installed cygwin at c:\cygwin, right?):
(setq find-program "C:\\cygwin\\bin\\find.exe")
You may need to restart Emacs for this to take effect.

Just add this line to you .profile
alias find='/cygdrive/c/cygwin/bin/find.exe'

Oddly-enough, I needed to use
(setq find-program "/bin/find.exe")
instead.
But thanks for the suggestion Drew.

Adding a setq find-program [msys2 or git path] in my init file, as suggested (I tried different forms), didn't work for me. "C:\Windows\System32\find.exe" is first in the path if I type where find in eshell and I didn't find how to remove it, only how to add others, which doesn't solve the problem.
So I share here the more radical, but working (also in Powershell), solution I used: replacing the find.exe in "C:\Windows\System32" with the one from "C:\msys64\usr\bin". I kept the old file in case, but so far so good. You need to change the permissions for this operation (see here how to gain full control, but I suggest only applying this to the file, not the whole folder, and putting things back after ;)).

Related

Unable to add files and directories to PATH

I have a program, let's call it exampleProg, in my /opt directory, and I want to run it from any directory, rather than just:
/opt/radFolder/exampleProg
This should be a simple task, I've done it several times before on different computers. I've searched around, and found instructions ranging from:
edit .bash
edit .bashrc
edit .profile (Another stackoverflow answer said that, while this worked at one time, it no longer functions.)
edit /etc/environment/
with PATH="$HOME/bin:$PATH:/opt/radFolder/:" or just adding the /opt/radFolder bit.
Yet none of them seem to work. The problem that I'm running into is that there doesn't seem to be a yet there doesn't seem to be a universally agreed-upon solution. I've tried so many that I think one of my changes has prevented the appropriate one from taking effect. Would someone help me put this to rest once and for all? Many thanks in advance.
I'm running ubuntu 14.04 LTS x64.
First, understand that writing things to those files does not mean everything is instantaneously, and globally, changed. In fact, nothing is changed until the file is sourced (via . or source), and even then, the environment changes apply only to the current shell (and subsequent created children, if export is used).
INVOCATION, near the top of man bash, spells out which files are automatically sourced when. To summarize:
~/.bashrc is read for new non-login, interactive shells, e.g., when you open a GUI terminal. On many systems, this file by default in turn sources /etc/bashrc.
/etc/profile, ~/.bash_profile, and ~/.profile are read by interactive login shells.
Adding to ~/.bashrc should be effective, but it will only work for subsequently invoked, interactive, non-login shells (and their children, if $PATH is exported). However, since it's prone to being sourced repeatedly, using it to add to an existing variable (as with $PATH) can produce repeated concatenations (see here).
An issue with the second category, .profile, is that if you use a GUI login, the display manager may not source it, but it logs you in, meaning, you never invoke a login shell and hence none of those is ever sourced. If this is the case, sourcing them from ~/.xsession should work (this has a system wide correlate in /etc/X11).

gnuplot initialization in Windows 7

I want gnuplot to load an initialization file on startup. According to the manual, in Windows systems, it is called GNUPLOT.INI. (It shouldn't matter if I call it gnuplot.ini, right? I tried both, though.)
According to answers like here: gnuplot configuration file
I'm supposed to put a file called gnuplot.ini in my HOME directory, and then everything should work. (Alternatively, see the manual at http://www.gnuplot.info/docs_4.6/gnuplot.pdf, page 38.)
1) What is a "HOME" directory in Windows? Where is it in Windows 7?
2) The manual mentions that I could change this default directory by changing the environment variable GNUPLOT. But it doesn't explain how to change environment variables in gnuplot, or even really what they are.
Basically, everyone refers me to the section in the manual, which I don't understand.
Furthermore, also from the manual: "When gnuplot is run, it first looks for a system-wide initialization file named gnuplotrc. The location of this file is determined when the program is built and is reported by show loadpath."
If I run "show loadpath" in gnuplot, it says:
"loadpath from GNUPLOT_LIB is "C:\Program Files (x86)\gnuplot\demo"
gnuplotrc is read from share"
1) There is no file called gnuplotrc in that folder.
2) No file ending is specified. Does the manual refer to x.gnuplotrc or gnuplotrc.x or something else?
3) Also, what does "read from share" mean?
I appreciate your help.
I finally managed to solve the problem above. Maybe this solution can help someone else. So:
1) The HOME directory of your OS can be found here: http://en.wikipedia.org/wiki/Home_directory.
2) Even after putting a file called gnuplot.ini into my HOME directory, gnuplot didn't consistently initialize with it. In fact, it only did it once, and I still don't know why.
3) The cryptic message "gnuplotrc is read from share" actually means that gnuplot searches for the initialization file "gnuplotrc" (without file ending) in the folder (install directory of gnuplot) \ share .
4) Placing the file called "gnuplotrc" into the folder (install directory of gnuplot) \share\ finally worked. Now gnuplot initializes from this file every time I restart gnuplot.
An update:
Other non-Linux users may be as unaware of what the "home directory" of an OS is as myself. Wikipedia finally gave me the answer here: http://en.wikipedia.org/wiki/Home_directory
So the Home directory in Windows 7 was (root) \Users\ (username).
Then I placed my gnuplot.ini in that folder, and when I started wgnuplot.exe and typed "plot sin(x)", it finally had the settings I wanted.
I thought I had finally solved my problem. I closed gnuplot. Then I changed a line in gnuplot.ini, saved it, and afterwards started gnuplot again. gnuplot was wholly unaffected by my change in gnuplot.ini. (I verified this with the option "show all".)
So as far as I can tell, I managed to correctly initialize gnuplot ONCE, but it doesn't properly intialize via gnuplot.ini every time?! What gives?
On windows, add the following line at the end of gnuplotrc:
load "C:\\Users\\username\\GNUPLOT.INI"
(replacing "username" with your user name, and with doubled backslashes !)
then you can put your GNUPLOT.INI file in your home directory

How to specify customized emacs configuration file rather than "~/.emacs"?

I just want emacs to load another file as the configuration file, and ignore the default file ("~/.emacs").
Note that I don't want to change the original "~/.emacs" file.
I've tried to change "$HOME" env variable, but it doesn't work.
(Platform is Linux.)
emacs --no-init-file --load=some-other-config.el
Or with short options:
emacs -q -l some-other-config.el
From the Emacs manual, section 48.4:
Emacs looks for your init file using the filenames ‘~/.emacs’, ‘~/.emacs.el’, or ‘~/.emacs.d/init.el’ you can choose to use any one of these three names […].
If you really want to use another file, you should consider patching Emacs and making a custom build. It looks like lisp/startup.el:1009 is a good place to start.
As far as I can see, the only option is to use -u to indicate another user's init file.
As #Benjamin quoted, there are three filenames you can choose. As normally, we choose ~/.emacs.d/init.el to be loaded. That's because, we can simply add more configuration files in this directory and add them all under version control(Git). Be sure ~/.emacs and ~/.emacs.el removed before u choose to use the ~/.emacs.d/init.el.

Easier navigation through filesystem in linux shell (cli)

I often find myself taking a lot of time to navigate through my filesystem when using the linux shell. This generally occurs because the autocompletion of bash only works if you provide the start of the file/dirname. What I often end up in is a lot of 'ls' with 'grep' commands, finally doing a 'cd'.
When you use a GUI based filebrowser (like Nautilus) you can type any part of a file/dirname and it will have matches that it jumps to directly. This makes it a lot easier and faster to navigate.
I wonder if anybody knows any great tools that helps with this problem. I know of the existence of Midnight Commander, though I never really used it for real and I couldn't figure out a direct solution for my problem the first couple of times I tried it. Also it seems not suitable because I want to have my shell's current working directory to be changed so I can do stuff there, instead of being stuck in an external program like Midnight Commander.
Try autojmp
https://github.com/joelthelion/autojump
And following article provides another solution
http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html
You can first use the autocd or autopushd in zsh. You would just have to type the directory you want to go to, without the hassle of typing cd or pushd everytime.
You also have the globing possibility. For example, if I got those file in a directory:
1-a.tar
1-b.tar
c.tar
I can just type
*a.tar
without caring about the beginning of the file.
As a last solution you can always use an alias to the find command with a personalized option.

Opening the header file to a C/C++ source file with vim from multiple directories and multiple extension

First off, I was about to write a long list of if/else statements in vim and realized that 1) there was a better way to do what I was trying to do and 2) SO would be ripe with help on the subject. So! I have a variety of files spread about like
foo/src/file01.C
foo/src/file02.cc
foo/src/file03.c
foo/include/file01.hh
foo/include/file02.h
foo/include/file03.h
If you notice that the C/H, cc/hh, c/h extension may or may not match then you are keen and I'd like you to please help. I've look at things like the following vim scripts from the Vim wiki for "Easily switch between source and header file" and although I only dumped a few hours into a.vim without success, it doesn't seem that the others would work via the docs on that page. So can anyone help out on how to make this work?
A good lead I had was a quick How to Easily Switch between Header and Source topic, but still couldn't make it work.
I guess what I really want is how to avoid the multiple if statements and use real matching to do what I want. I want to look into another directory and if look for a header file of the same name with any familiar extension if it was a source C/C++ file, or look for a source file of any regular extension if it was a header file. Thanks for your help!
UPDATE: I specifically want to open the file in a new tab. I live on vim tabs!
I recommend using the FSwitch plugin. https://github.com/derekwyatt/vim-fswitch
This does exactly what you need out of the box. It is better than a.vim in more than one way, being a rewrite of the idea behind a.vim.
The link you posted presents it as a solution, too.
I have just installed it to my vim configuration and it does its job well.
Enjoy.
Just to make sure I was using the most current version, I downloaded the latest a.vim script (2.18) and copied it into my ~/.vim/plugin directory.
You can define certain variables in your ~/.vimrc file to get a.vim to recognize alternate file extensions.
To get the files in your example to match their alternates I added the following to my ~/.vimrc:
let g:alternateExtensions_C = "H,hh"
let g:alternateExtensions_hh = "C"
These are global variables that allow you to override what's already defined. You'll have to define
both relationships (they don't work both ways).
You can see what the current mappings are by typing:
:echo g:alternateExtensionsDict
If you need to define other mappings, follow the same pattern. What comes after the underscore is the file extension you're editing. What's in the double quotes is a comma-separated list of alternate extensions.
let g:alternateExtensions_<ext> = "<list,of,alt,ext>"
If you have a different directory structure, you can define what paths to search by overriding the g:alternateSearchPath variable. ../src and ../include are already included by default.
:echo g:alternateSearchPath
To open the alternate file in a new tab:
:AT
By the way, the a.vim script is pretty well documented. You might want to open it up and take a look. I found a setting or two that I didn't know about and I've been using it for years ;o)
I hope that helps.
IMO your best option is to adopt existing scripts to use :tabf instead of :e or whatever the scripts use right now to open the counterpart file. You can also try to make the change configurable and submit it to the script author. (I'm pretty sure many would find the enhancement useful.)
That reminded me of a trick I used very long time ago. Instead of guessing where the corresponding source/header files are, I have used at the top of file special comment containing relative path to the counterpart file. Switching was as simple as finding the special comment, extracting file name and opening it. Problem was similar to yours in that file extensions were not predictable. My rational solution was to stop guessing and denote counterparts explicitly in the source code. (This days I would have probably tried to put the relationship table into an external file with a standard name and look it up in VIM using the upward search.)
Two helpful things
:he 'path'
:he tabfind
So you would do
:set path=../,/usr/include/,/home/buildagent/SDKROOT/mysdk/inc
:tabfind error_codes.h
to open error_codes.h from somewhere exotic without having to specify it. Note how vim globbing is very very flexible, so you might not need mucht
:argadd ./**/*.[h,H] | tab sall
will open all header files under the current directory, regardless of how many levels deep. Be careful running this command on a large tree or with symlinks outside the tree

Resources