I am trying to install git's autocomplete (and I do not want to use Homebrew to do this), so I placed the following in my bash_profile
if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash
fi
The .git-completion.bash is an install script I donwload from github, specifically:
https://github.com/git/git/raw/master/contrib/completion/git-completion.bash
The .git-completion.bash file exists, I can see it when I run ls -la however, every time I open a terminal window, I see
-bash: /Users/Username/git-completion.bash: No such file or directory
(I do not know why it does not have a "." in that error)
I would appreciate any guidance on how to fix this without homebrew. Thanks
Related
I know the premise of the question may be confusing, but I want to understand what happened.
Recently I have been experimenting with the rockchip OK3399 single-chip computer(see here) and have installed a linux system on it with TF card installation. Using Putty and connecting with serial protocol, I was able to establish a connection with the OK3399 computer and control it through my laptop.
I am trying to self-learn some linux with the OK3399 system. I created a bash code by the name of displayvids.sh inside the directory /usr/bin, which is meant to take a variable number of pictures with a mipi camera and then save in a directory for work.
I finished writing the code, but for some reason I cannot run the .sh file when my working directory is not the /usr/bin directory, despite /usr/bin being in the %PATH% environment variable. So, I executed the following command:
mv /usr/bin/display* /usr/local/bin
... attempting to move the file to /usr/local/bin instead. The command ran successfully, but when I tried to run the command:
cd /usr/local/bin
It tells me that I cannot cd to bin
As seen from the above image, the /usr/local/bin is not even a directory. Why would mv succeed if the target was not a directory? How can I retrieve my bash file?
Why would mv succeed if the target was not a directory?
mv can also rename files:
mv foo.txt bar.txt
You renamed your script to bin and moved it under /usr/local.
You may want to remember to add a trailing slash next time, to have mv barf if the target isn't a directory:
mv /usr/bin/display* /usr/local/bin/
How can I retrieve my bash file?
Rename it back.
mv bin displayvids.sh
For future reference, you can use the file command to (try to) identify the contents of a file, if it's installed:
file bin
would have probably said bin: Bash script or similar.
I have installed nvim using AppImage mentioned as below
curl -LO https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage
chmod u+x nvim.appimage
./nvim.appimage
if i use nvim test,yml ,it fails as '-bash: /usr/bin/nvim: No such file or directory'
if i use ./nvim.appimage test.yml then it works. How to map this to nvim so that it works properly?
Linux looks for binaries in the paths that are set in $PATH variable. To check current paths execute echo $PATH
One way to fix it would be to move nvim.appimage (and rename it to just nvim) to one of the paths set in that variable.
Another way is to append the current path of nvim.appimage to $PATH. This was answered in detail How to correctly add a path to PATH?
I am using the "Bash on Ubuntu on Windows" (Linux Subsystem) and want to add Terraform to my $PATH. Since Terraform can't be installed via apt-get, I did the following steps:
Navigated to this directory, where I wanted to install Terraform:
cd /usr/local
In the above path, I used wget to download Terraform:
wget
https://releases.hashicorp.com/terraform/0.9.8/terraform_0.9.8_linux_amd64.zip
Terraform successfully unzips! When I open the file in VIM it is all good:
unzip terraform_0.9.8_linux_amd64.zip
I then enter this command to check to see if the Terraform binary is accessible from the command line:
terraform -version
However the following message gets returned:
terraform: command not found
This tells me that the Terraform downloaded location needs to be added to my $PATH.
Already being logged in as the root user ("sudo su") I enter the following command to access ".profile":
vim ~/.profile
The following is already in this file, which I leave untouched:
# ~/.profile: executed by Bourne-compatible login shells.
if [ "$BASH" ]; then
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
fi
mesg n
Immediately below this text, I add the following, and successfully save the file using :wq!:
export PATH=/usr/local/bin:$PATH
export PATH=$PATH:/usr/local/terraform
6.
I then again enter the following command to check to see if terraform is detected
terraform -version
Still the same "terraform: command not found" message is returned. I even tried closing out and starting a new command line session and even restarting my computer. Still no change.
Anyone have any ideas on how to resolve this? Again, note that I am using "Bash on Ubuntu on Windows" (Linux Subsystem). Any input would be appreciated!
The direct answer to your problem is at the end.
But I think it will make more sense if you keep reading from here.
Before trying to add to PATH,
I recommend to test a program first.
In your case I would do like this:
wget https://releases.hashicorp.com/terraform/0.9.8/terraform_0.9.8_linux_amd64.zip
unzip terraform_0.9.8_linux_amd64.zip
./terraform
Notice the last line ./terraform.
The zip file contains a single file, terraform,
which now should be in the current directory,
so I can run it with ./terraform.
If it's executable.
If it's not executable then confirm it:
ls -l terraform
And make it executable if needed:
chmod +x terraform
Now let's add it to PATH.
But first,
let's decide where to put this executable.
/usr/local/bin seems a reasonable location.
So let's move the terraform executable into that directory.
Usually /usr/local/bin is already on PATH,
so you might not need to change anything.
Now you can try your check, and there's a good chance it already works:
terraform -version
If it doesn't, then /usr/local/bin is not on the PATH.
To add it, add this line in ~/.profile:
export PATH=$PATH:/usr/local/bin
Two things looked fundamentally wrong with your approach:
Adding /usr/local/terraform to PATH. This is fishy, because the entries on PATH must be directories, and in your post nothing indicates that you created a directory at /usr/local/terraform.
You cd into /usr/local, and then unzip the zip file of terraform. The linked zip contains a single file named terraform, so /usr/local/terraform in your example should be a file.
If it is a file, then you could make it executable as terraform by adding to add to PATH its base directory. But adding /usr/local to PATH would not be a good idea. It's conventional to put binaries into /usr/local/bin, not directly into /usr/local
You did not mention how you reloaded ~/.profile. After editing this file, the new commands you added do not get automatically executed in your current shell. They will get executed when you open a new shell. Or you could manually execute the added commands in the current shell.
Hit below command
export PATH=$PATH:/usr/local/bin
I have installed virtualenv and the virtualwrapper via apt-get, I got to a point where I created a virtual enviroment but however later on during that same day when I used the workon command it was not found. I further on went and inspected my home directory and .virtualenvs dir and the virtualenv I created earlier were still there.
Solving this problem took two steps:
Add this to your .bashrc / .bash_profile / .zshrc:
# load virtualenvwrapper for python (after custom PATHs)
venvwrap="virtualenvwrapper.sh"
/usr/bin/which -s $venvwrap
if [ $? -eq 0 ]; then
venvwrap=`/usr/bin/which $venvwrap`
source $venvwrap
fi
Then use:
source .bash_profile
# or .bashrc / .zshrc
to reflect the changes.
Additionally, if the terminal still sometimes cant find workon, use source .bash_profile to reset and find it again.
type source .profile in home directory from terminal.
Read the readme in the top of which virtualenvwrapper.sh
You need to source it inside bashrc
open ~/.profile
cd ~
nano .profile
add at the end
#virtualenvwrapper setup
export WORKON_HOME=$HOME/envs
export PROJECT_HOME=$HOME/dev
source /usr/local/bin/virtualenvwrapper.sh
to load your .profile file you just edited:
$ . .profile
I ran in to this problem too and I simply needed to logout and log back in.
This read in the changes which the debian package manager made to my system at /etc/bash_completion.d/virtualenvwrapper
I have Git (version 1.7.2.5) bash compeletion working on my Debian squeeze (6.0). Git was installed with aptitude and I am using standard debian's bash, which supports command line autocompletion.
Now, I just installed Git (1.5.6.5) on an other machine (Lenny/Debian 5.0) and the there is no autocompletion.
Why is Git autocomplete not working on the second machine? How do I diagnose this?
What is making completion work on my machine? I have looked for the file git-completion.bash but it doesn't seem to be on my machine. How does Git complete ever work?
How can I bring git complete to the other machine?
You need to source /etc/bash_completion.d/git to enable git auto-completion.
In my .bashrc it's done with:
for file in /etc/bash_completion.d/* ; do
source "$file"
done
For Debian Squeeze (6.x):
Put the following lines in your ~/.bashrc
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
The script/program /etc/bash_completion already includes the scripts in /etc/bash_completion.d and also defines some functions needed by the included scripts.
For Ubuntu Bionic and up (^18.04):
Put the following lines in your ~/.bashrc
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
fi
For Fedora 20 & macOS High Sierra
See comments
You need to install this package if missing. And then logout and login.
apt-get install bash-completion
The shortest way to activate the bash auto-completion for Git on Debian is to add
source /etc/bash_completion.d/git
to the ~/.bashrc (and restart the terminal).
See also here: "Pro Git" -> 2.7 Git Basics - Tips and Tricks -> Auto-Completion.
Get the git autocompletion script:
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
Add to your .bash_profile in home directory:
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
Source your .bash_profile after this like:
. ~/.bash_profile
For Manjaro and other Arch-based distros. I know it's about debian, but most things are the same but sometimes not. Whatever OS you use you'll end up here.
In your ~/.bashrc add:
source /usr/share/git/completion/git-completion.bash
And then in terminal
$ source ~/.bashrc
For Ubuntu/Debian
Install Git and bash-completion by the following command:
sudo apt-get install git bash-completion
I don't think you need to do anything else.
Use Notepad++ to edit your ~/.bashrc file.
Put the line at the bottom of the script with a # at the beginning of the line. Save the file. For example:
# source C:\cygwin64/etc/bash_completion.d/git
Don't forget to put the entire file path after 'source' and in front of '/etc/' For example, my cygwin64 folder which contains the 'etc' folder is in my c drive so my file path is c:\cygwin64/etc therefore the line I included in my bashrc file is:
# source c:\cygwin64/etc/bash_completion.d/git
Save bashrc file. Open Cygwin Terminal ... Boom! It's go time.
I then entered the following command and it worked.
git clone git:\/\/github.com/magnumripper/JohnTheRipper -b bleeding-jumbo JtR-Bleeding
Recent versions of Ubuntu (observed on 20.04) seem to have split completions into multiple paths. For Ubuntu 20.04, I had to add the following to my .bashrc (taken from the default bashrc found in /etc/bash.bashrc):
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
At times git auto-complete disappears because you accidentally deleted your ~/.bashrc file. Check if the bashrc file is there in your home directory. If not, you can always copy it from:
/etc/skel/.bashrc