Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I recently installed NeoVim, and loved how its configuration files go in ~/.config/nvim/. Then while studying Git in more depth, I discovered that its configuration files can be stored in ~/.config/git/.
There are few other configuration files in my home folder that I'd love to move into ~/.config:
.bash_history and .bash_profile
.python_history and .pythonstartup
.ssh/
.vim/ and .viminfo
I've googled around, but haven't found any information about whether Bash, Python, etc., support moving these config files. Is it possible and how do I do so? I'd love to keep the home directory cleaner.
There is no universal answer for what can be put into ~/.config
The XDG Base Directory Specification defines several environment variables (each should point to a directory used for a specific purpose), and also a number of fallbacks in case such a variable is not set. One of these variables is XDG_CONFIG_HOME, and its fallback is ~/.config. So if a program is designed to be compliant with the spec, it should read your config files from its subfolder from this directory.
Whether or not a program uses XDG_CONFIG_HOME is entirely up to its developers, it is not safe to assume that if you put a config file into ~/.config's subfolder, it will have any effect.
As to the particular programs you mention:
Bash doesn't seem to support this.
Python: the tutorial mentions PYTHONSTARTUP environment variable, which indicates that this particular file doesn't go into ~/.config. Of course, you can put it there anyway and point PYTHONSTARTUP to it, and it should work.
ssh: it doesn't seem to conform to the spec, either.
nvim: if you're using Neovim, there's no need to use ~/.vim, you can put files from there into ~/.config/nvim/ (in fact, :help configuration says you should). Likewise, you don't have to use ~/.viminfo anymore.
You can use symbolic links to move anything you want there. For example,
mv .bash_profile ~/.config/bash/profile
ln -s ~/.config/bash/profile .bash_profile
This works for directories as well
ln -s ~/.config/vim .vim
(although for security reasons I'm not sure ssh will honor a symlink for ~/.ssh; you can try, though.)
Files like .bash_history are configurable to begin with. Add
HISTFILE=~/.config/bash/history
to use a file other than the default ~/.bash_history.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
PROBLEM DESCRIPTION
I'm setting up a new MacBook and decided to jump too fast into downloading Python 3.8. I downloaded it from the website https://www.python.org/ before realizing it's better practice to do so with homebrew.
GOAL - Remove Python 3.8 from my PATH to later install with Homebrew
I cleared Python 3.8 from my filesystem thanks to this page https://nektony.com/how-to/uninstall-python-on-mac, but the path the Version 3.8 is still in my PATH variable.
Typing echo $PATH in my terminal (zsh) returns /Library/Frameworks/Python.framework/Versions/3.8/bin along with other paths. Does anyone know how I can remove this path? It no longer exists in my filesystem so it's pointing to nothing.
WHAT I HAVE TRIED
I have checked all the following files using nano and they all do not have the export command which would place it in the path in the first place.
Files checked:
/etc/profile
/etc/bashrc
~/.bash_profile
~/.bash_login
~/.profile
~/.bashrc
MY ENV
I am running a macbook pro with Catalina (10.15.4) and using zsh as my terminal.
Any help is appreciated, thanks a lot!!
Found the solution! Through running grep {subset of the path you're trying to remove} . (don't forget the period at the end), I found all places where that path was found on my computer. That brought me to seeing that the ./.zprofile file was exporting the Python 3.8 path. I removed it from that file, saved it and restarted my Terminal. Now, the path is gone and I am happy
If you check what is stored in each variable using the set command, you might see Python somewhere there. To check what's in there, type set > ~/Documents/set.txt to view the contents. You can then open set.txt in your Documents directory to see the contents. Then, if you go back to Terminal, you can type PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin or whatever you would like to set it to. In conclusion, all you need to use is the PATH=<desired path> to set the value.
Check /etc/paths and /etc/paths.d/* and remove the relevant paths.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 5 years ago.
Improve this question
Please forgive my ignorance. I'm using Mint 18.1. I installed Python 3.6 from its source code but it failed.
if I enter python, version 2.7 runs.
if I enter python3, version 3.5 runs (both were preinstalled with my Mint)
if I enter python3.6, i get a 'command not found' error.
Then I found and followed Error Installing Python.
My question is how to do i set it up so python3.6 runs without having to enter $HOME/py36/bin/python in the terminal.
Thanks
edit
NEVERMIND. got it. thanks a lot, guys.
You could add an alias in your shell's config file (.bash_profile or similar, if you're using bash) that points python3 to $HOME/py36/bin/python.
To do this, you need to find your shell configuration file (~/.bash_profile, ~/.bash_login, or ~/.profile) and edit it so that it contains an alias. Aliases take the form of newcommandname='oldcommandname -flags', so you want something like python3="$HOME/py36/bin/python". Note how there are no spaces around the equals sign, and double quotes, as that is required for this to work.
Alternately, you could add $HOME/py36/bin/ to your $PATH variable, so that your shell automatically looks there for binaries. You can do this by editing your shell configuration file like above to say PATH="$HOME/py36/bin/:$PATH". This makes your shell look here for executables before anything else; PATH="$PATH:$HOME/py36/bin/" will cause your shell to look for executables here after looking everywhere else. I don't recommend this, tbh; do the first one.
The best way to maintain several different versions of python is via conda, which allows you to create a variety of environments with different Python versions and packages. Conda is part of the Anaconda scientific Python distribution.
Anaconda
There are lots of tutorials on YouTube and the web.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I know exactly 0 things about coding (unless HTML is coding?) and joined the site specifically for this question.
I found this code on Reddit and I'd really like to use the program, but I have zero knowledge of how to do that. I installed Python and have no idea how it works. I just need the very basic, click-this-button, type-this-here step-by-step of how to get an output and edit the variables.
The explanation of the program: https://www.reddit.com/r/worldbuilding/comments/1tpj38/random_royal_family_tree_generation/
The code is linked in the post but here it is again just in case: http://pastebin.com/uk9xG4XQ
I'm running Windows 10 and Python 3.5
Download the code in the python format (.py), open up PowerShell (comes with Windows 10), find your way to the directory you downloaded the .py format code to using the cd [X] command (where X is the directory), then type python3 X with X being whatever you saved the .py as.
If you're really eager to run the program without learning Python then do the following:
Download the file and save it as Dy27u.py
Open the file in notepad, find the line that says folder = '' #'/media/ToshikHD/Dropbox/Programming/Python/Dy/' and change the path to point to wherever you saved the file. Save the file, making sure you retain the .py extension
Open command prompt or powershell in Windows
Use cd to navigate to the folder where the file is stored. You make have to google this step to learn how to navigate around your file system if you don't already know hot do
Once you're in the correct directory, type python Dy27u.py
Taking a closer look at the code, you also need some extra text files called FemaleNames.txt, MaleNames.txt, and LastNames.txt. Read the comments in the .py file your downloaded so you know how to format those files
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Is it possible build python in my assigned directory on a Unix machine that I SSH to? Since this is a work server, do I need to make this aware to the system administrator if I want to try this. I want to use python instead of perl for advanced text manipulation.
You can do that following Python building instructions. They are pretty standard configure/make/make-install invocations. Just make sure to pass --prefix=~/local to configure script, so that it installs into your home directory because you probably don't have rights to install in /usr/local. You may need to ask your sysadmin to install extra development packages though, without them python or some python modules may fail to build.
If you can not get the required development packages installed on your server, another option is to build it on your own desktop, where you can install all required development packages, probably in a virtual machine matching the OS of the target box, and then just rsync/scp the directory where you installed it to the same directory on the target machine.
Yet another option is to find a privilege escalation exploit for your kernel, become local root and do whatever you want, but this is likely to get you in trouble. From a pure technical perspective though, it could be doable provided you are so determined to manipulate strings with Python.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
Do you know of any tool that could assist me in obfuscating python code?
Your problem space is underspecified. Is this for a command-line app? Is this code supposed to be used as a library?
In addition to the two other answers, you could embed the code into a binary. When it starts, decode the code and eval the string. This works for a shared library extension as well. You could also do that with byte code, I think, but it wouldn't be as simple as calling Py_EvalCode.
py2exe or freeze are other solution, which convert the code into an executable. It just includes the code in the binary, and doesn't do any sort of serious obsfucation, but it's still harder than opening a .py file.
You could write the code in Cython, which is similar to Python and writes Python extension files in C, for use as a .so. That's perhaps the hardest of these to reverse engineer and still give you a high-level language for develoment.
They are all hackable, as are all solutions. How hard to you want it to be?
http://www.lysator.liu.se/~astrand/projects/pyobfuscate/
Or at http://freshmeat.net/projects/pyobfuscate/
I actually found a very nice project which basically converts a Python to C++ and create a binary, statically linked file.
Check this out: http://www.nuitka.net/
In many situations you can ship byte-compiled .pyc files instead of the .py source files. This gives you some level of obfuscation. As the pyobfuscate README suggests, this has limitations. But you may be able to combine the two approaches.
Python's standard library includes compileall.py. You can run this on a directory and it will generate .pyc files for all your source files. The .pyc files will only include bytecode and docstrings, and will strip out all comments. You could then copy this directory, and then run something like rm -rf $(find . -name .py) to remove the original source files.
Your best bet is to compile it using Shed Skin, an experimental Python-to-C++ compiler.
Although it doesn't do obfuscation, this Python recipe works very well for minimizing the size of Python code, including stripping out comments.