terminal – Neither .bashrc nor .profile gets read when bash is set as the shell in macOS 11

I know macOS 11 is trying hard to convince me to use zsh, but it also says I can choose another shell, which I have: chsh -s /bin/bash. The problem is, it no longer works as it did, as it neither reads my .profile nor my .bashrc when I start Terminal.app or iTerm.app. I just get this:

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.

If I now manually type bash, things happen as they should:

bash-3.2$ bash
(Timer is unset. Use timer_start) core utils setup finished
(3) Executing $HOME/.bashrc
(7) Reading utility functions and aliases
(10) core utils setup finished
(14) Reading aliases and functions
(22) ssh aliases
(26) conversions
(30) Use htop if available
(36) small utils and aliases
(40) aliases: setting up node aliases
(44) aliases: finished setting up node aliases
(48) webserver aliases
(52) global aliases and functions finished
(56) Reading utils for git prompt
(63) Reading bash completion files
(69) /Users/carlerik/.bash_completion.d/azure
(75) /Users/carlerik/.bash_completion.d/git
(89) /Users/carlerik/.bash_completion.d/npm
(95) /Users/carlerik/.bash_completion.d/tmux
(100) Reading color codes
(105) Read /Users/carlerik/.bash.d/colors
(130) Read /Users/carlerik/bin/z.sh
(135) Reading local settings for this machine
(140) Load personalized bashrc for mac
(152) Read /Users/carlerik/.bashrc.local
This setup is missing 'direnv'. Please install it for per-directory overrides
(157) Finished bash setup
(205) Read /Users/carlerik/.secret

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.

carlerik at idas-imac in ~

All the timing stuff is due to a DEBUG setting I have enabled (my .bashrc in my dotfiles). So it works as normal.

How can I get macOS 11 to use my .bashrc and/or .profile on startup?

I have even tried overriding the terminal settings in both apps from the standard logon shell to /bin/bash --rcfile $HOME/.bashrc with no further success.

For reference, this is my .profile:

printf "Reading .profile"
export DEBUG=1

if ( -n "$BASH_VERSION" ); then
    # include .bashrc if it exists
    if ( -f "$HOME/.bashrc" ); then
        . "$HOME/.bashrc"

# other stuff
# ...
# other stuff end

if ( -f "$HOME/.profile.local" ); then
    . "$HOME/.profile.local"

terminal – Why is my Bash Profile suddenly not available and no commands work?

terminal – Why is my Bash Profile suddenly not available and no commands work? – Ask Different

applescript – How to pass variable in bash script to osascript

I’ve spent hours researching this question, but none of the answers that I’ve found seem to work. I want to pass a POSIX path to some AppleScript running in a shell script, but nothing that I’ve tried lets AppleScript use the variable.

Here’s something that shows (in the simplest possible form) what I’m trying to do (my actual script will use Microsoft Word to open the file named in the path and then save it to another format):



osascript << 'EOD'
display dialog "$INFILE"

I’ve tried escaping the quotes; I’ve tried double-single-double quotes; I’ve tried parentheses and braces; I’ve tried using the filename as a parameter and setting a variable to item 1 of argv. Nothing works that I’ve tried. The answer is probably obvious to any expert, and I’ll be grateful for any help.

bash – Running a script as sudo wihout terminal

I’m working on a tool for a client which needs to be run as sudo (I found out later that it doesn’t work without sudo as I’ve never worked on a Mac before). I have the binary ready, and I wrote a shell script to call that binary as sudo.

However, the problem is that the shell script isn’t able to find the binary, and also it outputs the wrong path with pwd. The location of the binary isn’t fixed and it could be placed anywhere, so I cannot hardcode the path into the shell script.

To elaborate a little on the pwd outputting wrong path: the script was placed in a location whose path is /Volumes/MySSD/MiscFiles/ and the output of pwd through the shell script was /User/<my client's username>.

Another important constraint is that my client cannot operate a terminal, so for him when he double clicks on the executable it starts. But I need this to run as sudo otherwise it doesn’t work.

So, my question is, is there a way to make it so that when I double click the binary from the file explorer (I think it is called Finder in Mac), it should run as sudo.

Or,is there something wrong I’m doing in my shell script?

this is my shell script

# sudo ./actiontool #actiontool is the binary, and this command didn't work, it gave a no such file or directory error
# echo $(pwd) #this echoed the wrong path
sudo .$(pwd)/actiontool #also didnt work as $(pwd) outputs the wrong path

linux – Updating text in a Markdown document with Bash

This is a small script to update my project’s README file. Notes on improvements from any aspect are welcome!

Here is the document it updates.

readme.sh (Executed like so: ./readme.sh)

#!/usr/bin/env bash

