bashrc

Detect OS from a bash script

I would like to keep my .bashrc and .bash_login files in version control so that I can use them between all the computers I use. The problem is I have some OS specific aliases so I was looking for a way to determine if the script is running on OS X, Linux or Cygwin. What is the proper way to detect the operating system in a bash script...

What's the difference between .bashrc, .bash_profile, and .environment?

I've used a number of different *nix-based systems of the years, and it seems like every flavor of Bash I use has a different algorithm for deciding which startup scripts to run. For the purposes of tasks like setting up environment variables and aliases and printing startup messages (e.g. MOTDs), which startup script is the appropriate...

xargs doesn't recognize bash aliases

I'm trying to run the following command: find . -iname '.#*' -print0 | xargs -0 -L 1 foobar where "foobar" is an alias or function defined in my .bashrc file (in my case, it's a function that takes one parameter). Apparently xargs doesn't recognize these as things it can run. Is there a clever way to remedy this? ...

Executing own Unix command in terminal?

I made an Unix command, macmac2unix, which converts Mac's Word file for Unix platforms. I would like to run the command as $macmac2unix file1 file2 file3 ... Problem: How can I run this command in every path? I added the following to .bashrc unsuccessfully CDPATH=:/Users/Sam/Documents/Unix ...

Unable to put TERM to .bashrc in Mac

Stevey recommends to set the following command to .bashrc TERM=xterm-256color I put the code to the top of my .bashrc and I have now a flashing black green terminal. The font color in my terminal switches from black to green and vice versa periodically. What did I do wrong? ...

How can you export your .bashrc to .zshrc?

I am trying to move to zsh from Bash. I put my .bashrc directly to my .zshrc, and it caused a lot of errors when I try to use Bash again. How can you export your .bashrc to .zshrc? ...

.bashrc at ssh login

When I ssh into my ubuntu-box running Hardy 8.04, the environment variables in my .bashrc are not set. If I do a source .bashrc, the variables are properly set, and all is well. How come .bashrc isn't run at login? ...

Creating a .bashrc function to search through all files for a particular string

I have a useful little command that searches through all files & subdirectories for a particular string: find . -name "*" -exec grep -il "search term" {} \; I'd like to turn this into a function that I can put in my .bashrc and call from my shell without needing to remember the whole thing, but I can't get it working. This is what I h...

Hide a bash function internals..

Hi, My .bashrc looks something like this... export PERL5LIB="/tools/perl/Linux/${PLAT}/lib/perl5/5.10.0/${PLAT}-thread-multi" export PERL5LIB="${PERL5LIB}:/tools/perl/Linux/${PLAT}/lib/perl5/5.10.0" function dev { export PERL5LIB="/dev/tools/perl/Linux/${PLAT}/lib/perl5/5.10.0/${PLAT}-thread-multi" export PERL5LIB="${PERL5LIB...

commands from .bashrc not available in emacs

I have some aliases and functions defined in ~/.bashrc. I start emacs from a terminal window using emacs -nw When I execute M-x shell-command, the aliases and functions from ~/.bashrc are not available, but give a "command not found". I've googled quite a bit but all the posts I come across say, if I understand them correctly, that...

How can I detect that emacs-server is running from a shell prompt?

I want to have my .bashrc detect if running emacsclient would work in lieu of running emacs. Basically: if emacs_server_is_running; then EDITOR=emacsclient VISUAL=emacsclient else EDITOR=emacs VISUAL=emacs fi What would I put in the emacs_server_is_running function to accomplish this aim? ...

Bash PWD Shortening

I'm looking for a bash function that will shorten long path names to keep my PS1 variable from getting excessively long. Something along the lines of: /this/is/the/path/to/a/really/long/directory/i/would/like/shortened might end up as: /t../i../t../p../to/a/r../l../d../i/w../like/shortened something that the took the path and a ma...

How to set environment variable for everyone under my linux system?

Can I have certain settings that are universal for all my users? ...

Tell if a user has SUed in a shell script?

I have a script which executes a git-pull when I log in. The problem is, if I su to a different user and preserve my environment with an su -lp, the script gets run again and usually gets messed up for various reasons because I'm the wrong user. Is there a way to determine in a shell script whether or not I'm currently SUing? I'm looking...

want to set an ls alias, to take parameters

i have the following alias set in my .bashrc: alias la='ls -laG' but i would really like to issue a command thusly: la foo/bar i guess i have to write a shell script? or is there some xargs way? ...

BASH: How do you "split" the date command?

Cygwin user here (though if there's a suitable solution I will carry it over to K/Ubuntu, which I also use). I have a Welcome message in my .bashrc that looks like the following: SAD=(`date +%A-%B-%d-%Y`) DUB=(`date -u +%k:%M`) printf "Today's Date is: ${SAD}.\n" printf "Dublin time is now ${DUB}. (24-Hour Clock)\n" After numerous at...

Bash PS1 settings - how to get the current folder back as the terminal title

Hi all. I recently added these lines to my ~/.bashrc file to show the current branch if i'm in a git working folder, and it works nicely for that. However, what i've lost is that the current folder name used to be shown in the tab for the terminal i have open, and now it isn't: it always just says 'Terminal'. Can i get that back and s...

bash_completion not working, source command not found.

I recently inherited a Ubuntu Hardy box that acts rather funky out-of-the-box. The first things I tried to do was edit my .bashrc profile to do some coloring and add some aliases I usually have, but then when I try to source the ~/.bashrc I get sh: source: not found and I have also noticed tabbed autocomplete is also not working at all -...

Anyone know of a Snippet or File Repository Application in PHP?

I am looking to start a community based on user posted scripts such as bashrc, screenrc, aliases, etc. Does anyone know of a web application in PHP that would do that? I am not looking for a snippet program, or a link directory. Users can store linux/UNIX/Windows configuration files, as well as maybe an option to attach a screenshot....

How can I get and use a user's TZ setting from their .bashrc in a Perl CGI script?

Each of my users has a (possibly) different TZ defined in their .bashrc. I have a Perl script that displays date/time and want it to have it display with their profile time zone. Does anyone know the best way to do this? ...