Hot answers tagged


Traditionally, when you log into a Unix system, the system would start one program for you. That program is a shell, i.e., a program designed to start other programs. It's a command line shell: you start another program by typing its name. The default shell, a Bourne shell, reads commands from ~/.profile when it is invoked as the login shell. Bash is a ...


Regarding the problem with .bashrc above: On most systems, ~/.bashrc is only used when starting an interactive non-login shell. However, when you start up a new shell it is often an interactive login shell. Since this is a login shell, the .bashrc is ignored. To keep the environment consistent between non-login and login shells, you must source the .bashrc ...


When you open up your Git Bash, you should be in your home directory by default. Now create the .bashrc file (if on Win7 the file should be named .bashrc.). If you're not in the home directory, change into it by typing: cd and pressing Enter. cd, without any other parameters listed after, will always return the home directory. You can create the file ...


So turns out that on Mac OS X Snow Leopard as well as Mac OS X Lion, the file that's loaded is called .profile, not .bashrc. What you want to do is create a file in ~/.profile and call it .profile (if it doesn't already exists). Put whatever information you needed to load with each instance of bash there (Thanks, thepurplepixel). A couple of side notes: ...


From this short article According to the bash man page, .bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells. What is a login or non-login shell? When you login (eg: type username and password) via console, either physically sitting at the machine when booting, or remotely via ssh: ...


bash is probably getting started as a login shell, in which case it doesn't read .bashrc automatically. Instead, it reads .bash_profile. From the Bash manual: So, typically, your `~/.bash_profile' contains the line `if [ -f ~/.bashrc ]; then . ~/.bashrc; fi' after (or before) any login-specific initializations. So in summary, create a ...


Back in the old days, when pseudo tty's weren't pseudo and actually, well, typed, and UNIXes were accessed by modems so slow you could see each letter being printed to your screen, efficiency was paramount. To help efficiency somewhat you had a concept of a main login window and whatever other windows you used to actually work. In your main window, you'd ...


The following should work: function cd() { builtin cd "$@" && ls -l; } Since the function is on a single line, ensure that it is terminated with ; as above in order to work correctly.


Seeing "Broken pipe" in this situation is rare, but normal. When you run type rvm | head -1, bash executes type rvm in one process, head -1 in another.1 The stdout of type is connected to the "write" end of a pipe, the stdin of head to the "read" end. Both processes run at the same time. The head -1 process reads data from stdin (usually in chunks of 8 ...


~/.bash_profile DROPBOX_PROFILE='~/Dropbox/Bash/.bash_profile' if [ -f $DROPBOX_PROFILE ]; then . $DROPBOX_PROFILE fi ~/.emacs (load "~/Dropbox/Emacs/.emacs")


Assuming you’ve verified that it’s a login shell (shopt login_shell): ~/.bash_logout is only run if it you explicitly exit the shell with exit or logout, or by typing Control-D to enter an end-of-file at the command prompt. If you close the terminal emulator, processes are sent SIGHUP, and bash doesn’t run ~/.bash_logout in that case. If you want to ...


On a modern system it is not especially common to run into the cases where it matters, but it does happen. (In particular, if you use shell operations in vim such as :r !command or the in-line !<motion>command form.) What would you put under ~/.bashrc? only aliases? You put things in ~/.bashrc that would not be inherited by subshells ...


You could simply add the following command into System > Preferences > Startup Applications: bash /full/path/to/your/ That should do the trick ;)


You can put .bash_profile in your user directory: C:\Users\<username>. You can also create some git-only aliases so you can do just git st for git status by adding these lines to C:\Users\<username>\.gitconfig: [alias] st = status Some other useful aliases: cm = commit -m cma = commit -a -m br = branch co = checkout df = diff ls = ls-files ...


In most cases, the file doesn't even exist unless you specifically create it. In order to do this, you don't need chflags. In fact, if you're a typical user, you don't need chflags at all with your Mac. Just enter: cd touch .bash_profile You can then edit it with whatever application you like, for example a terminal-based editor like vim, nano, or even ...


You can fix a broken pipe at the expense of another process by inserting tail -n +1 in your pipe, like this: type rvm | tail -n +1 | head -1 The +1 tells tail to print the first line of input and everything that follows. Output will be exactly the same as if tail -n +1 wasn't there, but the program is smart enough to check standard output and closes ...


I think you're running into a loop. Your cd function is calling cd, which is... the function You need to know about builtin which is a keyword which makes command lookup use the the Bash builtins like cd and not your function function cd { builtin cd "$1" : do something else } Also, calling /usr/bin/cd will never work, even if such a command ...


Perhaps you accidentally ran this from csh? $ csh lucid32:~> source if_rc if: Expression Syntax. lucid32:~> cat if_rc if [ -f /etc/bashrc ]; then : fi


⇧⌘. shows hidden files in file dialogs. You could try opening ~/.bash_profile with TextEdit and making it blank temporarily.


Just putting all my comments together for an answer: First thing you should do is change the shell, this way you can set a shell that will not load the bash init-scripts (.bashrc, .bash_profile) - how to do this for the Mac OS X terminal app can be seen here: Apple Support Now you should be able to open a terminal again and use your favourite command-line ...


So basically, as nodiscc suggested, create a desktop launcher: ~/.config/autostart/script.desktop with the following contents: [Desktop Entry] Type=Application Name=Autostart Script Exec=autostart Icon=system-run X-GNOME-Autostart-enabled=true Then create the autostart script: ~/bin/autostart with your bash contents: #!/bin/bash # Execute bash script ...


Use a function instead: function quit { osascript <<EOF tell application "$*" to quit EOF }


Add the following line at the end of ~/.bash_profile or ~/.bashrc, whichever exists: PS1="\n$PS1" This will add a newline before a prompt is printed, which is after control is returned to the shell. Unless your command prompt contains shell commands or variables (which would get executed/interpreted at the time of variable assignment), this will work. ...


You should edit your ~/.bashrc, and add something like: export PATH=$PATH:/path/to/bin


Temporarily fix the PATH, directly in the broken shell: export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin (This is my PATH, it should mostly work for you as well) Give yourself write permissions for that file, with or without fixing PATH as above: /usr/bin/sudo /bin/chmod u+rwx ...


In bash, alias sudo='sudo ' will cause bash to expand any aliases that come after sudo.


Summarizing from the other suggestions: Put this in your .bashrc (or preferably, .bash_aliases): alias ls="ls -F --color=auto" Also, a good read would be man dircolors.


You have to make your own .bashrc. You can simply use a text editor to make a file called .bashrc (no extension) with the contents you want and save it in your home directory (/Users/YourUserName/).


I suggest not to override the cd because there are some other scripts hijacking the 'cd' function, for example, rvm. It would be better to choose another name, like 'd', instead and don't specify the 'builtin' type in your function; otherwise, the hijacker would not function. I am using the code below: function d() { cd "$@" && ls;}

Only top voted, non community-wiki answers of a minimum length are eligible