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
42 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
77 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
1answer
26 views

What modifies the PATH variable on macOS?

echo $PATH$ returns a different result than the variable I define in .bashrc. .profile is empty. What else could be modifying PATH? The directories listed are all things I would have entered (i.e., ...
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
17 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
17 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
42 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
29 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 ...
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 ...
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
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
27 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 ...
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
1k 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
281 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?
1
vote
1answer
70 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
774 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
305 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
17 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 ...
27
votes
7answers
99k 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
66 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
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
42 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
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
56 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 ...
10
votes
1answer
3k views

--group-directories-first option for “ls” command

I am using both Ubuntu 16.04 and OS X. alias ll='ls -Flh --group-directories-first' This is an alias in my bashrc, but somehow --group-directories-first option got illegal in OS X after I upgraded ...
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 ...
60
votes
14answers
45k views

How to get a notification when my commands are done

I'm running a series of commands on the command line that takes approximately twenty minutes to complete. I'd like to see some sort of notification on my Mac when these are finished so I don't need ...
6
votes
2answers
2k views

Default Bash 3 overriding shebang /bin/bash with brew installed bash 4

Background Bash 4 installed successfully using homebrew and the additional steps required to make bash 4 your default shell. Many guides on the net with a simple google: Example Bash 4 upgrade guide ...
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 ...
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 ...
2
votes
1answer
95 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,...
6
votes
2answers
1k views

Preview image from pipe

I have a command line utility, let's called as: produce_image. So i can do the following in the Terminal: $ produce_image > some.jpg $ open some.jpg #opens Preview.app also, I have ImageMagick ...
2
votes
0answers
98 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 ...
7
votes
2answers
4k views

How do I make a bash script so that I can drag its input on top of the icon?

I need to make a bash script to that I can drag a .rar file on top of it and then the script will receive the pathname of that file as argument 1 ($1). I have made the bash script, but how do I make ...
35
votes
3answers
24k 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 ...
2
votes
2answers
77 views

Launch different apps based on file name (other than the extension)?

I'd like to have different apps handle .jpg files based on a naming convention I'll use for the .jpg files. Specifically most will go to Xee, but ones containing thumb should instead cause VLC to be ...
1
vote
1answer
38 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 ...
1
vote
1answer
32 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
45 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 ...
317
votes
11answers
168k views

git auto-complete for *branches* at the command line?

On my Linux machine I have autocomplete for branches with Git. [Note we are talking about git branch completion, not bash completion (e.g. commands, files, etc). Thus NOT Lane's answer at all] For ...
1
vote
1answer
201 views

How to open multiple iTerm2 tab with admin privilege

So I have an executable program in my /usr/local/bin/ called myApp. I need to run multiple myApp processes in new iTerm2 tabs with sudo. The file structure is like this: --myFolder ----v1 ----v2 ---...
10
votes
3answers
4k views

Installing ffmpeg from dmg and then running from a terminal, is there a better way?

From here: https://ffmpeg.org/download.html#build-mac I chose static builds 64-bit which too me to https://evermeet.cx/ffmpeg/ I then downloaded this: and opened it using this: which gave ...
0
votes
0answers
21 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
77 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 ...