CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Installation

[Other] Create a user defined folder to access like $FOAM_RUN

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By 2538sukham

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 28, 2024, 11:48
Default Create a user defined folder to access like $FOAM_RUN
  #1
Member
 
Michael Sukham
Join Date: Mar 2020
Location: India
Posts: 85
Rep Power: 6
2538sukham is on a distinguished road
I want to create different folders with alias like that of $FOAM_RUN which we can access by typing run. Example folders PHD, WORK etc which we can access using alias. Can someone help me with this? With ~/.bashrc I am not sure how to achieve this and I don't want to break my OpenFOAM installation.
Any help is appreciated.
2538sukham is offline   Reply With Quote

Old   February 29, 2024, 15:12
Default
  #2
Member
 
Shravan
Join Date: Mar 2017
Posts: 75
Rep Power: 9
Severus is on a distinguished road
Hello,
If you want to change directory in terminal using alias, open your bashrc and add the following lines at the end

Case 1: You want to change directory to a folder not in the /home/ path
Lets say you want to change directory to a folder openfoam8 located in /opt/, then use

alias OF8_DIR='cd /opt/openfoam8/'


Case 2: You want to change directory to a folder that is in the /home/ path
Lets say you want to change directory to a folder called PHD_folder that is located in /home/Michael/, then use

alias PHD='cd ~/PHD_folder '



Case 3: You want to open a folder in the file manager and view it (for a GNOME desktop environment)
Lets say you want to a folder openfoam8 located in /opt/, then use

alias openfoam='nautilus /opt/openfoam8/'



Once you paste it in the end of bashrc, then open a new terminal and do this

source .bashrc



Now you should be able change directories

Note
In order to avoid making mistakes take a backup of your current bashrc, it will be useful and restore it just in case you mess up something
You can also check this thread for restoring the default bashrc: https://unix.stackexchange.com/quest...hrc-file-again

Thanks
Severus is offline   Reply With Quote

Old   March 1, 2024, 04:09
Default
  #3
Member
 
Michael Sukham
Join Date: Mar 2020
Location: India
Posts: 85
Rep Power: 6
2538sukham is on a distinguished road
Quote:
Originally Posted by Severus View Post
Hello,
If you want to change directory in terminal using alias, open your bashrc and add the following lines at the end

Case 1: You want to change directory to a folder not in the /home/ path
Lets say you want to change directory to a folder openfoam8 located in /opt/, then use

alias OF8_DIR='cd /opt/openfoam8/'


Case 2: You want to change directory to a folder that is in the /home/ path
Lets say you want to change directory to a folder called PHD_folder that is located in /home/Michael/, then use

alias PHD='cd ~/PHD_folder '



Case 3: You want to open a folder in the file manager and view it (for a GNOME desktop environment)
Lets say you want to a folder openfoam8 located in /opt/, then use

alias openfoam='nautilus /opt/openfoam8/'



Once you paste it in the end of bashrc, then open a new terminal and do this

source .bashrc



Now you should be able change directories

Note
In order to avoid making mistakes take a backup of your current bashrc, it will be useful and restore it just in case you mess up something
You can also check this thread for restoring the default bashrc: https://unix.stackexchange.com/quest...hrc-file-again

Thanks
Works like a charm!! I went for case2 which I added at the end of bashrc file: alias phd='cd /home/mikeyfluids/OpenFOAM/PhD' then sourced it : source ~/.bashrc
Now I get how the alias work. I can even alias paraFoam installed in windows using the same procedure since I am using wsl2 .
I consider the thread solved and closed !!
Thank you Shravan!
Severus likes this.
2538sukham is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create connectors with user defined distribution Nguyen Le Hai Pointwise & Gridgen 0 February 20, 2021 09:02
"decomposePar" not decomposing volumeVectorField located inside user defined folder kavatar OpenFOAM Running, Solving & CFD 0 December 11, 2020 02:32
[waves2Foam] Add user defined gauges in waveFoam Lewis Liang OpenFOAM Community Contributions 3 October 18, 2020 11:32
User defined time step - Possible to put variable time stepping in it? maccheese Fluent UDF and Scheme Programming 19 June 4, 2018 10:49
CFX 5.5 Roued CFX 1 October 2, 2001 17:49


All times are GMT -4. The time now is 10:07.