Twilio CLI setup; In autocomplete: What is "add the autocomplete env var to your bash profile and source it"? - twilio

I'm following the CLI setup for twilio and i get the following instruction from the command line on my mac (mojave) when i reach the autocomplete section of this document (https://www.twilio.com/docs/twilio-cli/quickstart). I do not know what i am being instructed to do here. Excuse my naivety.
1) Add the autocomplete env var to your bash profile and source it
$ printf "$(twilio autocomplete:script bash)" >> ~/.bashrc; source ~/.bashrc
NOTE: If your terminal starts as a login shell you may need to print the init script into ~/.bash_profile or ~/.profile.
2) Test it out, e.g.:
$ twilio <TAB><TAB> # Command completion
$ twilio command --<TAB><TAB> # Flag completion
Enjoy!

You can run the command:
printf "$(twilio autocomplete:script bash)" >> ~/.bashrc; source ~/.bashrc
from your OS-X terminal prompt, it will then append >> the output of that command to your ~/.bashrcfile. It then sources the contents of that file to populate your terminal environment (do you don't need to close your terminal and re-open it in this first instance).
From that point on, when you start a new Bash shell, you will be good to go (and don't need to run that command again).

Related

Wondering how to get my ENV variables into supervisor

In my ~/.bashrc I set the below variables...they work fine in my python script when I launch it but when I use supervisor it can't fine
FAILURE
[supervisor]
environment=ORACLE_HOME="%(ORACLE_HOME)s",LD_LIBRARY_PATH="%(LD_LIBRARY_PATH)s"
SUCCESS
[supervisor]
environment=ORACLE_HOME="/path/to/it",LD_LIBRARY_PATH="/path/to/it"
Basically I don't want to go back into the config file every time I want to update the oracle instant client.
Thanks
Try this executing these commands and then start supervisor
>> sudo export ORACLE_HOME="/path/to/it"
>> sudo export LD_LIBRARY_PATH="/path/to/it"
>> . ~/.bashrc

Extend $PATH variable in git bash under Windows

I'm trying to extend my $PATH variable in git bash (MinGW shell) by adding the following to the file ~/.bashrc
PATH=$PATH':/c/Program Files/maven/apache-maven-3.2.5/bin'
After I did this and restarted the bash it seems like that the $PATH variable was extended like expected:
$ echo $PATH
MANY_OTHER_PATHS:/c/Program Files/maven/apache-maven-3.2.5/bin
But I still cannot execute the programms in the given directory:
$ mvn
bash: mvn: command not found
What went wrong here? How do I extend the PATH variable correctly?
Here are two ideas.
You can have your path with double quote mark.
export PATH=$PATH:"/C/Program Files (x86)/apache-maven-3.3.3/bin"
Or, You can also make symbolic link for the directory.
ln -s "/C/Program Files (x86)/apache-maven-3.3.3/bin" ./mvnbin
export PATH=$PATH:/your-path/mvnbin
It works for me in mingw32 environment.
I needed to add something to my Git Bash path permanently each time I open it. It was Meld.exe path which can be added with:
export PATH=$PATH:"/C/Program Files (x86)/Meld/lib"
In order to execute this command each bash session, you need a ~/.bashrc file. Check if it already exists or create it using notepad ~/.bashrc or touch ~/.bashrc.
You can check where it is with:
echo ~
Open it and add the command that adds the PATH (first command in this response).
I hope you found this useful.
According to this SO post, you need to escape Program Files with quotes. git-bash $PATH cannot parse windows directory with space
Add PATH in Git Bash Permanently | Windows Only
Just in case you are still wondering how to add a path permanently in git bash here is the step-by-step process for Windows users:
Create .bashrc in user's root folder using the below command. It will open notepad and ask you to create the file, click yes.
notepad ~/.bashrc
Put the directory you want to add as below, for more than 1 items repeat the same format in next line:
export PATH=$PATH:"/c/folder/folder/"
Save the file and relaunch the bash.
Next launch will give you a warning like WARNING: Found ~/.bashrc but no ~/.bash_profile, ~/.bash_login or ~/.profile. but git bash will handle it by creating the required files.
SOME INSIGHTS
Git Bash doesn't fetch Window's environment PATH, it maintains its PATH separately in more like a Linux way.
You can run export PATH=$PATH:"/c/folder/folder/" in cmd to add a directory to path, but it will be only for the current session once you close the bash, it will be gone.
.bashrc is a shell script file that will be executed every time you launch a new git bash window. So you can add any type of bash command here. We simply added the export command to add our desired directory to PATH.

Docker shell completion on OSX iTerm2 oh-my-zsh

I am trying to get Docker shell completion on this stack (OSX iTerm2 oh-my-zsh)
I followed this guide -> https://docs.docker.com/compose/completion/
First I executed this
$ mkdir -p ~/.zsh/completion
$ curl -L https://raw.githubusercontent.com/docker/compose/master/contrib/completion/zsh/_docker-compose > ~/.zsh/completion/_docker-compose
Then I added this two lines almost at the end ~/.zshrc file
fpath=(~/.zsh/completion $fpath)
autoload -Uz compinit && compinit -i
Then in the terminal I run
source ~/.zshrc
exec $SHELL -l
But when I press tab it suggest the files and folders on the path
You set up the completion for docker-compose not for docker. If you would like add the docker completion too then run the following command and reload your shell.
curl -L https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/zsh/_docker > ~/.zsh/completion/_docker
Other solution (UPDATE):
Add the docker plugin to the .zshrc's plugin list:
Open ~/.zshrc
Add docker to the plugins list like this:
plugins=(docker ...)
Make sure you have the lastest version of oh-my-zsh by running: upgrade_oh_my_zsh
Also, it can't hurt to run rm ~/.zcompdump* after trying all the other answers.
Fixed it for me.
Run vim ~/.zshrc on your iTerm2
Find the line that contains plugins=() which normally will have git for example plugins=(git)
make a change by pressing I at that line ( i for Insert Mode)
change to plugins=(docker git) to add the docker extension and place ESC to exit insert mode
save by type :w to save and exit by type :x
restart your iTerm2 then docker completion should work now

I have to run "/bin/bash --login" everytime to use rake/rails commands?

whenever I switch directory in my terminal, I have to run the command "/bin/bash --login" before I can run rails/rake related commands. If I don't, I get an error saying "the program "rails" can be found in the following packages: ..."
Any advice?
By default some servers do not allow this due to permissions reason. You can place this in
~/.bashrc and it will automatically work when you open a new terminal
As per bash man page.
When an interactive shell that is not a login shell is started, bash
reads and executes commands from ~/.bashrc, if that file exists. This
may be inhibited by using the --norc option. The --rcfile file option
will force bash to read and execute commands from file instead of
~/.bashrc.
When bash is started non-interactively, to run a shell script, for
example, it looks for the variable BASH_ENV in the environment,
expands its value if it appears there, and uses the expanded value as
the name of a file to read and execute. Bash behaves as if the
following command were executed:
if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi but the value of the
PATH variable is not used to search for the file name.
The file is just shell commands. It is typically used to change prompts, set environment variables, and define shell procedures. Traditionally, the file .profile is used for this purpose, but bash has so many extensions that it needs its own startup file for users that want to put bashisms in startup files.
Easy solution:
Just open terminal. GO to Edit menu from terminal navigation bar, Select "Profile Preferences", It will open "edit profile pop-up". Select "Title and Command" button and "check Run Command as login shell"
ctrl + alt + t -> Edit -> Profile Preferences -> Title and Command -> Check Run command as login shell
Close the terminal and open again. Next time you don't need to "/bin/bash --login"

Automatically Run Command Upon Opening Terminal (Linux Mint 16)

I am using Rails and for some reason unbeknownst to me I have to execute the following line every time I start the terminal in order to use ruby and rails.
source ~/.bash_profile
If I type the following before running the above command, it will recommend that I install the packages (ie "type 'sudo apt-get install package' to install")
rails -v && ruby -v && irb -v
Is there a way to make my terminal execute a command upon opening? Or, better yet, can anybody help explain the reason I have to run this line? I found an article that said I had to do that given my issue but it didn't explain why.
Assuming you're using the bash shell, then ~/.bash_profile will be sourced once (and only once) when you log in to the system but not each time you open a terminal window.
The ~/.bashrc, however, will be sourced every time a new shell is opened (i.e. when you open a terminal window).
So they are probably some environment variables settings in ~/.bash_profile which are required for ruby to run. Those settings should be moved to the ~/.bashrc file instead so they are defined in all shell instances.
Alternatively, source ~/.bash_profile from your ~/.bashrc (this is at your own risk, it may have side-effects).

Resources