cd

How do I change my current directory from a python script?

限于喜欢 提交于 2019-12-05 02:23:29
问题 I'm trying to implement my own version of the 'cd' command that presents the user with a list of hard-coded directories to choose from, and the user has to enter a number corresponding to an entry in the list. The program, named my_cd.py for now, should then effectively 'cd' the user to the chosen directory. Example of how this should work: /some/directory $ my_cd.py 1) ~ 2) /bin/ 3) /usr Enter menu selection, or q to quit: 2 /bin $ Currently, I'm trying to 'cd' using os.chdir('dir') .

use grub2 make dual boot cd(support bios and UEFI)

不问归期 提交于 2019-12-04 21:14:10
使用grub2 制作支持BIOS&UEFI 双启动的ISO镜像 首先就是准备grub2了。最新的Release版本可以从这里获取: ftp://ftp.gnu.org/gnu/grub . 其他信息参考 http://www.gnu.org/software/grub/ Compiler: a. Download the newest released grub2 package b. Decompress the package to path $grub2 c. mkdir ~/grub2-bios ~/grub2-uefi, cd $grub2 mkdir build build-uefi d. cd build, ../configure --prefix=${HOME}/grub2-bios, make , make install #compiler bios version e: cd ../build-uefi ../configure --with-platform=efi --target=x86_64 --prefix=${HOME}/grub2-uefi, make, make install Note: 正确的编译grub2, 你需要安装一些工具与lib,请参考grub INSTALL document。 Make bin: Bios: cd ~

Creating multi-platform CDs for software distribution

主宰稳场 提交于 2019-12-03 21:19:46
This is not strictly programming related, but I hope still relevant. I'm working on a project which is written in Java and intended for use on PCs and Macs. It will be distributed on CD (and perhaps DVD, eventually). Our intended audience is decidedly non-technical and, as such, it's important the CD "just work" when it's loaded. This is not itself difficult. For Windows, we can setup Autorun to automatically launch the app and, for Mac, we can use special folder formatting to make it clear what the user should do. The hitch is that we would like to ship one disc which could be used on either

Change directory to a path specified in a file with tilde

走远了吗. 提交于 2019-12-03 18:12:15
问题 I have a file, say: ~/cwd . The content of this file is a single line: ~/tmp I want fo cd to this (~/tmp) dir. I'm trying: > cd `cat ~/cwd` And got: -bash: cd: ~/tmp: No such file or directory Why the RELATIVE paths failed? When the content of the ~/cwd is absolute path - it works. 回答1: Try this: eval cd `cat ~/cwd` The '~' needs to be expanded by the shell. The eval causes the command to be run through the shell's command processing, which includes '~' expansion. 回答2: It's not a problem with

How do I change my current directory from a python script?

北战南征 提交于 2019-12-03 17:22:28
I'm trying to implement my own version of the 'cd' command that presents the user with a list of hard-coded directories to choose from, and the user has to enter a number corresponding to an entry in the list. The program, named my_cd.py for now, should then effectively 'cd' the user to the chosen directory. Example of how this should work: /some/directory $ my_cd.py 1) ~ 2) /bin/ 3) /usr Enter menu selection, or q to quit: 2 /bin $ Currently, I'm trying to 'cd' using os.chdir('dir') . However, this doesn't work, probably because my_cd.py is kicked off in its own child process. I tried

Is there a hook in Bash to find out when the cwd changes?

谁都会走 提交于 2019-12-03 05:06:28
问题 I am usually using zsh, which provides the chpwd() hook. That is: If the cwd is changed by the cd builtin, zsh automatically calls the method chpwd() if it exists. This allows to set up variables and aliases which depend on the cwd. Now I want to port this bit of my .zshrc to bash, but found that chpwd() is not recognized by bash. Is a similar functionality already existing in bash? I'm aware that redefining cd works (see below), yet I'm aiming for a more elegant solution. function cd() {

Change working directory in my current shell context when running Node script

不打扰是莪最后的温柔 提交于 2019-12-03 04:50:35
问题 I am trying to change the working directory of my Node.js script when it is run from a bin script. I have something like the following: #!/usr/bin/env node process.chdir('/Users') When I then run this file with ./bin/nodefile , it exits, but the working directory of the current shell context has not changed. I have also tried shelljs, but that does not work either. What is the best way to do this? I understand it's working but it's just in a separate process. 回答1: The correct way to change

Is there a hook in Bash to find out when the cwd changes?

南笙酒味 提交于 2019-12-02 18:20:28
I am usually using zsh, which provides the chpwd() hook. That is: If the cwd is changed by the cd builtin, zsh automatically calls the method chpwd() if it exists. This allows to set up variables and aliases which depend on the cwd. Now I want to port this bit of my .zshrc to bash, but found that chpwd() is not recognized by bash. Is a similar functionality already existing in bash? I'm aware that redefining cd works (see below), yet I'm aiming for a more elegant solution. function cd() { builtin cd $@ chpwd } You would have to use a DEBUG trap or PROMPT_COMMAND . Examples: trap chpwd DEBUG #

Change working directory in my current shell context when running Node script

牧云@^-^@ 提交于 2019-12-02 18:18:00
I am trying to change the working directory of my Node.js script when it is run from a bin script. I have something like the following: #!/usr/bin/env node process.chdir('/Users') When I then run this file with ./bin/nodefile , it exits, but the working directory of the current shell context has not changed. I have also tried shelljs , but that does not work either. What is the best way to do this? I understand it's working but it's just in a separate process. The correct way to change directories is actually with process.chdir(directory) . Here's an example from the documentation : console

bash - how to pipe result from the which command to cd

会有一股神秘感。 提交于 2019-12-02 14:06:00
How could I pipe the result from a which command to cd ? This is what I am trying to do: which oracle | cd cd < which oracle But none of them works. Is there a way to achieve this (rather than copy/paste of course)? Edit : on second thought, this command would fail, because the destination file is NOT a folder/directory . So I am thinking and working out a better way to get rid of the trailing "/oracle" part now (sed or awk, or even Perl) :) Edit : Okay that's what I've got in the end: cd `which oracle | sed 's/\/oracle//g'` mykhal You use pipe in cases where the command expects parameters