Stack Exchange Network

Stack Exchange network consists of 174 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 Mac OS X

0
votes
0answers
6 views

How do I unmount a drive with a script?

I installed sleepwatcher to run ~/.sleep before my computer goes to sleep. I need to umount /Volumes/Backup before my computer falls asleep. If I forget to do it, I get a message telling me that I ...
1
vote
1answer
12 views

What's the fish shell equivalent to `set -o vi` to get vi/vim key bindings to access command history and edit?

I'm one of the "cursed ones" that got their start in vi instead of emacs so the shell editing commands I am used to are set in bash with set -o vi but this doesn't work in the fish shell. How can I ...
0
votes
1answer
27 views

How to reset iTerm2 Window/Tab Title when disconnecting from remote host? [duplicate]

I have my bash_profile on my Mac and the remote computers I connect to setup to automatically put the hostname in the window's (or tab's) title area. A bash shell on my local machine A remote host ...
1
vote
1answer
23 views

Dealing with filename extensions - bash vs oascript

I have a script than closes open windows, but it only works when I have enabled the Finder "show all filename extensions" preference. Is there a robust way to accomplish this regardless of the state ...
5
votes
0answers
48 views

Apple's online version function support-sp.apple.com/sp/product?edid= does not work for all macOS versions

I would like to get the Apple marketing name, the code name, for a given version of macOS (e.g. 10.12 is macOS Sierra) from Apple's online service at support-sp.apple.com/sp/product?edid=. This is ...
4
votes
2answers
336 views

Is there a macOS equivalent of the Windows assoc command?

I am looking to change a file association on the Mac using some sort of script. I know that I can do something like that in Windows using the assoc command. Is there something scriptable on macOS ...
1
vote
1answer
40 views

Pass a variable from bash shell into Applescript? [duplicate]

Using the path defined in bash shell How would i pass the variable to applescript using osascript/applescript? Here's what I have so far.. The path of $FOOD_NUM is subject to change and it must be a ...
0
votes
0answers
88 views

Getting sudo: /etc/sudoers is owned by uid 501, should be 0

I am on Mojave When I run sudo today it is giving me: sudo: /etc/sudoers is owned by uid 501, should be 0 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy ...
0
votes
2answers
59 views

How to change the `sh` command to run scripts in bash 4

I have installed bash 4 with Homebred and bash --version shows me the version 4. If I have following test script: #!/usr/local/bin/bash # test-version.sh echo $BASH_VERSION And I make it executable ...
0
votes
0answers
38 views

What's the location of the system-wide bashrc for the brew-installed Bash?

I've installed Bash via homebrew to replace the old pre-installed one. However, the brew-installed Bash doesn't seem to read /etc/bashrc (or /usr/local/etc/bashrc). Where should I put the system-wide ...
2
votes
1answer
22 views

Is there a script for downloading videos from YouTube utilising only Wget or curl on iPhone?

I'm looking for a script that does not utilise youtube-dl and instead Wget or curl (coupled with things like sed and other base UNIX utilities that I wouldn't need to install, like no perl). I'm ...
1
vote
1answer
81 views

Make sourced .bash_profile works immediately in current window [closed]

I use a macOS to connect to an Ubuntu server, after defining new .bash_profile (like upgrading node.js or making new alias), I will have to exit the ssh and login again after sourcing the ....
11
votes
1answer
90 views

Open and focus file browsing dialog from command line

I'd like to open the native file browsing dialog from the command line, focus the dialog, and then get the full path of the selected file. The following works nicely, but the dialog is not focused ...
1
vote
0answers
44 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 ---...
1
vote
1answer
66 views

How do I copy multiple files to macOS's clipboard programmatically?

I ultimately want to have a bash function to-clipboard which gets file paths and copies the files to the clipboard. Using other scripting languages as helpers is okay. I currently have this for ...
0
votes
0answers
17 views

Is there a way to tab-complete Google Drive File Stream top-level folders in Bash?

I'm using Google Drive File Stream on High Sierra. It creates its own folder /Volumes/GoogleDrive with two folders inside this: My Drive and Team Drives. When in terminal and I want to CD to ...
3
votes
1answer
31 views

Alias in bash to Change Directory

