The default Unix shell used by Terminal in Mac OS X

learn more… | top users | synonyms

46
votes
3answers
18k views

git auto-complete for *branches* at the command line?

On my linux machine I have autocomplete for branches with git. For example I can type git checkout [TAB] and get a list of branches. Or I can type git checkout feb* [TAB] to get all branches that ...
37
votes
8answers
68k views

Why doesn't .bashrc run automatically?

I put some alias commands in my .bashrc file, so that they might be loaded everytime I open a new Terminal window. Yet this doesn't happen. I have to select run script: in the ...
35
votes
3answers
8k views

Is it safe to upgrade Bash via Homebrew?

I'm new to OS X. I'm running OS X Lion on a MacBook Pro. Is it safe to upgrade the bash shell using Homebrew: $ brew install bash If safe, how do I make it the default instance of the shell I run ...
30
votes
3answers
11k views

Is bash in OSX case-insensitive?

Are bash commands on OSX case insensitive? I type "which TR" and it shows /usr/bin/TR, though there is no such binary there. Same thing for other binaries, when capitalized. Or is Terminal.app maybe ...
15
votes
10answers
9k views

How to get a notification when my commands are done

I'm running a series of commands on the command line that takes approximately twenty minutes to complete. I'd like to see some sort of notification on my Mac when these are finished so I don't need ...
14
votes
4answers
14k views

How to get the fully resolved path of a symbolic link in Terminal?

I have a tangled mess of python installations on my laptop. I was looking at the executables in /usr/local/bin and they are all symbolic links to ../../../Library...... There's some weird behavior ...
13
votes
2answers
3k views

Why do I need to put sh before running .sh files?

When I want to run .sh files in Terminal, I need to put sh in front of them. Is there any way to avoid this, and thus save typing?
11
votes
7answers
2k views

Is there a bash command to check to see if Time Machine has finished backing up?

I'm writing a script that will rsycnc my Time Machine directory to a remote server using ssh. I've switched from a shell script to an AppleScript and then back to an Apple script and I don't really ...
11
votes
2answers
1k views

cd to a directory by typing its name?

For example if a directory 'blob' exists and I just type 'blob[return]' then the system cds into the blob directory for me. In Linux (Ubuntu) I can add shopt -s autocd to my .bashrc file, but on OS X ...
10
votes
4answers
1k views

Updating modifier key mappings through defaults command tool

I am trying to automate the inital setup of my macbook, that includes installing software and changing OS X configuration to my needs. I have tried to update the modifier keys with defaults, the ...
9
votes
5answers
554 views

How to share .bashrc files between two mac user accounts

I have set up two user logins on my computer, one for home and one for work. I would like to be able to share any of my bash and vim settings between the two users. Is there anyway to do this? Thus ...
9
votes
3answers
17k views

Getting files, all at once, from a web page using curl

I would like to download the files, all at once, from the following page using curl: http://www.ime.usp.br/~coelho/mac0122-2013/ep2/esqueleto/ I tried curl ...
9
votes
3answers
2k views

OS X - Create a personal bin directory (~/bin) and run scripts without specifying their full path

So, what I am trying to do is to create a personal bin directory at my home folder. I created the following folder: /Users/thi/bin I put my scripts in this folder, but if I type in the Terminal: ...
9
votes
2answers
5k views

How to enter special characters so that Bash/Terminal understands them?

Let's say a folder has a file called Näyttökuva.png (for those who are interested, it is ”screenshot” in Finnish). This is what happens: $ ls Näyttökuva.png $ ls N* Näyttökuva.png $ ls Nä* ls: Nä*: ...
9
votes
2answers
7k views

Using terminal to get current fan speed?

I would like to view the current fan speeds of my MacBook and iMac using terminal. I've found that running spindump then cat /tmp/spindump.txt | grep "Fan speed" will show it, but that's very slow and ...
9
votes
1answer
11k views

Bash or Zsh, what's the difference, why use one or the other?

So, the question pretty much says it all. I'm on Snow Leopard, and I do a lot of web development, particularly in Rails 3 which makes heavy use of the console. I've seen some notable bloggers etc. ...
8
votes
2answers
8k views

Why Mac OS X don't source ~/.bashrc [duplicate]

