mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-11-03 22:47:13 +00:00 
			
		
		
		
	Update example bash script to use nvm use on shell open
This commit is contained in:
		
							parent
							
								
									8093dbeacd
								
							
						
					
					
						commit
						b93a27ed03
					
				
							
								
								
									
										10
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								README.md
									
									
									
									
									
								
							@ -458,8 +458,12 @@ find-up () {
 | 
			
		||||
    echo "$path"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
cdnvm(){
 | 
			
		||||
cdnvm() {
 | 
			
		||||
    cd "$@";
 | 
			
		||||
    nvmUse
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
nvmUse() {
 | 
			
		||||
    nvm_path=$(find-up .nvmrc | tr -d '[:space:]')
 | 
			
		||||
 | 
			
		||||
    # If there are no .nvmrc file, use the default nvm version
 | 
			
		||||
@ -500,11 +504,15 @@ cdnvm(){
 | 
			
		||||
        fi
 | 
			
		||||
    fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
alias cd='cdnvm'
 | 
			
		||||
nvmUse
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
This alias would search 'up' from your current directory in order to detect a `.nvmrc` file. If it finds it, it will switch to that version; if not, it will use the default version.
 | 
			
		||||
 | 
			
		||||
It will also call `nvm use` when a new terminal window is opened (e.g. opening a terminal in your IDE).
 | 
			
		||||
 | 
			
		||||
#### zsh
 | 
			
		||||
 | 
			
		||||
##### Calling `nvm use` automatically in a directory with a `.nvmrc` file
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user