When I am typing in a typical alias with my .bash_profile, my change directory is not working. I currently have the following: alias cdicloud="/Users/<username>/Library/Mobile Documents/com~...
1
vote
1answer
434 views

Disk full; Terminal in Recovery mode won’t delete files; boot kernel panics

I’m in a pickle here. macOS Mojave, just updated the other day. I managed to fill my disk up while creating a .dmg, and the system froze. I rebooted. Kernel panic. Boot to Recovery mode. Mount the ...
3
votes
0answers
21 views

iTerm2 - Split vertically with same command history

Is it possible to have same history of commands when I split window vertically in iTerm2 with Command + D as in current window? For example history command shows different list of commands, looks ...
1
vote
2answers
29 views

How can I run an app, when using the full path?

I need to start an app from another app with just one command on macOS. So, I can't use cd to get to the right path. I just need to run the app with the full path like: /my/path/to/app/myapp -...
7
votes
0answers
76 views

Get two-factor authentication code from terminal?

Is it possible to retrieve my Apple ID two-factor authentication code via the terminal instead of the GUI prompt, i.e. via ssh or a bash script? I don't own any Apple devices other than a headless ...
0
votes
3answers
89 views

Running `nano` uses the old nano(2.0.6) even though nano 3.0 is installed

I installed nano 3.0 with brew install nano, but when I run nano --version, it shows version 2.0.6, which is what came with macOS. Screenshot: echo $PATH also shows that /usr/local/bin is listed ...
3
votes
2answers
141 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 | ...
0
votes
0answers
31 views

defaults: Writing Nested Directories and Arrays

I'm trying to write a bootstrapping Bash script that will implement the preferences for some of the apps I use, through the defaults write command. There are particular cases that I find the structure ...
5
votes
1answer
121 views

Sort with case-sensitivity (lowercase before uppercase) in macOS in the Terminal

I am trying to use the answer in GNU Sort by case-sensitive to sort a file in my Mac OS. My file.txt looks like this: "Best" "A" "BEST" In the second answer to the mentioned question, it says that ...
0
votes
1answer
23 views

-bash: export: `Drive/Courses/Programming/nand2tetris/tools': not a valid identifier

Every time I log in to the terminal, I get this error. -bash: export: `Drive/Courses/Programming/nand2tetris/tools': not a valid identifier -bash: export: `Drive/Courses/Programming/nand2tetris/tools'...
4
votes
2answers
71 views

Bash - Suppressing output to STDOUT

I've written a script for fresh macOS installs that installs Homebrew, Cask, and a bunch of apps I like, along with creating a .vimrc file. Thanks to an answer by daniel Azuelos (located here: Best ...
3
votes
1answer
137 views

Open Terminal Window with Predefined Environment Variables (Including `PATH`)

I'm trying to create a .command file which will open a terminal window with predefined Environment Variables (Including PATH). I tried this: #!/bin/bash # Adding CMake to Path export PATH=$PATH:/...
0
votes
0answers
39 views

Removing directories from PATH

I am trying to run rkhunter, but it is giving me this output: stack/security/rkhunter-1.4.6 ➜ sudo rkhunter --check Password: Invalid BINDIR configuration option: Invalid directory found: ~/.dotnet/...
1
vote
3answers
635 views

How do I prevented the hackers (secret intel) manipulating my terminal again [closed]

How do I prevented the hackers manipulating my terminal again so that my terminal works correct again? Here in the Netherlands we perform cybertest at the company where we work and the attacks are ...
2
votes
1answer
42 views

Open homebrew version of emacs instead of Apple version

I installed emacs 26.1 via brew install emacs, but when I try to start emacs via command line, only the outdated Apple-supplied version (22.1.1) opens. However, emacs is apparently correctly linked: ...
0
votes
1answer
31 views

Turn on Proxy Without Password Prompt

I am looking for a way to do the equivalent without prompting for password. I need it to be a native way that does not require the user to change any configuration files (including sudoers). And GUI ...
1
vote
1answer
289 views

Endpoint has been activated through legacy launch on Mac Mini

Asking this here as I don't think it's a Linux problem. My Mac Mini sits on a desktop and is the 'central authority' for all of my backups. I have nine Linux virtual machines on a server on which ...
2
votes
2answers
77 views

