Questions tagged [bash]

The Unix shell formerly used by Terminal in macOS until 10.15

Filter by
Sorted by
Tagged with
0 votes
1 answer
48 views

Why does iTerm no longer source ~/.bash_profile, but Mac Terminal does?

This must be something very simple, but I can't figure it out. Until recently iTerm always properly sourced .bash_profile which has: Sellotape:~ mnewman$ cat .bash_profile ## .bash_profile - Make sure ...
Buadhai's user avatar
  • 429
1 vote
0 answers
38 views

Having period job to remove temporary files

I've defined a periodic plist which runs a bash script. The plist is placed in the local library and script is also place in /usr/local/bin. It successfully run the script on the defined period but it ...
Parham Alvani's user avatar
-1 votes
0 answers
40 views

How to avoid duplicate commands in command line?

This seems to have been asked many times, but I just can't make it work. I want to make it so that when I use the same command two or more times in a row, it shows up only once when scrolling through ...
I am me's user avatar
2 votes
2 answers
105 views

Check if display sleep on Apple Silicon in Bash

I have a Bash script that performs certain actions when the Mac enters sleep mode. The script worked fine on my Mac with an Intel chip, but it can't detect whether it's sleeping or not with Apple ...
Piero's user avatar
  • 121
0 votes
0 answers
19 views

Cannot switch to root after applying Account Policies

After running the following script, that applies some Account Policies I have lost the access to root account. I took the script from Git Executing command sudo su - Resulting in request of an old ...
Papa Smurf's user avatar
4 votes
3 answers
948 views

Apple Terminal startup errors (session save/restore)

