Questions tagged [bash]

The Unix shell formerly used by Terminal in macOS until 10.15

194 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8 votes
2 answers
2k 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 ...
user avatar
  • 181
6 votes
0 answers
3k views

Run a command without opening the terminal

Is it possible to start a terminal command without opening the terminal first? I have some quick commands, and for those I open the terminal window, run the command, and close it again. I generally ...
user avatar
5 votes
0 answers
1k views

Change keyboard layout automatically when external keyboard connected

I recently purchased an external keyboard (non-apple) that is used at home and also dragged along with me from time to time, and I've noticed a need. My Mac is in English, as well as its physical ...
user avatar
  • 151
4 votes
1 answer
406 views

launchctl: Unrecognized target specifier

I think that at one point in the past I disabled my media keys using the instructions provided in this answer. I am trying to re-enable them, but upon using the command: launchctl bootstrap "gui/$...
user avatar
4 votes
0 answers
173 views

iOS Cannot SIGINT or Ctrl+C when SSH'ed into it

I have a jailbroken iPhone that I often SSH into. For some reason, I am unable to Ctrl+C a foreground process or kill -INT a background process when said process is started in an SSH session, but I ...
user avatar
4 votes
0 answers
1k views

iotop on High Sierra

I seem to have issues with iotop on High Sierra, googling it I find no useful information. The output is garbled and almost unusable. I have SIP disabled for dtrace (I know "I'm not suppose to do ...
user avatar
4 votes
0 answers
3k views

How to use nohup/send process to background on os/x

The command nohup <command> & does not actually work properly on mac it seems: the process is suspended. Issuing fg appears to be required to reactivate the command. Here is an ...
user avatar
4 votes
1 answer
590 views

How to schedule run of .command file (bash)?

I have a bash script (saved as myfilename.command) and would like to schedule its run. I've tried to use Calendar event for this (which works fine with Automator scripts), but I get the following ...
user avatar
  • 364
3 votes
0 answers
479 views

Catalina and pyenv install python versions fine, but anything needing ssl fails

I seek to use pyenv instead of manually installing an official python release. My goal is to run the included script titled “Install Certificates.command”. My assessment of the situation is pyenv is ...
user avatar
3 votes
0 answers
83 views

Garbled Terminal output

The text displayed and the cursor on Terminal is very often garbled or 'noisy', and this is across releases for as long as I can remember. That said, it seems worse on Big Sur. Symptoms: Suppose I've ...
user avatar
  • 161
3 votes
2 answers
192 views

Preventing Relocated Items shortcut after every update

The Problem My Mac has received a new Relocated Items folder after every OS update since March 8th, 2020. This was around the time I upgraded to Big Sur I think. If I delete the shortcut, it'll just ...
user avatar
3 votes
0 answers
112 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 ...
user avatar
3 votes
0 answers
2k views

How can I mount Google Drive File Stream before launchd user agents start?

I have a simple backup bash script that dumps the output of pg_dump for a PostgreSQL database into a Google Drive File Stream directory. This bash script is referenced by a launchd user agent. The ...
user avatar
3 votes
0 answers
815 views

Opening new Firefox window from command line while it's already running

Does anyone know how to open a new Firefox window from the command line while Firefox is already running? I can't find any solutions currently out there that work for me. I've looked at the MDN web ...
user avatar
3 votes
1 answer
361 views

How to properly esca‌​pe spaces in the res‌​ults of mdfind to use them in a for loop

Trying to answer the question Are true dynamic folders (NOT a “Smart Folder” SavedSearch) possible? I stumbled about the problem to loop the results of an mdfind search as quoted or escaped paths. ...
user avatar
  • 64.1k
3 votes
0 answers
2k views

macOS new logging api (unified logging) log stream

Questions: 1) How can we redirect the log stream from stdin to, for example lnav? Currently, I use bash | (pipe), but I would like to hear if there is a better way to do it - the pipe buffer flow is ...
user avatar
  • 2,286
3 votes
0 answers
144 views

open -g command still opens application in the foreground

When I run the command open -ga /Applications/Google_Chrome.app http://example.com the application behaves normally and opens the url in Chrome without bringing the application to the foreground. But ...
user avatar
  • 681
2 votes
1 answer
117 views

When viewing man pages in Terminal, how to get correct man page order priority? `man` shows the correct manpage but Terminal shows an older one

I love using the Terminal's man page viewer. You can right click on anything and open its corresponding man page. Or just run open x-man-page://1/<man page> However, I'm having trouble getting ...
user avatar
  • 483
