.bashrc is the primary configuration file for the bash shell.
28
votes
4answers
35k views
How to correctly add a path to PATH?
I'm wondering where a new path has to be added to PATH environment variable. I know this is accomplished editing .bash_rc (for example), but it's not clear how to do this.
This way:
export ...
14
votes
2answers
634 views
.bashrc overwritten but still sourced — how can it be recovered?
Usually when I find a command I want to alias, I echo it to my .bashrc like so:
[up button pressed to last command, then line edited so that it reads]
$echo "command-i-just-did" >> ~/.bashrc
...
10
votes
4answers
582 views
How can I source the bashrc file every time I 'clear'
This might be a bad idea. The more I think about it the more I come to the realization that I probably shouldn't do it... but I've been trying and failing so I REALLY want to know how to do it, even ...
9
votes
5answers
287 views
How to test for possible conflicts while using alias in bashrc?
Is there a simple way to list all the command conflicts that have occurred in the system due to the bashrc update involving alias commands?
For example, someone writes alias ...
8
votes
2answers
1k views
What is the difference between ~/.profile, ~/.bashrc, ~/.bash_profile, ~/.gnomerc, /etc/bash_bashrc, /etc/screenrc …?
Answers to the questions on SO and askubuntu, along with poking through (and reading headers of) $HOME and /etc/, indicate a number of files that can be used to set environment variables, including:
...
7
votes
7answers
635 views
Doing simple math on the command line using bash functions: $1 divided by $2 (using bc perhaps)
Sometimes I need to divide one number by another. It would be great if I could just define a bash function for this. So far, I am forced to use expressions like
echo 'scale=25;65320/670' | bc
but ...
7
votes
3answers
269 views
How can I find a rogue alias declaration?
I'm trying to find where a specific alias has been declared. I've searched all the usual places I know to look for aliases:
~/.bashrc
~/.bash_profile
/etc/bashrc
/etc/profile
With no luck.
I know ...
6
votes
1answer
341 views
How can I change screen's hardstatus color based on the logged in user?
I haven't edited/created a .screenrc file in a while, but this is what I'm currently using:
# Turn off the screen startup message
startup_message off
# Define format of bottom ...
5
votes
2answers
346 views
Can a home directory have both .cshrc and .bashrc files?
Or are they both not allowed at the same time?
5
votes
1answer
539 views
How to detect when a shell is owned by a remote SSH session?
My question is similar to this one, but I'm looking for something slightly different. I have a notebook PC that I use to access Linux machines on a network in two different scenarios:
I have a ...
4
votes
1answer
74 views
View shell function's current definition
So I am editing bashrc constantly, and I have a terminal open with a working function definition, although bashrc has been updated with a wrong function definition. (Because the definition do not ...
4
votes
2answers
2k views
How do I get rid of Cygwin's /cygdrive prefix in all paths?
I'm switching to Cygwin from the bash shell that ships with Git for Windows, and encountering a strange problem. Someone thought it would be a good idea to add /cygdrive/ to all paths, while I think ...
3
votes
1answer
61 views
Keep two bash history files, one with ignoredups, one with everything
For the purposes of looking at which commands I am using the most, I'd like to keep a record of command I type in my bash history (even duplicates).
But, for sanity and ease of use, I still want to ...
3
votes
2answers
187 views
Run ssh login command without modifying remote .bashrc
We have a bunch of servers set up with set -o vi in their ~/.bashrc.
It would be nice to be able to ssh into these boxes and automagically run set -o emacs as a timesave.
I've seen a solution ...
3
votes
1answer
595 views
Problems with automatically starting screen on SSH login
I'm looking at http://taint.org/wk/RemoteLoginAutoScreen to setup my server so it autostarts a screen session when I login via SSH.
I have added the following to my .bashrc:
# Auto-screen ...
2
votes
1answer
166 views
How to make a permanent variable
In terminal:
VAR="Extremely long and often used command"
echo $VAR
Output:
Extremely long and often used command
So far it works fine, but after restarting a terminal my variable doesn't ...
2
votes
3answers
136 views
What is the difference between ./script and . ./script? [duplicate]
Possible Duplicate:
Using ‘.’ to execute files in bash
I was trying to figure out how to export my environmental via script instead of changing my .bashrc file.
I found this old useful ...
2
votes
3answers
132 views
When the lines of a file or directory get too long, upgrade to ls list format?
Is there a way I can do this? For example if a gets a long name like:
i-have-names-that-are-too-long-to-describe/
i-have-names-that-are-too-long-to-describe-2/
...
2
votes
1answer
176 views
Alias in .bashrc doesn't seem to accept an argument [duplicate]
Possible Duplicate:
In Bash, when to alias, when to script, and when to write a function?
I'm trying to setup an alias in my .bashrc file, but it's not working as expected.
I have this ...
2
votes
2answers
93 views
Is there any way I can fit this into my ~/.bashrc as a function?
I just discovered this useful bit of code on this useful-looking website.
#!/bin/sh
exec tclsh "$0" ${1+"$@"}
proc main {} {
set lines [lrange [split [read stdin] \n] 0 end-1]
set count ...
2
votes
3answers
277 views
Added bin directory to my path, can't execute commands in it with 'sudo command'
I made a bin directory in my home folder where I place all my scripts. Then in my .bashrc I added the following:
export PATH=$PATH:/home/myusername/bin
So I could access files I placed in there ...
2
votes
2answers
657 views
Global bash_profile
I realize there are /etc/profile and /etc/bashrc files for setting global environment variables and maybe I'm just misunderstanding their purposes, but...
Is their a global bash_profile file?
This ...
2
votes
1answer
77 views
How to link different (incompatible) libraries at runtime depending on program?
I have a number of legacy codes that need to be compiled with specific (and often conflicting) libraries. To be specific I have a program which can only be compiled with g77 and another program which ...
2
votes
3answers
670 views
Issues with .bash_profile and terminal commands
I added some data to my .bash_profile to run two aliases ruby version 19 and the proper gems. As soon as I added the data I could not longer run any commands such as the MacPorts command port nor the ...
2
votes
0answers
56 views
.bashrc alias not working [closed]
I have set up a few aliases in my .bashrc file, like the following:
alias ras='rails server'
alias res='redis-server'
alias rc='rails console'
alias be='bundle exec'
# git alias's are as follows
...
2
votes
0answers
212 views
Populate PS1 asynchronously
I have a few git svn related functions that see if I have to pull/push from/to the repository.
My problem is that the functions I've wrote to gather these informations are too slow, I'd like to make ...
1
vote
3answers
75 views
In bash, how can I erase an alias without logout? [duplicate]
I had an alias in my .bashrc and I really don't want it anymore. I erased the alias, but my bash already has this alias loaded.
Can I erase this alias from this bash without logging out?
1
vote
2answers
609 views
What is the difference between interactive shells, login shells, non-login shell and their use cases? [duplicate]
Possible Duplicate:
Difference between Login Shell and Non-Login Shell?
I have been looking at /etc/profile. bash.bashrc to see how they are run, and notice that some are executed by ...
1
vote
1answer
102 views
What's the right way to reuse this one-liner?
I recently came up with the following one-liner:
for f in *.mp3; do sha1sum $f | sed -r 's/[a-z]//g' | cut -c1-2 | awk '{ print ($1 >= 255) ? $1 - $1 + (1/3)*$1 : $1 }' | xargs -i id3v2 -T {} $f; ...
1
vote
2answers
1k views
Where is the system profile that gets sourced at login on CentOS 5.8?
In CentOS release 5.8 (Final), where is the bash system profile?
Is it /etc/profile ?
I've added the following to source my ~/.bashrc file but haven't had any luck as it fails. I know it fails ...
1
vote
1answer
195 views
How to colorize “root” in red in CentOS?
This is the content of /etc/bashrc, I would like to modify it for show "root" as red but don't know where to add the color code.
# /etc/bashrc
# System wide functions and aliases
# Environment stuff ...
1
vote
1answer
138 views
execute bash script inside .bashrc
Hi I am curious if it is possible to execute a bash script inside bash rc. It would seem to create a infinite loop unless there was some way to tell it to not try and start a new shell.
Here is an ...
1
vote
0answers
194 views
How to use history commands with readonly PROMPT_COMMAND?
I'm sometimes logged in on a host which I do not control and where PROMPT_COMMAND is readonly. Is there some way to work around this to run history commands anyway, for example using PS1? I've tried ...
0
votes
3answers
164 views
What is the difference between '.' and 'source' in shells? [duplicate]
Possible Duplicate:
running script with “. ” and with “source ”
I have used both the dot command '.' and 'source' to reload a given rc file (typically to update my environment variables) ...
0
votes
2answers
917 views
How to assign user root rights?
I have Suse Linux on my desktop. So I am root and "normal" user.
Frequently e.g. to start tomcat or install/remove a program I should use sudo or switch to super user. But I have defined many aliases ...
0
votes
1answer
747 views
.bashrc doesn't get executed
I have a user (non-root) which has a ~/.bashrc file with some aliases in it.
But it doesn't look like the file is executed at log in time. If I do source ~/.bashrc then it does what it's supposed to. ...
0
votes
1answer
51 views
Is it possible to change shell using bashrc when assigned a nologin default shell?
i have assigned a /sbin/nologin shell to a user while creating that user (specifying -s option in useradd), if this user logs in using SFTP and changes his .bashrc file, will he be able to change his ...
0
votes
1answer
224 views
Login script for bash not loading
I am very confused about the login script for bash. I have always used ~/.bash_profile to configure my bash shell. Now I am on a new system just as a user: I am not root. This system was originally ...
0
votes
1answer
115 views
Bash script for Angstrom
I have written a bash script to automate cross-compiling an OpenCV program:
echo "Compiling started for: $1"
if [[ $1 == *.c ]]
then
gcc -ggdb `pkg-config --cflags opencv` -o `basename $1 .c` $1 ...
0
votes
0answers
134 views
sftp gives an error: “Received message too long” and what is the reason?
I was able to do sftp yesterday to a RHEL 5.4 box (RedHat) and today I can't.
The message is "Received message too long 778199411", and after some investigation, it was due to my RHEL box's .bashrc ...
0
votes
0answers
31 views
Loading my bashrc without sourcing it everytime [duplicate]
Possible Duplicate:
.bashrc doesn't get executed
I have my .bashrc file properly setup but for some reason, when I login into the server, it does not load the custom profile.
...