Questions tagged [bash]

The default Unix shell used by Terminal in macOS

Filter by
Sorted by
Tagged with
1
vote
0answers
17 views

How to paste files using Applescript (or bash)?

I want to paste a file copied by Finder in the terminal. Sth like pbpaste but for binaries. (pbpaste itself just returns the basename of the copied file.)
4
votes
1answer
1k views

Set file metadata attribute values

I'm trying to set the values of some file metadata attributes in OS X Yosemite - kMDItemDateAdded and kMDItemLastUsedDate - the values of which can be shown using mdls <filename>. I'm trying to ...
18
votes
1answer
19k views

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

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. ...
3
votes
2answers
621 views

Zsh vs Bash shell in Terminal [duplicate]

Are there any advantages to using zsh vs bash shell in Terminal app? Also, can you use zsh from the terminal? My understanding of zsh is skewed.
1
vote
1answer
34 views

How can I stop AppleScript from converting variables like “\087” into their octal form when passing through bash?

I have a program I'm using to write xml with variables, and it passes through AppleScript and bash to form the final xml. However, one of my variables usually begins with "024", "054", or other three ...
5
votes
3answers
476 views

Prepend folder names to file name and flatten file structure

I have a bunch of folders with various names, for example 2013-02 Snow and birds PICT0001.jpg PICT0002.jpg 2013-06 Bicycle trip edited_panorama.jpg From phone DCIM0001.jpg ...
0
votes
1answer
19 views

I have override a file in bin folder and this affect other programs

I was installing phpstorm. It use shortcut to use it in bin files as "ps" to use "ps" in terminal to open phpstorm. I didn't know that a file with that name already existed, and I found that when I ...
43
votes
3answers
4k views

bash vs. zsh: What are the practical differences?

With the news that Catalina will default to zsh instead of bash, I'm finding lots of results telling me about the switch, and that it may cause problems with shell scripts, but I'm not familiar enough ...
3
votes
0answers
54 views

How can I detect which button was clicked in the DMG EULA confirmation screen

I'm using the open command to automate (via bash) opening a dmg which has a EULA attached to it. When I run open my_app_distribution.dmg I get a screen that looks like this: The open commands uses ...
1
vote
1answer
203 views

Cannot configure xdebug; “Operation not permitted” error when trying to cp

I'm trying to configure xdebug, but when I run the command cp Downloads/xdebug-2.6.1/xdebug-2.6.1/modules/xdebug.so /usr/lib/php/extensions/no-debug-non-zts-20160303 I get a "Operation not ...
3
votes
2answers
92 views

Help to replace a blank space with a backslash and blankspace in a variable in Run Shell Command with Automator

Im creating an automator service that transcodes all the files within a folder to a compressor preset by running the following shell script: VAR="/Applications/Compressor.app/Contents/MacOS/...
36
votes
3answers
25k 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 ...
10
votes
7answers
29k 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?
0
votes
1answer
88 views

How to apply a bash script just to one user account?

Generally speaking I manage my MAC OS X High Sierra and Mojave systems using very basic script(s) that I remotely send and apply to the entire Mac OS X system, that means all these script(s) are ...
9
votes
2answers
426 views

Change the default text editor in Terminal

I just discovered that Control + X + E opens a text editor in the Terminal that allows me to edit the most recent command before executing it again (I think it is actually a bash thing). However, the ...
21
votes
2answers
12k views

Terminal - how to restart session after inadvertently exiting?

Sometimes I inadvertently exit from a Terminal session (usually because I think I'm connected to a remote system, when I'm not), so I get to this point: How I can I restart the session at this point ?...
4
votes
1answer
95 views

Search folder, copy to new folder and change names of the files!

So I'm trying to recursively search folder, and as you might imagine it will be the "Photos"-folder in MacOS. And in the process, I would like to change the file name, why you might ask? Because ...
0
votes
1answer
44 views

Escape every character in bash

I want to take a string like this: Example string 59^!#&$( And turn it into this: \E\x\a\m\p\l\e\ \s\t\r\i\n\g\ \5\9\^\!\#\&\$\( I've tried: sed -e 's/./\\&/g; 1{$s/^$/""/}; 1!s/^/"/; ...
-1
votes
1answer
87 views

Bash Shell Prompt change color when in root mode

Mac OS X, how do I set the bash shell prompt (PS1) that every time the user type sudo su (root mode) the shell prompt change from the standard color to the red color and of course if the user exit ...
0
votes
0answers
13 views

Sound in Ubuntu not in Mac OS

I broke the headphone jack. Internal speakers disabled in Mac OS. However when installing Ubuntu the speakers work normally. Can I somehow install the Ubuntu drivers into Mac Os or something? to make ...
1
vote
3answers
154 views

Move folders using Terminal by referencing a CSV file