2 votes
0 answers
3k views

How can I determine the source of this permission message? “bash“ wants access to control “System Events“

I occasionally receive this permissions message in MacOS 10.15.5: “bash“ wants access to control “System Events“. Allowing control will provide access to documents and data in “System Events“, and to ...
user avatar
  • 121
2 votes
0 answers
178 views

problems resulting from launchd script running when computer is sleeping

I have a Bash script that copies a specified set of files/directories to a remote server via rsync. It is run by launchd as a Global Daemon every day at 3am. The computer is sleeping most of the time ...
user avatar
  • 305
2 votes
0 answers
697 views

macOS Terminal not using correct manpath

How to set $MANPATH or manpath for the macOS Terminal Help menu command: Open man Page for Selection? Having recently done a clean install of macOS Mojave (10.14.6), I am trying to get my macOS ...
user avatar
2 votes
0 answers
35 views

Opening terminal from command line, starting bash and got to the same location where the original terminal was

For example, I have a terminal (running /bin/bash) opened at a certain folder. Now what I want is when I type trm on the terminal, it will open another terminal at the same location where the first ...
user avatar
  • 153
2 votes
0 answers
181 views

Mac Terminal Slow after upgrading to PHP7.3

I had my Mid 2013 macbook air running Mojave (10.14.5) with PHP 7.1.23 updated to PHP 7.3 from https://php-osx.liip.ch/ using the command curl -s https://php-osx.liip.ch/install.sh | bash -s 7.3 . ...
user avatar
  • 141
2 votes
0 answers
1k views

Create User via Terminal with Bash in macOS Mojave

In general, you can create a user via Terminal in macOS using Apple's documented method. However, macOS Mojave introduced various security mechanisms that cause scripts to fail when changing user ...
user avatar
  • 56
2 votes
0 answers
425 views

Bash autocomplete in Terminal stops working after a while

Bash allows auto-completion using the tab key: If you type cd ~/D on Terminal, followed by the Tab key, you ear a beep, but if you follow by a second Tab key, the Terminal display the suggestions ...
user avatar
  • 301
2 votes
0 answers
105 views

What are .backup files and how do I remove them?

I'm working on removing hidden files from a directory, but keep running into issues with .backup files. I keep getting permission denied notifications even when using sudo. I'm not sure where they ...
user avatar
2 votes
0 answers
24 views

Processes display not allowing page down

The display hangs on one page after I invoke process through command top, Press 'space', 'arrow' take no effects. I got recommend to use htop, but find it complicated to manipulate. How to page top ...
user avatar
  • 2,349
2 votes
0 answers
80 views

Errors with 'echo [A-Z]*'

Errors with 'echo [A-Z]*' I am working on the root directory and intending to print those starting with upper letter. $ echo [A-Z]* Applications Library Network System Users Volumes bin cores dev ...
user avatar
  • 2,349
2 votes
0 answers
382 views

Can I modify iTerm window titles for some but not all running commands?

I was looking for a solution to auto set custom title in the terminal based on what command is being run on the current terminal. So, rather than java showing in many tabs - I'd love to have it pick ...
user avatar
  • 193
2 votes
0 answers
562 views

bash in iTerm2: how to log variables like $TERM_SESSION_ID into command history

To help with recovering history across restarts etc I would like to get some key data, like $TERM_SESSION_ID, stored in my command history. This would be preserved when the command response output in ...
user avatar
  • 79
2 votes
0 answers
71 views

Where do I find what's all affecting my $PATH?

When I echo $PATH I get: /Library/Frameworks/Python.framework/Versions/3.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/arukaj/Library/Android/sdk/platform-tools/:/Applications/XAMPP/...
user avatar
  • 121
2 votes
0 answers
391 views

Set up a Mac to run OSX (None Browser) application in pure kiosk mode

I've been trying for a number of months, using many methods, to run a Nuiteq Application called Snowflake on our 10 Mac Minis attached to touch-screens in pure Kiosk mode. I'm using Yosemite. These ...
user avatar
  • 21
2 votes
0 answers
49 views

Using CTRL with bash

Coming from year on Windows, I swapped Cmd and Ctrl buttons. On bash I used to press Ctrl+A/Ctrl+E for jumping to the beginning/end of line. But, since I swapped the buttons I need press Cmd+A/Cmd+E. ...
user avatar
  • 121
2 votes
0 answers
607 views

Grant rights on a certificate to an app through the shell

