.bashrc in Cygwin 1.7 - cygwin

I'm running Cygwin 1.7.17 on Windows Server 2012. My user account is "Administrator". Where should I put a .bashrc file for the Cygwin bash to pick it up?
I've tried the "c:\users\Administrator" folder, which seems to be the HOME in Cygwin 1.7. Tryed c:\cygwin\home\Administrator also.

Start a shell instance and run the command echo $HOME to see what your home path is set to. That's where all your user config files will be read from. It might not be one of the paths you tried.
Once you know where it is, just copy the template .bash_profile and .bashrc files from the /etc/skel folder to get you started.
If you don't like the path that's currently being used as your home, you can change it by editing /etc/passwd. Here's more info on that... Safely change home directory

Related

location for application text file not in home directory

I use linux. I'm working on a project where an app I wrote is launched by my runlauncher. At that time the app looks for an environment variable on the sytem. This environment variable contains a path to a text json file. I want to put this file somewhere on the sytem, not in the home directory. Where would be the appropriate place?
The environment variable is GOOGLE_APPLICATION_CREDENTIALS. The app is a flatpak app.
TLDR: Where do I put things on the system that I can read from my application that are not in the home directory?
On Linux, you need super-user rights (or sudo) if you want to write file outside $HOME directory. If you have only user right, then only $HOME directory is writable.

Adding a permanent value to $PATH on Raspbian

I am quite new to Linux so I'm sorry for my newbie question,
but for about and hour now I'm trying to add Node.js to $PATH with no luck :(
I've used the following line to add Node
PATH=$PATH:node-v0.10.24-linux-arm-armv6j-vfp-hard/bin
it worked, but when I logged off the terminal and logged in again, the path disappeared.
Later I tried adding the same line to .profile , .logins.defs and .bashrc.
All didn't work so I removed the line.
Please help me with this!
P.S , when I added the line to .profile I was able to call Node, but when I changed my directory in order to navigate to a Node project directory, I received the following error:
-bash: node-v0.10.24-linux-arm-armv6j-vfp-hard/bin/node: No such file or directory
You should add an absolute path, not a relative one. You added this to your path: node-v0.10.24-linux-arm-armv6j-vfp-hard/bin. That's a relative path, not an absolute one (absolute paths start with a /). You can change your line to:
PATH=$PATH:DIR/node-v0.10.24-linux-arm-armv6j-vfp-hard/bin
where DIR is the full path of the directory containing node-v0.10.24-linux-arm-armv6j-vfp-hard.
It's probably a good idea for you to read a bit on how this all works - it's not that complicated once you see it explained. See https://superuser.com/questions/238987/how-does-unix-search-for-executable-files for an example.
You have $HOME already set to your home directory.
So you can use this in your .profile:
PATH="$PATH:$HOME:$HOME/bin:$HOME/node-v0.10.24-linux-arm-ar‌​mv6j-vfp-hard/bin"
If you set it as an absolute path you will not be able to copy that .profile to another user who is set up similarly.
I see there is another question that deals with installing node.js on Debian - and must admit I am surprised it is installed per-user. So if you do the install for another login you might want to copy your .profile to the new login to solve this same issue. There would be no per-user editing required if you use the $HOME variable like this. Just a simple copy or cut and paste.
For reference, here is that other question/answer: install node.js on debian

Trying to load .bashrc config file locally

I'd like to create a .bashrc file in my Git Repo which should then be shared with other devs. The goals here is to add project-based aliases for every dev.
For instance when using node.js tools, a lot of them check the current directory for configuration files (ex: grunt looks for Gruntfile.js, JSHint looks for .jshintrc, npm for package.json).
I want Cygwin to look after .bashrc in the local directory.
I don't want to change the $HOME variable since it would allow me to only work on one project at a time.
I fixed the issue with aliasas
Run touch .bash_profile command
change file to contain all aliases. Example:
file .bash_profile
alias ga='git add --all .'
alias gp='git push'
Every time you open the Bash, type . .bash_profile to reload the file and therefore register the aliases.

Why can't I see paths that exist in OSX?

I am a windows developer switching over to OSX. I am very confused though. I am learning node.js and the documentation tells me to add a reference to nodemon at the path...
/usr/local/bin/nodemon
However when I am at the terminal and I type 'ls' I get the following output...
And that doesn't have a /usr/ folder ... And what is even more confusing is that if I do...
ls -a
Then I can see all my hidden folder with a folder in called .npm which seems to have all my modules. In windows this is easy it just installs all npm modules into %AppData%/npm or something but I just don't get it on OSX can somebody enlighten me please?
ls lists the directories and files in your current working directory.
You can find your current working directory with pwd (short for 'print working directory')
You can change your current working directory with the cd (change directory) command. In your case, you could run
cd /usr/local
ls
and it would show you the bin directory. Alternatively, you could directly run
ls /usr/local
As a special extra note, the Terminal Prompt itself actually displays the current working directory (by default). In your case, it shows ~, which is shorthand for the user profile directory, which the Terminal opens to automatically. It is generally /Users/<username>.

Setting Working Directory to Desktop in Cygwin

The current directory on cygwin is home/myuser. I navigated to cygwin and found it has a directory called home/myuser and could not figure out how I would navigate to the desktop. I did not want to add a desktop directory there and I could not navigate above the root folder (cygwin). Any idea on how I could do this?
This is essentially covered in the Cygwin FAQ under "How can I access other drives?". No, you're not trying to access another drive, but you are trying to access a folder outside of the Cygwin tree. As the FAQ item says, Cygwin maps your Windows drives as /cygdrive/<drive-letter>, so your desktop is likely something like /cygdrive/c/Users/<username>/Desktop. Note that the path has changed over the years with various versions of Windows and you didn't specify what version you're running, so it may not be exactly that.
Anyway, what I would do, would be to create a symbolic link to that from my Cygwin home folder. Something like this:
ln -s "/cygdrive/c/Users/<username>/Desktop" Desktop
I put the quotes in because depending on what version of windows you have, this path may include spaces.
You'll probably notice from the FAQ that the Cygwin version of bash accepts DOS-style pathnames, so you can actually do the following:
cd "C:/Users/<username>/Desktop"
But I recommend avoiding such syntax. Not all Cygwin apps understand DOS-style paths, and you'll only end up confusing yourself if you have to try to figure out whether what you're doing will work with a DOS-style path or not. It's best to just use the Unix-style paths for everything when in the Cygwin environment, unless you have a very good reason not to.
Add
cd "/cygdrive/c/Users/<username>/Desktop"
to .bashrc file located in <cygwin install directory>/home/<username>. This will change working directory to desktop every time you open Cygwin terminal.

Resources