Hot answers tagged

502

ok, so I needed the git autocompletion script. I got that from this url: curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash No need to worry about what directory you're in when you run this as your home directory(~) is used with the target. Then I added to my ~/.bash_profile file the ...


429

Status Apple has released Bash security fixes for Shellshock and related vulnerabilities as "OS X bash Update 1.0". They can be installed through normal system update for people using OS X Mountain Lion v10.8.5 or OS X Mavericks v10.9.5 (they are included in Security Update 2014-005) and can also be installed manually. Official Apple fixes are also ...


272

.bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells. When you login (type username and password) via console, either sitting at the machine, or remotely via ssh: .bash_profile is executed to configure your shell before the initial command prompt. But, if you’ve already logged into your machine and open a ...


148

First, some important things: Bash isn't going away. If you're already using bash, nothing will change for you. All that changes is that zsh will be the default login shell for new accounts, and even then, you can select bash instead. Scripts are not affected. What changes is the shell for interactive use, i.e. the shell in terminals (and also a few other ...


130

Use wget instead. Install it with Homebrew: brew install wget or MacPorts: sudo port install wget For downloading files from a directory listing, use -r (recursive), -np (don't follow links to parent directories), and -k to make links in downloaded HTML or CSS point to local files (credit @xaccrocheur). wget -r -np -k http://www.ime.usp.br/~coelho/...


112

Open Terminal, type in sh /path/to/file and press enter. Faster is to type sh and a space and then drag the file to the window and release the icon anywhere on the window.


101

unset it unset DYLD_LIBRARY_PATH The bash reference manual says Once a variable is set, it may be unset only by using the unset builtin command.


97

Some people prefer to use a package manager to automate the installing, updating, and configuring of Mac OS packages. I am a fan of package managers, and I think Homebrew is the best package manager for Mac OS (some would say it's the de-facto Mac OS package manager). Once you have installed Homebrew, you can simply install git along with bash-completion ...


91

In OSX the terminal by default starts a login session so reads .bash_profile etc. (The GUI login process that asks for your name and password does not use shell scripts and starts no shell it is all done from launchd and the workspace) On other Unices xterm runs a non login shell by default so they read .bashrc as the scripts that present you with your ...


64

Is it possible to actually update bash to version 4.0 in OSX Yosemite? Yes. Download / Install homebrew http://brew.sh/ by running this command in terminal. ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" Quit and reopen your terminal. then type brew install bash Change the default shell via the terminal gui ...


59

Terminal supports an extension of the ED (Erase in Display) escape sequence to erase the scroll-back. It is also supported by xterm. The ED command, described in the VT100 manual, accepts these values for the Ps parameter: ESC [ Ps J Parameter Parameter Meaning 0 Erase from the active position to the end of the screen 1 Erase from ...


59

The argument for osascript -e can contain newlines: osascript -e 'set x to "a" say x' You can also specify multiple -e arguments: osascript -e 'set x to "a"' -e 'say x' Or if you use a heredoc, bash interprets three characters (\, $, and `) between <<END and END but no characters between <<'END' and END. osascript <<'END' set x to "a" ...


55

As @William said in his answer, Apple does not provide bash 4 due to GPL restrictions. You can install bash 4+ however and also can make it your default shell (including for Terminal and iTerm2) by doing the following. Install Bash 4 via Homebrew First install the newer version of bash. There are various ways of doing that, I prefer Homebrew. Install ...


55

I ran into the exact same problem. After some digging, I finally figured out what the root problem is. They made some major changes to the git-completion.bash script which requires a new feature in git v2.18, --list-cmds. The problem is that none of the package managers have updated to git v2.18 yet. Most of the instructions out there say to download raw....


54

In Mac OS 10.8 you can send yourself Notification Center messages (similar to Growl but built in to Mac OS). Check out "Send an Alert to Notification Center from the Command Line in OS X" to see how to install a Ruby gem which will allow you to send notifications from the command-line. To simplify the common use-case of just caring about the fact of ...


48

X11 will look at your .bashrc while a "regular" Terminal will look at .bash_profile However, if you add the following to your .bash_profile, you can then move everything into your .bashrc file so as to consolidate everything into one place instead of two: if [ -f $HOME/.bashrc ]; then source $HOME/.bashrc fi


46

I have a .profile in my home directory; it contains many export … statements for environment variables. You can create such a file by opening a Terminal and issuing the command touch .profile Close Terminal. Then you should open that file in a plain-text editor (TextWrangler for example). You can also use nano .profile in a Terminal window (current ...


46

Yes you are technically vulnerable. So if you feel like panicking or billing a panicked client for a few hours of panic work, go for it! But the reality is unless you allow SSH access from remote connections or a web server that runs server side scripting, you are not at risk. You are only truly vulnerable if someone you do not know can remotely access your ...


42

This is SilverInstaller, adware to download more adware and ‘potentially unwanted programs’. This was likely distributed through fake Flash popups, which someone on the system clicked on, downloaded, opened, installed and provided administrator credentials to. Installed software in this package likely includes MacKeeper, VSearch, A Pirrit injector,...


39

First of all, if you are not using iTerm2 already, I suggest you download this free software as a replacement for Terminal.app. Among many other extra features, in iTerm Preferences, you can configure the default working directory for new shells. You'll find these settings in Profiles - General. The advantage here is that you can set different behaviors ...


39

Something like system_profiler SPPowerDataType | grep "Cycle Count" | awk '{print $3}' should do the job. system_profiler SPPowerDataType | grep "Condition" | awk '{print $2}' will get you the battery condition.


38

Here is why your current code is not working: export PATH=${PATH}/usr/local/mysql/bin/ You forgot the colon. export PATH=${PATH}:/usr/local/mysql/bin/ is the correct code.


38

Just install "Shell Integration" and it will be automatically installed for you. On the iTerm2 Menu, just click "Install Shell Integration" You should then see the output indicating that imgcat is installed: $curl -L https://iterm2.com/misc/install_shell_integration_and_utilities.sh | bash % Total % Received % Xferd Average Speed Time Time ...


37

Yes! Type this in your shell env x='() { :;}; echo vulnerable' bash -c 'echo hello' If it says vulnerable then you are vulnerable. If it says bash: warning: x: ignoring function definition attempt bash: error importing function definition for `x' hello then you are good. Edit: link to the fix


37

You can enable bash shell completion by installing bash-completion via brew: brew install bash-completion Then add the following to your ~/.bash_profile: if [ -f $(brew --prefix)/etc/bash_completion ]; then . $(brew --prefix)/etc/bash_completion fi Source (Edit: brew tap homebrew/completions is deprecated as of 2018.)


37

Apple will not update Bash, because the latest version is licensed under GPLv3, which Apple cannot use. They have updated most of their other shells though. ZSH for example is mostly up to date. References: After a bit of research, this seems like the primary issue: https://www.gnu.org/licenses/gpl-faq.html#Tivoization When people distribute User ...


36

Scripts run via Automator use the default search path which usually does not include /usr/local/bin. In your case an easy fix would be to put export PATH=/usr/local/bin:$PATH somewhere at the beginning of the script.


34

This is a limitation of find. The POSIX standard specifies that the return status of find is 0 unless an error occurred while traversing the directories; the return status of executed commands doesn't enter into it. You can make commands write their status to a file or to a descriptor: find_status_file=$(mktemp findstatus) : >"$find_status_file" find … -...


34

You also need to set HISTSIZE=10000000. HISTFILESIZE determines the number of lines to keep in the history file while HISTSIZE determines the number of lines to keep in memory. Both default to 500 Execute echo $HISTFILESIZE $HISTSIZE before you make the change and then again after. You should see 10000000 500 first then 10000000 10000000 after.


34

It looks like there exists a line :wq in one of your shell’s profile files, such as ~/.bash_profile, which was probably added as a failed attempt at quitting Vim when editing such a file. To edit the bash profile with TextEdit, run open -e ~/.bash_profile in Terminal. Edit the file to remove the :wq line only. Save it, quit TextEdit and restart Terminal to ...


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