I found a lot of people figuring out why instruction similar to this : Put X to your ~/.bashrc and you can do Y don't work. It always turns out that Mac OS X's bash's startup files (or Mac's ...
8
votes
2answers
190 views

Piping multiple commands

I would like to run the following command and pipe stout of both to TextEdit: pmset -g; echo; pmset -g assertions | open -f -a TextEdit This doesn't work, it only executes the latter: How?
8
votes
2answers
5k views

Run AppleScript from bash script

If I wanted to run an AppleScript from within a bash script I could call a file with the list of commands that I require to execute. #!/bin/bash {some commands} osascript file.scpt {other commands} ...
8
votes
2answers
3k views

How do I reset the scrollback in the terminal via a shell command?

When using Terminal.app, you can clear the screen by using the shell builtin clear or by pressing ^+L (Control-L). However, all this does is push the current screen content back one screen height ...
8
votes
5answers
4k views

sourcing bash profile for root users

Apologies in advance if this question is going to annoy the hell out of everyone as I appreciate, it's been asked in various ways many times before. Please be assured, I have read the archives and ...
8
votes
2answers
1k views

mount is adding a quarantine flag, causing: /bin/bash: bad interpreter: Operation not permitted - but not the usual suspects

OK, I'm having a similar problem to: -bash: Applications/mvim: /bin/sh: bad interpreter: Operation not permitted - but it's not the same problem. I'm getting the same result. I've already verified ...
7
votes
4answers
3k views

AppleScript vs. Bash script?

I'm a long-time Windows "power user" and developer who has recently decided to move over to Mac OS X. On OS X Lion and indeed previous versions there seem to be two main options for scripting and ...
7
votes
3answers
7k views

Change Terminal.app's Default Shell to BASH

How can I change Terminal.app's default shell to BASH? For some reason, my friend's Mac (10.6.6) defaults to using TCSH instead of BASH. The obvious remedy is to choose /bin/bash as the command to ...
7
votes
4answers
16k views

How do I execute a bash script that requires root privileges?

I have this script lines from my ISP: sudo bash echo "plugin L2TP.ppp">>/etc/ppp/options echo "l2tpnoipsec">>/etc/ppp/options It works if I paste line by line into Terminal. I want to ...
7
votes
2answers
2k views

What is the difference between .bash_profile and .bashrc?

To make an alias for the Terminal in OS X, you can either put the aliases in .bash_profile or .bashrc. What is the difference between the two and why would I choose to put aliases in one and not the ...
7
votes
2answers
2k views

Make ls command sort by file type (e.g. directories and file extension)

How do I make ls sort by file type (e.g. directories first and then by file extension)? The answers suggested in (Super User) Make ls sort by file type result in unknown option errors from ls.
7
votes
2answers
3k views

Is there a Mac OSX equivalent of zenity?

I'm porting some simple X windows/bash scripts to Mac OSX, but I cannot find a build of Zenity (a Gnome app for basic GUI dialogs) for OSX. Is there some other command line driven dialog utility I can ...
7
votes
4answers
113 views

How to list installed versions of the same program

I have a program called PyMOL installed multiple times on my machine. One was installed by MacPorts, one was installed through the developers distribution channel and so on. One is in /opt/local/bin, ...
7
votes
1answer
1k views

How can I format the output of ping in bash?

I am using the following script to cycle through a list of IP addresses and report back on the % of packet loss. I'd also like to have the IP address printed first, then its % of packet loss. But I ...
6
votes
2answers
720 views

Change my shell to a different bash version at /usr/local/bin/bash?

How can I set my /usr/local/bin/bash (which is the 4.2 version that allows auto-completion of 'cd to directory with directory name') to be my default bash for a new window instead of my regular ...
6
votes
2answers
638 views

“Airplane Mode” in OS X. Alternative command for `rfkill`?

This question is an exact duplicate of this post from superuser.exchange.com. I believe this is a valid question for both of sites and hope I am not (if any) violating stackexchange policies. ...
6
votes
2answers
2k views

What option should I give the sudo command to have the password asked through a graphical interface?

This problem has ben bugging me for a while now. Every now and then, I need to write a script file that should execute sudo commands. I do not necessarily know in advance that I will run as sudo so I ...
6
votes
1answer
10k views