export LANG=en_US.UTF-8
export LANGUAGE=en:el

set -eu

domain_linecount=$(cat black_domain.txt | wc -l)
ipv4_linecount=$(($(cat black_ipv4.txt | wc -l)-$domain_linecount))
ipv6_linecount=$(($(cat black_ipv6.txt | wc -l)-$domain_linecount))

domain_entries=$(printf "%'d" $domain_linecount)
domain_size=$(du -h black_domain.txt | gawk -F't' '{ print $1 }')

ipv4_entries=$(printf "%'d" $ipv4_linecount)
ipv4_size=$(du -h black_ipv4.txt | gawk -F't' '{ print $1 }')

ipv6_entries=$(printf "%'d" $ipv6_linecount)
ipv6_size=$(du -h black_ipv6.txt | gawk -F't' '{ print $1 }')

sed -i 
    -e "s/(<td id="domain-entries">).*(</td>)/<td id="domain-entries">$domain_entries</td>/g" 
    -e "s/(<td id="domain-size">).*(</td>)/<td id="domain-size">${domain_size}B</td>/g" 
    -e "s/(<td id="ipv4-entries">).*(</td>)/<td id="ipv4-entries">$ipv4_entries</td>/g" 
    -e "s/(<td id="ipv4-size">).*(</td>)/<td id="ipv4-size">${ipv4_size}B</td>/g" 
    -e "s/(<td id="ipv6-entries">).*(</td>)/<td id="ipv6-entries">$ipv6_entries</td>/g" 
    -e "s/(<td id="ipv6-size">).*(</td>)/<td id="ipv6-size">${ipv6_size}B</td>/g" ./.github/README.md
# xmlstarlet is probably better to handle this

bash – Linux: Remap special key only for the shell

When I am in the shell, I want Caps Lock to be mapped to Escape. However, when I am doing anything else, e.g. writing a question on StackOverflow, I want Caps Lock to be Caps Lock. In my preliminary searching, I’m not seeing anything that would work for this; not as a standalone config, nor in a .bashrc.

Specifically I am on Linux Mint (latest version), which I do not expect is a substantial factor here, and primarily using bash. Solutions which only work for bash and won’t cover any other shell are acceptable, but if there’s a more global solution I won’t have to rework if I switch to zsh or something more esoteric like mosh, that would be better.

Install docker and docker-compose from a bash script?

My project runs in a docker container and I am trying to run the following commands in a bash script:

docker-compose down

docker-compose pull

docker-compose up

The issue these commands are “not found” so I figured out that docker and docker-compose are not installed in my container’s project. I am now trying to install docker in the same bash script as the above commands by attempting to install if a version of docker doesn’t exist:

if ( -x “$(command -v docker)” ); then

echo “Update docker”

echo “Install docker”
pip install docker

The error I get is “pip: not found.” when executing ‘pip install docker.’ Does anyone know how to install docker from a bash script?

terminal – bash script that checks the content of the current directory

Write a bash script that checks the content of the current directory, if it is a file, the filename is prefixed with “FILE_” and if it is a directory, the directory name is prefixed with “DIRECTORY_”. For example if you have two files file1.txt and file2.txt, the new names will be FILE_files1.txt and FILE_files2.txt and if you have two directories dir1 and dir2, the new names will be DIRECTORY_dir1 and DIRECTORY-dir2.

bash – How to send html email from file with sendmail and postfix

I have a file with several lines as shown below
Each 4 lines is one email in queue ready for send
I intend to send with the command:
head -4 $file |sendmail -t
Each email is send OK but not arrive in html form
Any ideas?
Thanks in advance

From: myshop.com
To: email@email.net
Subject: Test 34234
\Mime-Version: 1.0;nContent-Type: text/html;ncharset=’utf-8′;n\
Test 2396234\

script – ¿Cómo soluciono sed: -e expresión #1, carácter 22: orden `s’ sin terminar? en bash

Mi scrip tienen la siguiente linea:

argsed="s/'manolo', /'manolo','"$custom"', /g";

Pero cuando lo ejecuto me da:

sed: -e expresión #1, carácter 22: orden `s' sin terminar

Se que el problema esta en los espacios que hay tras las comas.
¿Cómo debo manejar ese carácter especial?
ya he probado a poner una barra antes del espacio: ” ” y sigue dando error.

pd:¿y si quiero poner un salto de linea?

DreamProxies - Cheapest USA Elite Private Proxies 100 Private Proxies 200 Private Proxies 400 Private Proxies 1000 Private Proxies 2000 Private Proxies 5000 Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive.com Proxies-free.com New Proxy Lists Every Day Proxies123.com Buy Cheap Private Proxies; Best Quality USA Private Proxies