Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [bash]

The default Unix shell used by Terminal in macOS

1
vote
1answer
83 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: $ ...
0
votes
1answer
64 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 ...
0
votes
0answers
30 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
18 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
18 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
44 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
31 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 ...
1
vote
2answers
31 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
29 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
57 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 ...
40
votes
3answers
3k 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 ...
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?
3
votes
3answers
282 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
22 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?
4
votes
3answers
306 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
18 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
15 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 ...
0
votes
1answer
27 views

How to forward delete in Macports?

When using the interactive Macports shell (running port), is there a way to delete characters to the right of the cursor? Normally, you can simply use key the combination Fn + Delete to forward-...
0
votes
0answers
17 views

Mac OS terminal tab separate histories

Terminal gets bash to go through and elaborate dance to keep separate histories for each tab. Normally (for me anyway) after a restart of Mac OS these separate histories are lost and you are left ...
0
votes
1answer
44 views

Why isn't a binary not being found in my PATH?

I've got a Python project which uses a virtual environment. In my project folder, there is a bin/ folder which contains all the executables needed by the project. To use these, you run source bin/...
0
votes
2answers
67 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 ...
0
votes
1answer
20 views

Can't store multiple arguments with read -p in macOS terminal using bash

I am trying to store words from an input as parameters with read -p as follows : read -p "Enter your command: " cmd arg1 arg2 echo "$cmd" echo "$arg1" echo "$arg2" With this, $cmd ...
0
votes
1answer
58 views

The command for alias local='…' gets run on terminal open

I have an alias set up in my .bash_profile file: alias local='npm run start-local', and for whatever reason when I open a new terminal session it is trying to run that command npm run start-local ...
0
votes
1answer
19 views

Disable bash command completion (bash v. 5.0.7(1))?

I'm trying to remove all tab completion features from my shell to start over and rebuild it properly. I have homebrew installed and it's running bash v. 5.0.7(1). I had the bash-competion brew ...
0
votes
1answer
9 views

“type” and “which” programs coming up empty for programs on the path

Here is an example of a program that is in the path, find-able by tab / command-completion and accessible but not found by which: kafka- However running which kafka or type kafka comes up empty ...
0
votes
1answer
33 views

Retrieve folder's name for Automator's shell script action

For the sake of concatenating video files, I've assembled bits of code found online into a ffmpeg bash script on Automator. It works. However, I'd like for the output file to be named after the folder ...
2
votes
1answer
99 views

MacBook Pro stuck on GRUB minimal Bash at startup

I had a dual boot Linux Mint 19 and macOS on my MacBookPro11,2. Since the CPU was overheating with Linux, I decided today to delete the Linux partition. Little problem, when I start my MacBook Pro now,...
2
votes
0answers
100 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 ...
1
vote
1answer
33 views

Running Compiled AppleScript from DMG Doesn't Work

As a follow up for my previous question (Set the Working Folder of .app Created by Apple Script) I have the following problem. I have an AppleScript which is Poor man's Installer: tell me to ...
0
votes
1answer
46 views

Set the Working Folder of `.app` Created by Apple Script

I have a simple Shell File .sh which copies files form the PWD to a destination folder. This is basically Hand Made installer of a program. I want to create an APP from it. The idea is to have the ...
0
votes
0answers
22 views

dyld monitors DYLD_ variables behind the scenes [duplicate]

If I invoke DYLD_X=foo /bin/bash -c 'echo "<$DYLD_X>"' the output is <> while MY_VAR=bar /bin/bash -c 'echo "<$MY_VAR>"' outputs <bar> Switching to Bash 5: DYLD_X=foo /...
1
vote
1answer
72 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 ...
1
vote
1answer
52 views

bash $PS1 containing an emoj

This question is related to https://apple.stackexchange.com/a/357132/44531 I would like to have a space after the emoj 😱. I've tried in the script below but I'm getting two lines instead of the ...
0
votes
0answers
42 views

On Mac terminal keyboard key action macros?

I want to assign long commands in one key on Mac terminal. For example, I have assigned command php bin/magento under F13 key from "Terminal → Preference → Profiles → Basic → ...
0
votes
0answers
24 views

Add IP alias on macOS like on Ubuntu? [duplicate]

