Results 1 to 10 of 15
Hi All,
I started doing linux recently. Now, I want to run my firefox with playing mplayer simultaneously. For that I did;
1. Added 1 line in /etc/bashrc as :
...
- 02-21-2008 #1
adding environmental variable in bashrc
Hi All,
I started doing linux recently. Now, I want to run my firefox with playing mplayer simultaneously. For that I did;
1. Added 1 line in /etc/bashrc as :
> cat>> bashrc
mybrowse='firefox & mplayer ~/im/Music/Guitar/ *.mp3'
2. then i export the variable as:
> export mybrowse
but, it seems, bash can't find that command. can me help me out where I'm wrong. I'm confused about the part of exporting mostly.
Thanks in advance,
im
- 02-21-2008 #2
You are trying to setup an alias which you should do by editing ~/.bashrc and putting
After that you need to logout of the terminal and back in again for the alias to be recognised. An alternative would be to log into a new terminal.Code:alias mybrowse='firefox && mplayer ~/im/Music/Guitar/ *.mp3'
- 02-21-2008 #3
Thanks a lot daark.child. I got the idea about alias. Now, if I want to this alias to work sysem wide, what I have to do? And, can you kindly give an example of setting environmental variable in /etc/bashrc and when and how to export?
thanks in advance
im
- 02-21-2008 #4
- 02-21-2008 #5
Environmental variables should be placed in /etc/profile or a users ~/.bash_profile. Its as simple as doing something like
If the variable already exists and you just want to append something to it, you can do something likeCode:export VARIABLE=SOMEVAR
As for the alias to be system wide, you can put it in /etc/bashrc (path may differ on some distros).Code:export VARIABLE=$VARIABLE:SOMEVAR
- 02-21-2008 #6Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
Better "exec bash", so the previous bash session is closed and doesn't stay behind wasting your ram.
Well, some distros might have some init files to put this kind of stuff on, but the files for bash should be the same always (unless a given distro patches it, of course).
It's all in the bash man page, but to sum it up:
Bash has many ways to be run: interactive-login, interactive non-login, and non-interactive modes.
The modes we are concerned about are mainly the two interactive modes.
The interactive-login mode if the mode you enter when, let's say, you login into a console (or when you invoke bash --login). In this mode, bash always sources the files /etc/profile. Then, one, and only one of these, is sourced (the first to be found, and in this order):
~/.bash_profile
~/.bash_login
~/.profile
So, beware that, if you have a ~/.bash_profile, all the stuff in ~/.bash_login and ~/.profile will be discarded, even if it's an empty file.
When we use non-login interactive sessions (e.g., when you open an xterm), the only file that is sourced is ~/.bashrc, if you look at the bash man page.
But in my experience, /etc/bash/bashrc is also sourced in this case.
What I do, personally, if to forget about /etc/profile, because on each update of bash it will be overwritten.
You should look if your distro has some init file where to put global stuff. In gentoo it can be into /etc/conf.d/local.{start,stop}
About bash, I just use ~/.bashrc and ~/.bash_profile. One of them is a symlink to the other, so I have assured that my bashrc stuff will run no matter which kind of bash session I am using. There are some quircks that you might need to work around if you find concrete problems (after all, both files are not the same by default for a reason).
- 02-21-2008 #7They should be, but some distros change things e.g. on Debian, there is /etc/bash.bashrc instead of /etc/bashrc like most distros.Well, some distros might have some init files to put this kind of stuff on, but the files for bash should be the same always (unless a given distro patches it, of course).
- 02-21-2008 #8Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
- 02-22-2008 #9
Ok, Now I have plenty of problems that I can't sort out myself. hope you'll bear with and guide me thru, as I deeply need it in my early learning stage. i'll describe what I did and what is the result I got:
1> In ~/.bashrc I added this line:
Now everytime i'm opening a terminal this is coming:mybrowse=firefox & mplayer /home/Imran/Music/ *.mp3;
export mybrowse
2> I typed $PATH in terminal and this is coming:MPlayer 1.0rc2-4.1.2 (C) 2000-2007 MPlayer Team
CPU: Intel(R) Core(TM)2 Duo CPU E4500 @ 2.20GHz (Family: 6, Model: 15, Stepping: 13)
CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing /home/Imran/Music/.
Win32 LoadLibrary failed to load: avisynth.dll, /usr/lib/codecs/avisynth.dll, /usr/lib/win32/avisynth.dll, /usr/local/lib/win32/avisynth.dll
Seek failed
Playing *.mp3.
File not found: '*.mp3'
Failed to open *.mp3.
Then I added bin directory under /home/Imran/. But still the same message is showing.bash: /usr/kerberos/bin:/usr/lib/ccache:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/Imran/bin: No such file or directory
Similarly, I typed $PATH as root doing su -. There this is showing:
Again, I added a directory bin there, but still the same problem. I know there must be some problem with my understanding, but this is so frustating I can't help the grunt.-bash: /usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin: No such file or directory
Kindly show me the way.
im
- 02-22-2008 #10
There is no need to log out and in again when you edit .bashhrc. Just type >source .bashrc< and it rereads the file.
To add an alias you don´ t need to export it. Just:
Then source ~/.bashrc and you're done.Code:alias mybrowse='command_1 command_2 option'
Can't tell an OS by it's GUI


Reply With Quote
