how to exclude user name from file paths in zsh terminal?

How do I hide my username from absolute shell paths or better still, shorten the path


If I launch Blender3d from the terminal with:


/Applications/Blender.app/Contents/MacOS/Blender


Terminal displays the following as Blender starts up:


Read prefs: /Users/MyUsername/Library/Application Support/Blender/3.4/config/userpref.blend


How do I get it to display something like this instead?


Read prefs: ~/Library/Application Support/Blender/3.4/config/userpref.blend


I'm planning to record a video and don't want my full name to be seen.


Cheers

MacBook Pro 13″, macOS 10.14

Posted on Mar 1, 2023 4:42 PM

Reply
Question marked as Top-ranking reply

Posted on Mar 1, 2023 7:31 PM

You control your prompt. But you do not control Blender, or any other app you run during your screen recording.


If you can find every place an app decides to display the full path, and there is a way to modify that code, then have fun.


I think it would be much easier to create a disposable user with a name that says what you want, then to find all the places some app or command or utility decided to display a full path with your user name in it.


what you want sounds like a Sisyphus task of constantly pushing a rock up hill, only to have roll back down, and start over again.

Similar questions

6 replies
Question marked as Top-ranking reply

Mar 1, 2023 7:31 PM in response to Kuzey

You control your prompt. But you do not control Blender, or any other app you run during your screen recording.


If you can find every place an app decides to display the full path, and there is a way to modify that code, then have fun.


I think it would be much easier to create a disposable user with a name that says what you want, then to find all the places some app or command or utility decided to display a full path with your user name in it.


what you want sounds like a Sisyphus task of constantly pushing a rock up hill, only to have roll back down, and start over again.

Mar 2, 2023 5:11 AM in response to Kuzey

Blender is designed to output that full path sequence that you see as its absolute path, and there is nothing you can do in Zsh to alter that fact because it is program stdout content. The Blender developer would have to alter the application to output a tilde path string, and there is a single Apple Foundation NSString method to do that.


Can you not launch blender in the following manner from the Terminal:


open -a Blender


However, if you had an actual Zsh absolute file path in a variable:


x=/Users/myUsername/Library/Application\ Support/Blender/3.4/config/userpref.blend
print ${${x:a}//"${HOME}"/\~}
~/Library/Application\ Support/Blender/3.4/config/userpref.blend


Mar 2, 2023 6:44 AM in response to Kuzey

I was using python subprocess.popen to launch Blender and I finally found the answer:


"Open -gj /Applications/Blender.app/Contents/MacOS/Blender ", shell=True


The -gj flags kept the terminal in the background so you don't see the paths as Blender is starting up and it looks better as well...win-win


Thanks again

Mar 1, 2023 6:47 PM in response to BobHarris

There has to be an easier way to do this than creating a new account?


For example, I have this in my .zshrc file to use a custom name instead of the default username@comptuername prompt:


PROMPT='%B%F{blue} Kuzey3D:%f%b %U%F{202}%~%f%u '


This works great but I want to do the same with my name in any paths that get displayed on the terminal screen.


Cheers

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

how to exclude user name from file paths in zsh terminal?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.