Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 13474  / 2 Years ago, tue, january 18, 2022, 6:21:31

I'm trying to write a simple bash script, which when run from the command line, will cd into a default directory and then open up the folder in the file-browser:



#!/bin/bash

if [ -z "$1" ]
then
# unless $1 is specified, cd into main proj
cd code/ruby/my-main-proj
else
# cd into project specified by $1
cd code/ruby/$1
fi

# open folder in file manager
pcmanfm .


This is great, it gives me two things:




  1. a command-prompt whose working directory is set to the project I want

  2. a file-browser for the same project



The trouble is that I would like to run my bash script by clicking on a desktop icon but in it's current form, the terminal does not open up, just the file browser..



So I've made a modification to try and get the terminal to open too:



then
# unless $1 is specified, cd into main proj
x-terminal-emulator -e "cd code/ruby/my-main-proj"
else
# code same as before


But while the terminal does open, it just displays a blank screen, with no prompt or PWD.
How can I get a terminal to open up, and have it's working directory change to the one I'm trying to specify in my bash script?


More From » bash

 Answers
5

I didn't get it to work with x-terminal-emulator, but with the standard
gnome terminal.



user@MacBookPro:~$ gnome-terminal --working-directory=~/code/ruby/my-main-proj


Hope this helps.


[#32712] Wednesday, January 19, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
restlerfin

Total Points: 347
Total Questions: 112
Total Answers: 108

Location: Ukraine
Member since Wed, Dec 16, 2020
3 Years ago
;