Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide .pyc files when you enter `ls` in bash

Tags:

python

linux

pyc

ls

When I perform ls in bash, I always see too many *.pyc files. Is there any way to hide these files?

like image 330
user2566808 Avatar asked Jul 10 '13 03:07

user2566808


People also ask

Where do I find PYC files?

pyc files are placed in the same directory as the . py file. In Python 3.2, the compiled files are placed in a __pycache__ subdirectory, and are named differently depending on which Python interpreter created them. (This can be useful to people importing the same Python modules from multiple versions of Python.)


1 Answers

This way lies the dark side, but you could force ls to never show them by adding something like

alias ls='ls --hide="*.pyc"' 

to your .bashrc. ls will reveal the hidden files if you use -a or -A.

However, I would recommend just ignoring them in your head, or running this version of ls when you really don't want to see them.

like image 54
Matt Bryant Avatar answered Oct 06 '22 03:10

Matt Bryant