Why must I source .bashrc every time I open terminal for aliases to work?

I added this line into my ~/.bashrc file. alias myserver='ssh davidfaux@davidfaux.com' However, when I open terminal and run myserver, terminal complains that -bash: myserver: command not found ...
6
votes
2answers
2k views

Changing Terminal colors when ssh-ing into remote machine and back

Looking for a way automatically change terminal colors when ssh-ing into remote machine and revert back to the default colors, when exiting the ssh session. Simply, want have another colors when i'm ...
6
votes
4answers
14k views

OS X Mavericks bash_profile paths don't work

I need to create a new path in OS X Mavericks. To do so, I edited .bash_profile: export LC_ALL="en_US.UTF-8" export PGHOST=localhost export PATH=$PATH:/usr/local/heroku/bin export ...
6
votes
1answer
52 views

Get ambient light sensor value from ioreg

I'm using the ioreg command line tool to try and read sensor information available on my computer (iMac). Particularly, I'd like to read the current value of the ambient light sensor. So far, I have ...
5
votes
5answers
1k views

OSX Bash for loop - issues with spaces in folder names?

I'm getting a bit confused on how to handle spaces in path names when returned in a for loop. Rationale: I'm cleaning up the permissions on folders and files that I copy over from Windows. Most of ...
5
votes
2answers
371 views

Command to close terminal window

When I want to close a window I type exit : mbp-thomas in ~ ○ → exit logout [Opération terminée] Then cmd + w to close the window. Is there a way to do it with a little script like if I type ...
5
votes
2answers
487 views

How can I have my shell always start in a certain directory that is not my home directory

I've tried putting cd /Users/my_name/my_directory/structure in both .bashrc and .bash_login but neither works, i.e. when I open a new terminal window I am in my home (/Users/my_name/) directory. ...
5
votes
3answers
2k views

Opening a terminal window to a specific directory from a bash script

How can I write a bash script in Mac OS X that opens a Terminal window in a specific directory? I'd assume something like: open /Applications/Utilities/Terminal.app But that does nothing (maybe ...
5
votes
2answers
814 views

Can sudo use my existing aliases?

How can I let sudo use my existing aliases in my .bash_profile (or .bashrc, .profile …)? For example I want to be able to use ll instead of ls -laGF as sudo.
5
votes
2answers
872 views

What does -HUP do when used with killall?

Sometimes when I'm running a killall command from Terminal, a co-worker would suggest or edit my scripts to show killall -HUP. What does the -HUP part do?
5
votes
1answer
2k views

How can I reset my bash configuration?

When I open Terminal it shows this: Last login: Fri Apr 1 17:04:59 on ttys000 -bash: export: /opt/local/bin': not a valid identifier -bash: ...
5
votes
1answer
104 views

Weird line wrapping in terminal with a colored prompt

I have reason to think I've got improper escaping in my bash prompt (I get weird random line wrapping in Terminal). Can anyone point it out? It looks OK to me... export PS1="\033[0;35m\u\033[00m on ...
5
votes
1answer
2k views

Why is a command line change to ~/Library/Preferences/com.apple.LaunchServices.plist not effective immediately?

When the Info window of Finder is used to associate files of a particular type with an application: the preference is effective immediately. When Terminal is used to make a comparable addition ...
5
votes
3answers
7k views

How is my $PATH variable built in Mountain Lion?

I've recently installed Homebrew on my Mac and it's complaining that /usr/bin occurs before /usr/local/bin in my $PATH variable, meaning that system-provided programs will be used instead of those ...
5
votes
2answers
613 views

Strange behavior in Terminal with custom .bash_profile

It's hard to describe the behavior, but here's a short clip: http://www.youtube.com/watch?v=9KqHBA94FPI Basically, when entering multi-line commands, at the end of the first line, the insertion ...
5
votes
2answers
663 views

Smarter Bash Tab Completion

As a recent switcher from Ubuntu (Well recent switch backer if that's a word) I'm finding myself in the command line a lot more than when I was a mac user before. One thing I really loved about Ubuntu ...
5
votes
5answers
4k views

How do I restore my .bash_profile?

I've accidentally overwritten my ~/.bash_profile file. Does anyone have a "sample" one I could copy, or know where I might be able to find one?