DEV Community

Discussion on: What are your preferred bash aliases?

Collapse
 
amritanshupandey profile image
Amritanshu Pandey • Edited

One alias that I use many many times every day:

‘’’
alias cdtemp='cd $(mktemp -d)'
‘’’

It creates a new temporary directory and switch to that directory.

Collapse
 
nocnica profile image
Nočnica Mellifera

interesting! is that just for experimenting with files you might not keep? I'm always curious how others use filesystems, I make a lot of temp files but don't ever make a temp directory to put them in!

Collapse
 
josephj11 profile image
Joe

I don't either, but it's a cool idea because you can create a bunch of files for something and delete them all when you're done just by deleting the directory they're in. Also makes it so you don't have to worry about file name collisions between tasks.

Thread Thread
 
amritanshupandey profile image
Amritanshu Pandey

Yes thats exactly how I use this alias. Another benefit is that in most of linux distros the ‘/tmp’ directory is cleared upon each reboot.

Thread Thread
 
nocnica profile image
Nočnica Mellifera

Whaaaaat I did not know this.