I can't find nix-env, nix-build, nix-shell etc. on MacOS Catalina.
I installed with:
sh <(curl https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume
and was able to run them yesterday. I restarted my computer and can no longer find them. find / -name nix-env | grep nix-env shows nothing.
I tried installing again with the same command (sh <(curl https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume) but this time it exists immediately with 0 status code.
I suspect I need to do something to mount a virtual drive.
You should follow Notes on the recommended approach.
It looks like the volume is not mounted (check /etc/fstab state with vifs as described in documentation).
Use the Disk Utility UI to remove the nix volume (sudo rm -rf /nix won't work).
Then run the script again and cross fingers your fingers this time: sh <(curl https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume
While Nix (amongst others) installs with bash newer MacOS do use zsh instead of bash.
So you need to update your .zshrc to source this command from bash, too.
In your terminal start editing with:
sudo nano ~/.zshrc
and add:
source ~/.nix-profile/etc/profile.d/nix.sh
Reload and test with
source ~/.zshrc; nix --version
Related
I run the command source ~/.bash_profile and get the following error:
$ source ~/.bash_profile
-sh: /Users/chaklader/.sdkman/contrib/completion/bash/sdk: line 37: syntax error near unexpected token `<'
-sh: /Users/chaklader/.sdkman/contrib/completion/bash/sdk: line 37: ` done < <(curl --silent "${SDKMAN_CANDIDATES_API}/candidates/all")'
The login shell that I use is bin/sh:
Whats the issue here and how to solve it?
This is how I solved the issue with the provided steps:
Install Homebrew from the docs on their homepage
Install Git using Homebrew (optional, but nice to have a more up-to-date git)
brew install git
Now install bash:
brew install bash
Add this install of bash to the allowed shells list:
echo '/usr/local/bin/bash' | sudo tee -a /etc/shells;
Homebrew installs things to /usr/local/Cellar/ by default, then symlinks any binaries to /usr/local/bin, so you've now got the latest bash sitting at /usr/local/bin/bash
Finally, change your shell to use this new one:
chsh -s /usr/local/bin/bash
Open a new terminal window/tab, and run these commands to double-check your work:
$ echo $SHELL
/usr/local/bin/bash
$ echo $BASH_VERSION
5.1.8(1)-release
This also solved the issue for running the source ~/.bash_profile whenever I open a new window in the terminal.
Reference:
The answer is from here How do I install Bash >= 3.2.25 on Mac OS X 10.5.8? by user jeffbyrnes
I'm using kubectl from within a docker container running on a Mac. I've already successfully configured the bash completion for kubectl to work on the Mac, however, it doesn't work within the docker container. I always get bash: _get_comp_words_by_ref: command not found.
The docker image is based on ubuntu:16.04 and kubectl is installed via the line (snippet from the dockerfile)
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && \
mv kubectl /usr/local/bin
echo $BASH_VERSION gives me 4.3.48(1)-release, and according to apt, the bash-completionpackage is installed.
I'm using iTerm2 as terminal.
Any idea why it doesn't work or how to get it to work?
Ok, I found it - I simply needed to do a source /etc/bash_completion before or after the source <(kubectl completion bash).
check .bashrc
enable programmable completion features (you don't need to enable
this, if it's already enabled in /etc/bash.bashrc and /etc/profile
sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
A Linux container executed on macOS creates a separate environment and
yes, it looks like a thread from macOS shell, but it is not. Shell history,
properties, functions are a different story.
Moreover, if the container has no persistent volume mounted all of those parameters will be transisten and won’t survive container’s restart.
The approach to have bash completion of both of them - macOS and Ubuntu
Linux are similar, but require different steps to take:
macOS side - permanent support for kubectl bash completion:
use homebrew to install support:
brew install bash-completion
kubectl completion bash > $(brew --prefix)/etc/bash_completion.d/kubectl
Ubuntu container’s approach to have kubectl and bash completion support build in:
You can adapt this set of commands and use it in Dockerfile during the image preparation:
apt-get update && apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubectl
echo 'source <(kubectl completion bash)' >> ~/.bashrc
If afterwards you or user executes /bin/bash in running container then you should get completion working.
docker exec -it docker_image_id /bin/bash
this will start bash shell with the bash completion.
I united two top comments for Ubuntu 22.04
edit ~/.bashrc and add
source /etc/bash_completion
before
source <(kubectl completion bash)
alias k=kubectl
complete -o default -F __start_kubectl k
I am running docker and I want bash command completion for docker commands and parameters.
If you have already homebrew bash-completion installed just install the docker completion script into the bash_completion.d
curl -XGET https://raw.githubusercontent.com/docker/cli/master/contrib/completion/bash/docker > $(brew --prefix)/etc/bash_completion.d/docker
Note: If you do not have homebrew bash-completion installed, follow these instructions to install it before you execute the line above.
Note: the completion depends on some functions defined in debian bash-completion. Therefore, just sourcing the docker completion script as described in completion/bash/docker may not work. If you try to complete docker run (by hitting TAB) you may get an error like __ltrim_colon_completions: command not found. This could mean that you have not installed the bash-completion scripts.
The official Docker for Mac page has a section on installing bash completion:
https://docs.docker.com/docker-for-mac/#bash
If you have Homebrew bash completion installed:
cd /usr/local/etc/bash_completion.d
ln -s /Applications/Docker.app/Contents/Resources/etc/docker.bash-completion
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-machine.bash-completion
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-compose.bash-completion
The completion scripts come with Docker Beta. I want them to stay up to date. So, on OS X...
Install homebrew's bash-completion
Symlink the files
find /Applications/Docker.app \
-type f -name "*.bash-completion" \
-exec ln -s "{}" "$(brew --prefix)/etc/bash_completion.d/" \;
The stumbling point for me was that once you brew install bash-competion, you have to add few lines in your .bash_profile to load it once you launch Terminal:
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
Source:
http://davidalger.com/development/bash-completion-on-os-x-with-brew/
Because I haven't found anywhere a step by step documentation, I've made a quick script to install homebrew, bash-completion and eventually the completion scripts for docker.
https://github.com/HypnoTheNomad/docker-bash-completion-macos-brew
The auto completion of docker needed not only for mac, its also needed for ubuntu / bash terminals.
In Ubuntu
curl -ksSL https://raw.githubusercontent.com/docker/cli/master/contrib/completion/bash/docker |sudo tee /etc/bash_completion.d/docker
Completion will be available upon next login.
Since its top result in google I added answer here.
The official Docker site has a section for Command-line completion, and for Mac to:
https://docs.docker.com/compose/completion/#mac
Helped for me with Homebrew:
brew install bash-completion
After the installation, Brew displays the installation path. From documentation is correct for me:
/usr/local/etc/bash_completion.d/
Run the script:
sudo curl -L https://raw.githubusercontent.com/docker/compose/1.25.4/contrib/completion/bash/docker-compose -o /usr/local/etc/bash_completion.d/docker-compose
Open and add following in the end of your file ~/.bash_profile:
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
Restart terminal. It's all.
Guide to setup autocomplete for ZSH on Mac OSX
Follow these steps if you are using oh-my-zsh and autocomplete is not working:
Step 1:
Make the following three links:
ln -s /Applications/Docker.app/Contents/Resources/etc/docker.zsh-completion /usr/local/share/zsh/site-functions/_docker
ln -s /Applications/Docker.app/Contents/Resources/etc/docker-compose.zsh-completion /usr/local/share/zsh/site-functions/_docker-compose
Step 2:
Either add autoload -Uz compinit; compinit to .zshrc
or run echo "autoload -Uz compinit; compinit" >> .zshrc in your shell
Just to be said:
if you use brew:
brew install docker
will do all what you need. It includes brew link docker which installs the completion into `brew --prefix`/etc/bash_completion.d/docker
same topic, same answer for docker-machine, docker-compose, etc. ...
else (perhaps you are using Docker Beta (new "more native" docker installation package without Virtualbox) you still have to add it manually, then follow Michael's answer plus have a look at the additional completion scripts for docker-machine, docker-compose and some shell-helper that are handled in the 'script' from CodeCorrupt
I used home-brew to setup tmux on a mac. When trying to run tmux I keep on getting this error
open terminal failed: missing or unsuitable terminal: xterm-256color
any suggestions?
Your system doesn't have xterm-256color. You could:
Set TERM to something other than xterm-256color outside tmux (try just plain export TERM=xterm).
See if there is a package containing xterm-256color, perhaps a later version of ncurses or terminfo.
Install it manually from another system with something like:
infocmp -x xterm-256color > out
Then transfer the "out" file to your Mac and try:
tic out
This happened to me during a system upgrade. Unfortunately I did not see a way besides restarting: tmux kill-server and then run tmux.
you can just type export TERM=xterm in console when you see this error, or put export TERM=xterm in the file ~/.bash_profile and source ~/.bash_profile. then you may never get this error again.
This works fine on my debian.
TL;DL
sudo ln -sf /usr/share/terminfo/x/xterm-color /usr/share/terminfo/x/xterm-256color
Details
Maybe the file /usr/share/terminfo/x/xterm-256color is corrupted. It may be fixed upon (system/package) upgrade / reinstall.
Meanwhile you can use other terminfo entry. You can get the available options by ls /usr/share/terminfo/x.
I am having the same problem and using xterm-16color meanwhile.
To set terminfo, you can type reset in the terminal, then select the terminfo:
username:~$ cd /usr/share/terminfo/x
username:x$ ls
x10term xnuppc+200x64 xterm-24 xterm+pcfkeys
x1700 xnuppc-200x64-m xterm-256color xterm-pcolor
x1700-lm xnuppc-200x75 xterm+256color xterm-r5
...
username:x$ reset
reset: unknown terminal type xterm-256color
Terminal type? xterm-16color
=== Edit 2018 Feb 20 ===
You should config the term in many places if you want to make it permanent, for example, .vimrc, .tmux.config, .Xresources, e.t.c.
I still have issue when using terminator -x 'tmux attach -t music; exec bash'
So I'm using a quick hack as below:
cd /usr/share/terminfo/x
sudo mv xterm-256color xterm-256color.bk
sudo ln -sf /usr/share/terminfo/x/xterm-color /usr/share/terminfo/x/xterm-256color
When I removed some sessions/windows this error went away for me. Apparently I had too many TTY's open.
You can kill sessions/windows from outside tmux with these commands:
tmux kill-session -t <session-name>
tmux kill-window -t <session-name>:<window-name>
I am also having the same issue.
export TERM=xterm
tmux kill-server
This helps solve the problem: https://www.peterdavehello.org/2019/11/tmux-open-terminal-failed-missing-or-unsuitable-terminal-xterm-256color/
In my case Xterm was absent.
(But I had the same error on Ubuntu)
I have installed git-crypt (https://github.com/shadowhand/git-encrypt) on Windows and it's work fine.
But when i try on MacOSX (Mavericks), it's not successful.
From the guide this command on Linux:
$ sudo ln -s "$(pwd)/gitcrypt" /usr/local/bin/gitcrypt
But i can not make it work on MacOSX.
I also try this command without success:
sudo -s 'echo "/usr/local/bin/gitcrypt" > /etc/paths.d/$(pwd)/gitcrypt'
I have found solution. I post here for anyone find it:
$ clone https://github.com/shadowhand/git-encrypt /usr/local/git-encrypt
$ sudo vi /etc/paths
Add /usr/local/git-encrypt to the end save and quit terminal.