My First Post      My Facebook Profile      My MeOnShow Profile      W3LC Facebook Page      Learners Consortium Group      Job Portal      Shopping @Yeyhi.com

Pages










Showing posts with label bash. Show all posts
Showing posts with label bash. Show all posts

Monday, October 12, 2020

Using different Versions of Node using NVM

 To check your current active version of Node and NPM

node -v
npm -v

Node 10.7.0

Node is most easily managed using NVM and that is the recommended tool we suggest. https://github.com/creationix/nvm



Now, suppose you have different version of node installed, but some app needs a lower or a different version. Then what to do. Here comes nvm for the rescue!


nvm is a version manager for node.js, designed to be installed per-user, and invoked per-shell. nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: unix, macOS, and windows WSL.

Install & Update Script

To install or update nvm, you should run the install script. To do that, you may either download and run the script manually, or use the following cURL or Wget command:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.36.0/install.sh | bash


Do not forget to source the bash profile after this:

Simply type source ~/.bash_profile

Alternatively, if you like saving keystrokes you can type . ~/.bash_profile


Now you can use nvm commands to change node version

eg:

nvm install 10.7

or, nvm use 10.7

Thursday, November 14, 2019

How to show full working directory in mac terminal on every command


Problem description:
You can obviously use a pwd command to see the present working directory. For eg:

prompt$ pwd
/Users/mfaiz/myDir

But sometimes you want to show the full directory path every time. Its a common ask for eg:
/Users/mfaiz/myDir$ pwd


Or, better still you want the directory path to be displayed on top before each command. All such issues can be handled using your bash profile file:


vi ~/.bash_profile


Solution: 
You can add this line -
export PS1='\u@\H:\w$'

or, if you like having a space between the $ and the command, then - 
export PS1='\u@\H:\w$ '



Shown following are two more complex examples that include coloring as well:




Command used to achieve this is:

export PS1="\n$C_LIGHTGREEN\u$C_DARKGRAY@$C_BLUE\h $C_DARKGRAY: $C_LIGHTYELLOW\w\n$C_DARKGRAY\$$C_DEFAULT "