Recently (possibly with the Sonoma update, but possibly even more recently than 14.0), Apple Terminal has been giving the following error on startup (when macOS is set to restore windows, i.e., when ...
Andrew Jaffe's user avatar
1 vote
2 answers
63 views

Creating a FAT32 SD card image (.img) out of a directory using command-line tools

I'm writing a program which is meant to be loaded and run exclusively from a FAT32 SD card. I need to create an SD card image for distribution as well as for testing the storage and retrieval of files ...
AcinonX's user avatar
  • 13
0 votes
0 answers
43 views

How to add Google Chrome to path?

I want to add Google Chrome to path under the google-chrome name so that I can execute the following command: google-chrome --version. First I tried with: sudo ln -s /Applications/Google\ Chrome.app/...
mångata's user avatar
  • 101
0 votes
0 answers
50 views

How to fix bless command can't access efi-boot-device in MacOS Recovery Mode?

I run this command in Mac Recovery Mode via Terminal App -bash-3.2# bless --info Can't access "efi-boot-device" NVRAM variable
leeannecando's user avatar
0 votes
0 answers
35 views

How to access Finder's "Date Added" field from Terminal without MDLS

[MacOS Ventura] I need to move some files off a drive that is nearing its capacity to another drive while preserving the original Date Added in its new location. Since I've noticed that MacOS ...
gone's user avatar
  • 603
2 votes
0 answers
50 views

launchd job returning 2 but works fine in terminal

I'm trying to write a bash script to clean up my Downloads folder every day at a certain time. The bash script should get called then a python program afterwards to do the cleanup. I'm using launchd ...
A-A's user avatar
  • 21
2 votes
1 answer
83 views

sudo: command not found, despite path being set correctly

Recently, I've been unable to use the sudo command in terminal. Any command I try to give it, file I try to get it to run, etc, tells me sudo: [command or file]: command not found. If I try to run ...
GtwoK's user avatar
  • 121
1 vote
0 answers
30 views

Make a RTP-MIDI session in "Midi Network Setup" reconnect to a participant after reboot

In a studio setup, I need an RTP-Midi (AppleMidi) session, that is set up via "Audio MIDI Setup" to reinitiate with a participant, after reboot. At the moment, the Session is active but the ...
adrifromhh's user avatar
1 vote
0 answers
64 views

How can I run bash command with having Sandbox in Swift? [closed]

I made a working app which hides and shows the desktop icons using bash the terminal command for making it, easier to do this job with an UI, it works ok without sandbox and if there is sandbox it ...
bulletproof software engineer's user avatar
2 votes
1 answer
68 views

Possible diskutil info protocol fields?

Is there somewhere in the OS such as a plist that stores all the possible protocols for diskutil info? So far, I have come across the internal disks as PCI, SATA and PCI-Express. diskutil info /dev/...
Bob R's user avatar
  • 129
7 votes
3 answers
1k views

Terminal: How to move files to the last used directory conveniently?

I googled to no avail and could not find any example. For example, if I want to move files to the current dir I can use . But what if I am in ~/foo and cd into ~/foo/bar/xyz/dir and want to move, say, ...
mariano-daniel's user avatar
0 votes
0 answers
58 views

Display a Tooltip at Mouse Cursor (via Applescript or Shell Script)?

I tried googling for info about this for a while, but came up empty handed. Is there any way, either with shell or Apple script, or maybe even via python, to display a tooltip relative to the mouse ...
Max Well's user avatar
  • 259
0 votes
1 answer
55 views

Convert passwordLastSetTime to date format YYYY-MM-DD on macOS Monterey

The code below from Convert passwordLastSetTime to date format YYYY-MM-DD works great on macOS Ventura machines to convert the date for when the password was last set on a user account. But when using ...
MPL's user avatar
  • 47
1 vote
1 answer
108 views

Tilde expansion broken

Today tilde expansion has broken on my Mac. $ cd ~ -bash: cd: ~: No such file or directory I use vi-mode on zsh along with oh-my-zsh and thought that could be causing the issue. But switching ...
CalumMcCall's user avatar
0 votes
0 answers
57 views

Launch New Bash Shell And Run Commands

I am attempting to launch a new shell and run a command in the new shell, and then leave the shell running interactively. I attempted the process over here [ (bash --rcfile <(echo '. ~/.bashrc; ...
Justin Goldberg's user avatar
0 votes
0 answers
53 views

How do I trap in a bash script and guarantee execution?

I have a bash script like this #!/bin/sh function cleanup() { osascript -e "tell application \"Terminal\"" -e "set current settings of window 1 to settings set \"...
gman's user avatar
  • 2,651
0 votes
1 answer
62 views

Expected end of line but found "/"

I am updating a script that was written by someone previously in my position but it will not compile due to the error above. This is my first time using AppleScript, so I am very much a beginner. I ...
Connor Eddy's user avatar
1 vote
1 answer
27 views

Is It Possible to Have a Local .bash_profile?

I'd like to have a different PATH for a project, and I was wondering if it's possible to have a local .bash_profile for a specific folder and its subfolders. Is this even possible?
Samuel Bacay's user avatar
0 votes
0 answers
126 views

Mac OS: Execute a command in .zshrc (or .bashrc) only for new windows but not for new tabs

I'm trying to change the "default working directory" for Terminal.app and it seems that is not possible (from my research so far). I could achieve this using ~/.zshrc (by adding "cd ~/...
Ajay A's user avatar
  • 45
0 votes
1 answer
26 views

XFCE Build Error xdt-csource.1

I'm trying to build xfce4-dev-tools on macOS Monetary. to build and install xfce4 desktop environment. im a total noob when it comes to building c/c++ programs. Following the steps - cloned the repo, ...
janithcooray's user avatar
0 votes
0 answers
83 views

Changing default shell to bash on Sonoma [duplicate]

As all the instructions that I can find say, I changed the default shell by doing this command in terminal: chsh -s /bin/bash I now get this error: The default interactive shell is now zsh. To update ...
pitosalas's user avatar
  • 1,867
1 vote
2 answers
67 views

Convert passwordLastSetTime to date format YYYY-MM-DD

Trying to convert passwordLastSetTime to date format YYYY-MM-DD The command is: dscl . read /Users/<username> | grep --context=3 passwordLastSetTime I want to convert this number to YYYY-MM-DD ...
MPL's user avatar
  • 47
1 vote
0 answers
39 views

Detect MacBook webcam usage without taking photo or recording?

I am attempting to write either a bash script or dedicated piece of software to live monitor my Macbook Pro's webcam activation in a similar manner to the green indicator light on the laptop itself. ...
Faceplanted's user avatar
5 votes
1 answer
84 views

`HISTSIZE=-1` causes 100% CPU on MacBook. Why does this happened?

I am setting up my first MacBook. I copied by .bash_aliases file from my Linux Mint. After that, I can not open Terminal with a bash session. I just see a black screen and bash taking 100% of my CPU. ...
Eugen Konkov's user avatar
1 vote
0 answers
49 views

A script to parse internet audio stream from Music.app and save it in a text file [closed]

I listen to the Internet radio in my Music.app on macOS Ventura and I would like a script that could parse the artist and the song name and paste it as a new line in a text file in the background ...
Dmitry's user avatar
  • 57
1 vote
2 answers
148 views

Escaped newlines make the code work wrong. Why?

From a Markdown style guide by Google: Because most commandline snippets are intended to be copied and pasted directly into a terminal, it's best practice to escape any newlines. Use a single ...
jsx97's user avatar
  • 143
0 votes
0 answers
48 views

How to change language of dictation on the fly in Ventura

I use the speech dictation tool to dictate text. But I do so in two different languages. To change the language of the dictation tool requires mouse clicking a few times which I try to avoid (hence ...
Blue badger's user avatar
0 votes
0 answers
134 views

Why does my DYLD_LIBRARY_PATH makes dynamic linker see a dylib that`ls` does not show me?

How did adding /usr/lib/ to my DYLD_LIBRARY_PATH cause this dynamic linking problem on my MacOS Ventura M1 MBP? I had set export DYLD_LIBRARY_PATH="...:/usr/lib:..." in my .bash_profile. $ ...
Jason Hemann's user avatar
0 votes
0 answers
115 views

In a bash script, how use osascript to minimize all windows of a specific app?

The following script opens the named files in the Skim app but fails to minimize them after that. What command will in fact minimize all windows of the app? #! /bin/bash for f in file1.pdf file2.pdf ...
murray's user avatar
  • 165
0 votes
1 answer
121 views

Trying to execute shell commands opening multiple terminals

I have a shell command which I use to setup multiple servers (metro, laravel, ngrok). Each of these processes needs to be executed in its own Terminal window. The issue right now is that all I'm able ...
gabogabans's user avatar
3 votes
3 answers
203 views

How to SSH when current user cannot access identity file?

I wish to find a shell one-liner on macOS that runs a command on a remote machine via SSH with a different non-root user (say, joe), using an identity file that only joe can access. The following one-...
Kartik Pontula's user avatar
-1 votes
1 answer
466 views

zsh:killed /usr/libexec/java_home -V after running /usr/libexec/java_home -V

I am trying to run /usr/libexec/java_home -v, and I am getting this error : zsh:killed /usr/libexec/java_home -V What did i try? Reinstalling brew. Changing shell to bash. It throws killed : 9 When ...
Prakarsh Pathak's user avatar
3 votes
1 answer
237 views

New iTerm2 tab displays ‘brew: command not found’ after updating PHP although brew is installed and included in PATH

I’m at the end of my rope here and hope you guys & gals can help out. I use the package bash-completion via brew, and, after this morning, I get this message when I open a new iTerm2 tab: -bash: ...
user avatar
2 votes
1 answer
77 views

convert or parse float to int in bash script fails in several ways

We have: MINUTES_UNTIL_ASK_TO_CLOSE="0,2" number_of_iterations=$((MINUTES_UNTIL_ASK_TO_CLOSE * 60 / 5)) There are a couple of weird behaviors when doing that. Firstly, the result should be: ...
chelder's user avatar
  • 217
0 votes
1 answer
797 views

`sudo` and other commands not found in terminal in startup options mode

(EDITED for specificity) When I use terminal in recovery mode (on a MacBook Pro with Apple silicon) a lot of bash commands seem to be missing and give me "command not found" errors when I ...
Empiromancer's user avatar
0 votes
1 answer
144 views

Update app from DMG: check versions

I download DMG with my app and update my app using it. I'm using the following bash script for this: set -e /usr/bin/hdiutil attach "mydmg.dmg" -mountPoint "/Volumes/My update" -...
Alexander Dyagilev's user avatar
1 vote
1 answer
190 views

ps return pid/name of process that called script.sh

I am running an app that calls script.sh and I would like to retrieve the invoking app's PID or name within that same script.sh. Ultimately, in my script.sh, I am trying to determine whether the app ...
John's user avatar
  • 989
2 votes
0 answers
66 views

Setting global/system variable visible from JVM in console and Eclipse

How to define global/system variable in OSX latest versions (Monterey/Ventura) that should be visible from console (JVM) and IDE (preferable Eclipse, IntelliJ has special knowledge how to handle this ...
FoxyBOA's user avatar
  • 133
1 vote
1 answer
55 views

How can I work out what a zsh command needs as input in a standardised way?

I'm trying to make some sort of GUI for the zsh/bash terminal, just as a fun learning project, but most commands in zsh/bash need you to put in some sort of extra input, alongside just the command. Is ...
pelican't's user avatar
0 votes
1 answer
65 views

Using sed to replace line results in two lines for each one replaced

I have been trying to automate something, using sed in a loop I wanted to do this: while IFS= read -r line; do sed -r -i '' "\"s|::set-output name=(.*)::(.*)\"|\"\1=\2\" >...
Rumbles's user avatar
  • 472
0 votes
1 answer
51 views

Simple method to mount a named drive from the command line?

To unmount a named drive from the command line I wrote a bash function which just tells the Finder via AppleScript to eject the drive: eject () { osascript -e "tell application \"Finder\&...
Paul R's user avatar
  • 1,095
1 vote
1 answer
744 views

How to auto source ~/.bash_profile on macbook everytime a new terminal is opened

On my work macbook, it seems my ~/.bash_profile doesn't get sourced every time a new terminal (tab or new window) is opened, and I have to do it manually. How can I automate this? I read through ...
David's user avatar
  • 131
1 vote
0 answers
26 views

Is there a simple way to start a bash script at login or startup WITHOUT revealing the terminal? [duplicate]

I know similar questions have been asked on forums, but due to the constraints of my script, the other solutions are either too complicated or do not work. Please forgive my lack of knowledge in the ...
hidden_machine's user avatar
0 votes
0 answers
53 views

The bash script in mac automator works for texts in Chrome, but not in Safari

Here is the code: if [ "$@" != "" ]; then timestamp="$(date +%Y-%m-%d' '%H:%M:%S)" dictlink="dict://$(echo $@ | sed 's/ /%20/')" ahref="<A ...
Jeff's user avatar
  • 1
1 vote
2 answers
141 views

Escape control characters in bash script

I need a solution to escape control characters from a string. What I need is to turn this: %f4^rH13#b$rHN into this: %f4\^rH13\#b\$rHN I found a solution working with GNU sed on stackoverflow, which ...
Nils's user avatar
  • 141

1
2 3 4 5
36