How To Set Working Directory On File Open (Linux Script)

(This guide is for Linux users. I’m sure it’s possible to do this in Windows and Mac but I don’t use either)

What this does:
When you open a file with Aseprite, this will switch Aseprite’s directory in the Open dialog to the directory that file lives. This keeps you from having to search for your working directory within Aseprite’s file browser after you already opened a file. (I made this script because I stream my drawings and I didn’t like having to show everyone my entire computer directory structure during streaming)

We’ll make this into an executable script:

Make a bin directory in your home directory if you don’t have one
cd mkdir bin cd bin

Make a script with a text editor of your choice, call the script whatever you want (example)
vim aseprite-open

Paste this into the file:

If Aseprite is installed directly to your system:
#!/bin/bash sed -i "s:^.*CurrentDirectory.*$:CurrentDirectory = $(dirname $1):" $HOME/.config/aseprite/aseprite.ini && aseprite "$@"

If Aseprite is installed via Steam:
#!/bin/bash sed -i "s:^.*CurrentDirectory.*$:CurrentDirectory = $(dirname $1):" $HOME/.config/aseprite/aseprite.ini && $HOME/.steam/steam/steamapps/common/Aseprite/aseprite "$@"

Make the script executable
sudo chmod +x aseprite-open

Optional: Make an alias for the script by adding this line to .bashrc
alias aseprite=aseprite-open

Thunar and PCManFM:
Set up this custom action in Thunar

aseprite-open %f

Ranger:
Add file associations you want to ~/.config/ranger/rifle.conf:
ext ase, flag f = aseprite-open "$@" ext png, flag f = aseprite-open "$@"

Thanks for reading.

1 Like

Related to this, there are plans for a projects feature in the future, where we should have easy access to all files inside the project folder. (Or just an “Open Folder” would be enough.) In any case, this should fix the problem of browsing folders for streamers.

Also, if you have some ideas for a possible “streaming mode” I’d love to hear about it :blush:

Sounds to me like a projects browser that hides full paths would just about solve the streaming issue.

The only other issue I am aware of is when you use the file browser to select a font file in the Text dialog, it switches the current directory in the file browser to your font directory. Then you have to navigate back to your working directory or use the Recent Paths dialog if you want to open anything again.

Besides that, I can’t think of any other privacy concerns with streaming. As long as I can keep the program inside of a working directory, then everything is great.

1 Like