The default Unix shell used by Terminal in Mac OS X
19
votes
3answers
4k 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 ...
19
votes
2answers
5k 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 ...
18
votes
8answers
32k 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 ...
18
votes
3answers
7k 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 ...
11
votes
2answers
453 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
5answers
1k 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 ...
9
votes
3answers
7k 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 ...
8
votes
9answers
3k 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 ...
7
votes
5answers
262 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 ...
7
votes
4answers
2k 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
4k 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
1answer
660 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 ...
6
votes
2answers
282 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
1answer
3k 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ä*: ...
6
votes
2answers
1k views
What option should I give the sudo command to have the password asked trough 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
2answers
1k 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 ...
5
votes
4answers
6k 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 ...
5
votes
2answers
310 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.
...
5
votes
1answer
906 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
1answer
6k 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. ...
5
votes
1answer
685 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 ...
5
votes
3answers
5k 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
236 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
425 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
2answers
1k 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 ...
5
votes
1answer
4k 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
...
5
votes
3answers
665 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 ...
4
votes
3answers
249 views
In terminal, modify the text that comes before $
In terminal I can always see which path I'm in:
macbook-romeo:School romeovs$ echo "example command"
which I find quite useful. Yet there is a lot of unnecessary stuff here too: macbook-romeo is ...
4
votes
2answers
1k 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 ...
4
votes
3answers
531 views
How to run a bash script from the desktop?
I have a .sh file with a #!/bin/bash header. I'm able to run it from the terminal, using chmod and ./ but is there a way to perform these two operations from the desktop (i.e. by clicking on it) ?
...
4
votes
2answers
522 views
How do I make find fail if -exec fails?
When I run this command in the shell (in a non-empty directory):
find . -exec invalid_command_here {} \;
I get this:
find: invalid_command_here: No such file or directory
find: ...
4
votes
2answers
168 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.
...
4
votes
3answers
1k 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 ...
4
votes
3answers
773 views
Is it possible to have bash escape spaces in pwd?
I'd like to copy the current directory to the clipboard, something like: pwd | pbcopy. However, pwd does not escape the space, so something in "Application Support", for example, doesn't copy ...
4
votes
1answer
227 views
Why does my Terminal command line screw up like this? (bash's fault?)
When I use the command line history ( CtrlR , CtrlP )
The command line screws up like this:
The cursor is supposedly located at the end of the line ( just pressed CtrlE )
If I press enter, just ...
4
votes
2answers
290 views
How to reset the terminal before command execution?
I've been looking at spicing up my Terminal experience by among other things, adding some color. I used the tput command to build a nicely looking prompt. This is part of my .bash_profile:
...
4
votes
3answers
2k 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?
4
votes
1answer
154 views
How to reset $PATH?
I was trying to add something to $PATH and it went totally wrong. I now can't run any commands such as ls. I've looked at this answer and used the following lines:
...
4
votes
1answer
148 views
declare -x messages appear in my terminal. How can I get rid of it?
declare -x Apple_PubSub_Socket_Render="/tmp/launch-qoybJQ/Render"
declare -x Apple_Ubiquity_Message="/tmp/launch-DWchNf/Apple_Ubiquity_Message"
declare -x COMMAND_MODE="unix2003"
declare -x ...
3
votes
2answers
1k views
Bash commands that work on an iphone
I've jailbroken my phone, and I'd like to execute some commands on it from my phone, namely, the Say command. That, unfortunately, does not work. What commands COULD I execute on the iphone, other ...
3
votes
2answers
179 views
Are Bash, Bourne, and Korn shells compiled into one binary in OSX?
On OSX 10.8, if you compare the binaries for bash, sh, and ksh, a few different shell options, they are the same size. If you take it further and cmp the binaries, there seems to be only a ...
3
votes
3answers
4k views
Where are environment variables specified when .profile, .bash_login, .bash_profile cannot be found?
When I type env at the terminal prompt, I get a dump of all the environment variables. When I check / or ~, however, I do not see a .profile, .bash_login or .bash_profile.
Where is this being stored ...
3
votes
3answers
4k views
Netcat -e on Mac OS X
I'm a newbie macuser coming from Debian, and I'm a big command line user.
One one my preferred one is netcat (aka nc on mac). I especially loved the -e option which enabled to create a process that ...
3
votes
2answers
793 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 ...
3
votes
2answers
1k 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.
3
votes
2answers
208 views
How to search for a file by a hash value with bash script (terminal)?
I am writing a script for Mac OS X Lion 10.7 and I would like to know how I can search for files based on their SHA1 hashes. I would like to search the whole file system for the file(s) I will be ...
3
votes
5answers
3k views
Why do I have to source ~/.bash_login every time I open Terminal
When ever I close and open Terminal.app, it never loads my ~/.bash_profile. I have my RVM setup at the top of the file but it never loads it.
As you can see, when I type rvm into Terminal, it says ...
3
votes
2answers
44 views
How to strip a filename of special characters?
I have a file with a name such as "Today's Date.txt"
What I am interested in is stripping away all special characters using the terminal such as:
" - , ' ' [
The reason for this is because I ...
3
votes
1answer
60 views
How do I generate cryptographically random numbers on OSX?
I need to generate several cryptographically random numbers in OSX and save it to a text file.
How should I go about doing this?
3
votes
2answers
142 views
How do I add a flag to an alias?
Is it possible to add a flag to a bash alias you create yourself? e.g.
con -a = 'ssh username@server1.domain.com'
con -b = 'ssh username@server2.domain.com'