I'm currently looking for a way to grant an application rights to a certificate in my /Library/Keychains/System.keychain through the shell. I can currently do this through the Keychain Access App by ...
user avatar
  • 21
2 votes
0 answers
154 views

Automating VPN switching

I can us a VPN app like tunnelbear to appear to be in other countries, but is there a way to do this in a bash script or applescript? I want to be able to run automated tests on my iOS apps (in the ...
user avatar
2 votes
0 answers
263 views

Terminal hangs when title includes unreachable NFS path

[Edit: reframing to make the question more clear] I use the Mac Terminal to access remote linux systems. On the Mac, the bash prompt is set by: PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}\...
user avatar
  • 21
2 votes
0 answers
139 views

Terminal: disable printing/output of keyboard commands

I have the same problem as this person – I am running a C script and somehow when I pass the EOF signal with Ctrl+D, ^D gets printed to the console. My question is therefore: is it possible to ...
user avatar
2 votes
0 answers
137 views

Determine when an application last launched

I need to have a script return a date that a particular application launched (in this case Parallels, but solution should be non-specific) so that our asset management system can mark the license for ...
user avatar
  • 126
2 votes
0 answers
742 views

Bash script to import RootCA and set it to Always Trust from Server

I am working on a way to import a RootCA into the login keychain of OS X and set it to always trust, the cert is located on a file share server. I am relatively new to the whole Bash scripting scene ...
user avatar
2 votes
0 answers
834 views

How to make files safe so users can download and OS will not quarantine them?

I work with Axure software that generates dynamic and navigable prototypes in HTML. Once they are done I need to send a ZIP file of those HTML files to clients via e-mail or any download internal ...
user avatar
  • 21
2 votes
0 answers
857 views

bash autocompletion scripts in OS X

Here is what I learned so far: # settings on mac if [[ $(uname) == "Darwin" ]]; then # enable bash completion if [ -f `brew --prefix`/etc/bash_completion ]; then . `brew --prefix`/...
user avatar
  • 577
2 votes
2 answers
1k views

How to Poll USB mouse through terminal in El Capitan

I've been trying to view which devices are connected to my USB ports through terminal in El Capitan, in particular a USB mouse. I've read online that I can ls /dev/tty.* to view all connected devices. ...
user avatar
  • 235
1 vote
1 answer
47 views

How to launch docker container from CLI in MacOS (eg `docker run ...`)?

How can I launch a docker container from the command-line in MacOS? In Debian Linux, I can execute the following commands to install docker, launch a new docker container based on the latest version ...
user avatar
1 vote
0 answers
52 views

Wrapping "osascript -e" to multiple lines in bash?

Is it possible to wrap a long "osascript -e" command across multiple lines in Bash? For instance: echo $(osascript -e text returned of '(display dialog "Enter your email address:" ...
user avatar
  • 111
1 vote
1 answer
262 views

Bash script or AppleScript to connect & disconnect an Airplay display in Monterey+

In System Preferences > Displays, bottom left corner is "Add Display". I can choose another (Monterey+) Mac, Apple TV, iPad, possibly other things, to effectively become an additional ...
user avatar
  • 388
1 vote
0 answers
36 views

Sed command to replace values on custom lines

I'm trying to replace custom values in a configuration file using sed, but the changes should be applied for specific indexes of lines (e.g. first two lines only, line 3, etc). For now, using this ...
user avatar
  • 111
1 vote
0 answers
36 views

Why is LANG environment variable wrong in shell?

When I start a Terminal (in Monterey 12.2.1) my LANG is sv_SE.UTF-8, which is fine. When I start a shell, or any other sub-process that reads environment, from GUI Emacs it is set to LANG="en_SE....
user avatar
  • 141
1 vote
0 answers
49 views

Sparsebundle issues: rsync fails and bash completion shows files that don't exist

The strangest thing is happening right now, so I'm just going to do my best to explain: I have two hosts: a MacBook Pro ("MBPro"), and an iMac ("iMac"), both running Mojave 10.14.6....
user avatar
1 vote
0 answers
300 views

How do I get iTerm2 to split a single session, Terminal-style?

In iTerm2, Cmd+D adds another pane in the window with a new session. Straightfoward, useful - but not what I want. In Terminal, I could use Cmd+D to split the window with the same session. Both ...
user avatar
1 vote
0 answers
277 views

Renaming All Files in a Folder with Date and Timestamp, Adding Counter if Duplicate

After taking a look at this answer and adapting to my needs, I am stuck when there are files with identical timestamps. I need to rename all files in a folder, including the date and timestamp at end. ...
user avatar
  • 127