I have a CSV file containing the following two columns: Column A: From Directory (e.g. /Volumes/Backup Plus/Salesforce/Order Test/OR-1000049439). Column B: To Directory (e.g. /Volumes/Backup Plus/...
0
votes
0answers
37 views

How to delete pre-installed apps on macOS Catalina [duplicate]

I used csrutil disable to turn off System Integrity Protection and deleted some unused pre-installed apps before macOS 10.14. Recently, I upgraded to macOS 10.15 Beta (19A487l) and found this way didn'...
6
votes
3answers
11k views

How to “killall” Visual Studio Code in Terminal?

I have a small shell script called "k" that i call everytime when i want to reset my complete Development Cycle: killall node killall Xcode killall Terminal How can i find out the final name of the "...
1
vote
1answer
101 views

Make Homebrew installed Vim override system installed one

I have troubling merging several version of vim on my machine. I have successfully installed vim via Homebrew. Here's the output of running brew info vim: vim: stable 8.1.1550 (bottled), HEAD Vi '...
0
votes
1answer
75 views

What modifies the PATH variable on macOS? [duplicate]

echo $PATH returns a different result than the PATH variable I define in .bashrc. .profile is empty. What else could be modifying the PATHvariable? The directories listed are all things I would have ...
1
vote
1answer
102 views

cp command: Overwrite confirmation with file diff

When running cp command to copy files, I would like to be prompted for overwrite confirmation, and, if possible, view the file diff confirming. Is this possible? And if yes, how? Ideal example: $ ...
7
votes
2answers
11k views

Git auto-completion not working on Mac OSX 10.11.5 El Capitan

I have tried the examples found here to get Git auto-completion working on El Capitan, however none of the examples work for me. I installed bash-completion with Homebrew (brew install bash-...
5
votes
3answers
8k views

How is my $PATH variable built on macOS?

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 ...
0
votes
1answer
78 views

How to remove special character from a folder name?

I am creating a folder like mkdir -p ../service/target/static but windows creates it with some special character static. I need to explicitely remove that special character using shell script. I ...
0
votes
0answers
32 views

Distribute bash script 'silently' to multiple macos machines

We want to deploy a script 'silently' across all mac machines in organization. We have created a bash script that will run using launchd agent. We need to deploy the launchd agent and script on all ...
1
vote
1answer
21 views

Get french accent on Linux terminal connected via ssh from MacOS High Sierra

I come on this forum since no answers or suggestions on other forums. I am often connecting from a MacOS High Sierra terminal via SSH to a Debian 8.0. The locales on my MacOS are : LANG= LC_COLLATE="...
1
vote
1answer
29 views

Bash History missing from Terminal

After an OS update, my bash history is suddenly gone - typing "history" at a terminal window (sudo or standard) yields only the commands entered after the upgrade. What could have happened here?
0
votes
1answer
46 views

Prevent Terminal from overwriting preferences on exit

When a user loads my C++ program, I want Terminal to look a certain way. I solved this by wrapping my program in an AppleScript .app which overwrites ~/Library/Preferences/com.apple.Terminal.plist (...
2
votes
1answer
35 views

How to find the PID(s) of a hung app in macOS from the shell (Terminal)?

Within Activity Monitor.app it's easy to visually identify a hung app by seeing its name in red text: How can such hung app statuses be identified from the shell (Terminal.app) and the PID(s) of ...
17
votes
4answers
12k views

Change file association in terminal?

Is there a method for associating file types with applications via terminal? I thought ~/Library/Preferences/com.apple.launchservices.plist might do it, and I also have seen: Why is a command line ...
1
vote
2answers
35 views

Launch of terminal after system login takes around 60 sec, is there a way to speed it up?

Here is my .bash_profile export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)" export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "...
1
vote
1answer
36 views

how to reset $SHELL variables in root from user space

I've switched my bash to zsh in root using chsh -s /usr/bin/zsh root After when I change back to bash, I type the wrong path: chsh -s /usr/bin/bash root Now I cannot enter root and I get this ...
2
votes
2answers
64 views

Change output format of “top” command in Mac OS for memory usage?

I am using the top command in Mac OS from this answer to grab memory usage: $ top -l 1 -s 0 | grep PhysMem PhysMem: 5490M used (2569M wired), 11G unused. Can I go from that to possibly printing out ...
0
votes
0answers
13 views

Why does my terminal on a Macbook Pro say Thomass-Iphone? [duplicate]

My name is not Thomass nor do I know one however I have this going on in my terminal, how can I fix this?
1
vote
2answers
2k views

Batch copy time creation and modification date from files using OSX

First of all, I have asked the same question at stack overflow, but I am not sure if it's right over there. That's why I decided to post it here, too. t'm having a hard time trying to copy the ...
3
votes
3answers
304 views

Remove sudoers using script

At the moment I'm working on a solution to prevent all admins users (except one particular) from running sudo. I can add a specific user to sudoers by running: sudo -i echo '$username ALL=(ALL:ALL) ...
0
votes
0answers
25 views

How to associate file extension with executable using bash?

In my bash script setup.sh, how to make macOS associate .foo extension with /usr/local/bin/bar, so that I can click on X.foo in Finder (say) and have macOS perform /usr/local/bin/bar X.foo?
1
vote
1answer
83 views

macOS Terminal.app can't split with Command + D

I installed zsh. When I press Command + D in iTerm2, it could split normally. But when I return to using Terminal.app, I use bash or zsh, it can't split with Command + D, it changed like the ...
7
votes
4answers
24k 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 plug ...
3
votes
2answers
938 views

Copy the first n files from one directory to another

Im looking to copy the first 'n' files from one directory to another directory preferably with only cli tools (no scripts). I've tried the following: find . -maxdepth 1 -type f | head -5 | ...
4
votes
3answers
324 views

Can't connect to Internet in bash using Mac OS

My browser works perfectly using the using Internet, however, when I tried to use this command in bash: ping -q -w1 -c1 google.com &>/dev/null && echo online || echo offline It gives ...
0
votes
0answers
22 views

Bash prompt customization not working

I have installed Git Aware Prompt. I have followed the instructions in the project readme file and customised my prompt in ~./bash_profile by adding the following lines: export GITAWAREPROMPT=~/.bash/...
0
votes
0answers
18 views

Forward deleting (Macports/bash): Is there an alternative to Fn+Delete and Control+D?

As a more general version to this question, is there a way to forward-delete in a bash terminal that doesn't involve Fn+Delete or Control+D? Motivation: When using the Macports port command ...
27
votes
7answers
100k 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 ...
0
votes
2answers
107 views

Connect and run commands over SSH using script

I'm using a series of commands for deploying my files to production. This is currently done manually. Is it possible to make these commands into an executable file? So that I don't have to copy paste ...