Zsh vs Bash shell in Terminal

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
38 views

macOS terminal: quick way to edit command options after bash/zsh autocomplete

The issue I use autocomplete from history a lot whether that's with up-arrow or typing the first few letters and completing the whole command including all arguments (options and others) with right-...
2
votes
1answer
248 views

Why is rename command missing from macOS?

I usually rename files and directories with the mv command. I'm reading a book on bash shell that mentions the rename command. When I executed man rename a man page was shown. However, when I entered ...
3
votes
2answers
40 views

Trigger the Creation of a Specific Preference List?

I have the following function: hardware_model () { local hardware_mod hardware_mod=$(defaults read ~/Library/Preferences/com.apple.SystemProfiler.plist 'CPU Names' \ | cut -sd '"' -f 4 \ | ...
1
vote
0answers
45 views

Terminal Startup command not found

Whenever I open my terminal there is a line that reads, -bash: 6ee67d3f2005ceaf5266c966198b7f3c165bf5d7: command not found This is shown after the line that states my last login information. I am ...
6
votes
2answers
575 views

“bash -D” command doesn't seem to do anything useful

I'm finally getting around to getting more familiar with the shell after all these years. I was exploring the man page for bash and looking at the -D option, which, according to the manual: -D ...
3
votes
1answer
70 views

Unable to resolve hostnames inside macOS chroot jail

I just created a chroot jail with inetutils, coreutils and bash. Most of the things seem to work. I can ping ip addresses and hosts that are inside /etc/hosts, however, I can't ping hosts that are not ...
0
votes
1answer
32 views

Searching forward through bash history

You can hit ctrl-r from the command line to initiate a search for a previously issued command. You can then hit ctrl-r to cycle back through the older commands that match the search string. However, ...
0
votes
1answer
142 views

Bash history not initially remembered with iterm2

I've got an annoying problem with iterm2 not remembering my history when I close out a terminal window. I'm not sure if it might be my .bash_profile config or what. Here is what is happening: 1) ...
2
votes
2answers
182 views

Can't open a PDF from Terminal on Mac because it ‘couldn't get a file descriptor referring to the console’

I tried to use the command: open <filename.pdf> but the message I got was Couldn't get a file descriptor referring to the console What can I do?
5
votes
4answers
197 views

How can I find the “friendly name” of the operating system from the shell / Terminal / bash?

I know that I can use sw_ver to find this information: ProductName: Mac OS X ProductVersion: 10.14 BuildVersion: 18A353d …and I know I can find other things like uname can give me some types of ...
3
votes
2answers
268 views

How to use a pipe in a script optionally

How can I achieve the conditional usage of a pipe for a command execution in a script. It looks like this #!/bin/bash XCPRETTY=" | xcpretty" if [ $(which xcpretty | wc -l) == 0 ]; then XCPRETTY="...
0
votes
1answer
73 views

netsh equivalent command in OSX

How would I construct the bash equivalent of this command? netsh -c interface ipv4 add neighbors "Wi-Fi" "10.0.1.1" "b8:8d:12:57:2d:50" store=persistent Thanks!
0
votes
0answers
30 views

Terminal and iTerm appear to be partially opening in zsh

I recently installed Julia on my iMac running High Sierra. Julia seems to want to run in the Z-shell whereas I normally use bash. I haven't run Julia today but my Term2 windows are screwed up since ...
1
vote
1answer
391 views

Scrolling doesn't work in Terminal for commands like less

I used to be able to scroll using the trackpad through git diff or man pages which both use less when the output doesn't fit on screen. Today I restarted my computer and that behaviour is gone and I ...
1
vote
1answer
123 views

Mac terminal says “-bash: echo: write error: Broken pipe” on opening

I opened my terminal, like I do most days Mon-Fri, and was surprised to see this error: Last login: Fri Jul 27 17:19:25 on console -bash: echo: write error: Broken pipe SomeMac:~ user568458$ ...
1
vote
0answers
61 views

Display emoji faces for correct & wrong commands in terminals

I want to customize my terminal to display emoji faces, showing sad face for wrong command and happy face for right command that I enter. Is there any way that I can do this using my terminal bash. ...