I want to add a second IP address on my Mac like on Ubuntu. On Ubuntu I use this: $ sudo ip addr add 192.168.1.12/24 dev eth0 On my Mac I used this: $ sudo ifconfig en0 alias 192.168.1.12/24 On ...
3
votes
1answer
45 views

Is it possible to fix the spacing when using “ls” with colored output?

This is the exact same issue found here: https://unix.stackexchange.com/questions/165154/changing-the-spacing-between-files-in-ls When you run the command ls -G or CLICOLOR=1; ls the spacing in the ...
2
votes
1answer
21 views

Set sshd to serve different shell based on `host`

I want my local sshd to serve different shell, based on the host. Example: ssh user@hostname1 -> get's bash ssh user@hostname2 -> get's fish Is it possible, and if so, how can it be done?
2
votes
1answer
85 views

Terminal PATH startup message

I messed up when installing Cisco Packet Tracer for Linux and it some how changed a few bash files. After a few hours of looking around and changing my PATH, when I open a new Terminal window I get a ...
2
votes
1answer
46 views

How can I make sure that the title of a Terminal tab/window is identical to the command I typed

I noticed that for aliases etc the title of a Terminal tab/window often isn't the same as the command I typed. This is sometimes confusing, especially for long-running processes with similar names. ...
0
votes
1answer
94 views

Why does chunkwm fail with “Permission denied” error for .chunkwmrc

ashleyharvey@Themis:~$ ls -al .chunkwmrc -rw------- 2 ashleyharvey staff 4.7K Apr 4 22:24 .chunkwmrc ashleyharvey@Themis:~$ chunkwm /bin/bash: /Users/ashleyharvey/.chunkwmrc: Permission denied So, ...
1
vote
1answer
31 views

LSCOLORS format

I want to configure my .bash_profile and I've seen this post about BSD based ls configuration: https://www.cyberciti.biz/faq/apple-mac-osx-terminal-color-ls-output-option/ I just don't know what is ...
1
vote
0answers
57 views

iTerm2 still opens old shell after Bash upgrade

I tried upgrading my MacOS Bash from 3.2 to the latest version as in this article. It involves installing the latest Bash with Homebrew and then setting the default shell with chsh. However, chsh ...
0
votes
1answer
53 views

Get parent of symbolic link instead of original folder

I have a project with node_modules folder that contains a symbolic link to another project. The problem that inner project takes configs from parent project (etc ../../../config) and thus cannot find ...
1
vote
3answers
94 views

osascript display dialog hangs when screen is off; detect unavailable GUI/display from bash or applescript?

background I've been working on a backup script that runs occasionally via launchd. When it runs, it prompts me with something like: osascript -e "display dialog \"Is now a good time to back up?\"" ...
4
votes
0answers
30 views

Is there a script/cmd that I can create/run that will allow me to install .dmg? [duplicate]

I have been working on a "Mac Rollout Project". After I run the Macs through the Apple setup, I have a list of .DMG / Applications that I have to install. There is no particular order that the .DMG / ...
0
votes
1answer
49 views

Failing to send Wake-On-LAN UDP packet with netcat

I'm trying send a WOL packet from a bash script under Mojave, much like https://stackoverflow.com/a/31588036/9370650, without any third-party utilities, such as the nifty https://github.com/jpoliv/...
4
votes
1answer
1k views

Why is .bash_history periodically wiped?

This is the second time it's happened. I just tried grep-ing some historical commands and came up empty. a look at my bash history shows that it's practically empty. Like it's been wiped clean. I use ...
3
votes
1answer
70 views

Extract numbers from string using shell

Using shell script, how do I extract two sets of numbers from a string like "R14C11"? I'd like to get the result as an AppleScript list. R14C11 -> {14, 11} R5C9 -> {5, 9} "R" and "C" will be ...
1
vote
1answer
78 views

Automator to remove all text before hyphen ( - )?

I'm trying to create an Apple Automator application that will rename a group of files by removing all text before and including a hyphen ( - ) that will post an error if trying to rename a file with ...
1
vote
1answer
39 views

How can I change the ownership of the unwritable directories for Homebrew?

I had admin account before and I deleted the admin and made the user as admin because it was bit of pain in neck. This is now the admin user called zuhairhallak. Before, installing Homebrew, it was ...