A kinda relevant question. I use Windows most of time. Like the author, I have bunch of CLI scripts (in Python mainly) which I put into my ~/bin/ equivalent. After setting python.exe as the default program for `.py` extension, and adding `.py` to `%pathext%`, I can now run my ~/bin/hello.py script at any path by just type `hello`, which I use hundreds of time a day. I now use Linux more and more (still a newbie) but…
> but then you have to add a shebang line directly to the script itself, which I always feel uncomfortable since it's hard-coded It won’t directly help reach your goal, but it is semi hard-coded. The ‘correct’ (but see https://unix.stackexchange.com/a/29620 for some caveats) way to write a shebang line is #!/usr/bin/env python That will make it run the first python in your path. > what if in future I don't want to ex…
Start all of your commands with a comma (2009)
91–100 of 177 posts
Re: Start all of your commands with a comma (2009)
#92I guess this works great right up to when the contents of ~/bin/ are added to a CSV for whatever reason.
Use TSV instead.
Re: Start all of your commands with a comma (2009)
#93Re: Start all of your commands with a comma (2009)
#94A kinda relevant question. I use Windows most of time. Like the author, I have bunch of CLI scripts (in Python mainly) which I put into my ~/bin/ equivalent. After setting python.exe as the default program for `.py` extension, and adding `.py` to `%pathext%`, I can now run my ~/bin/hello.py script at any path by just type `hello`, which I use hundreds of time a day. I now use Linux more and more (still a newbie) but…
Your example got me thinking about the difference between how the windows shell and Unix shell is designed. Seems like the windows shell knows about extensions, whereas the Unix shell does not That’s an interesting feature for a shell to have. Thanks!
Re: Start all of your commands with a comma (2009)
#95> Because my shell script names tended to be short and pithy collections of lowercase characters, just like the default system commands, there was no telling when Linux would add a new command that would happen to have the same name as one of mine. Not sure I understand this problem. I just put my bin directory at the front of $PATH rather than the end. To browse my commands, I simply `ls ~/bin`.
Re: Start all of your commands with a comma (2009)
#96 $ cd ~/bin
$ for x in $(find . -type f -perm /a=x -exec basename {} \;) ; do echo $x ; done
temps
$ for x in $(find . -type f -perm /a=x -exec basename {} \;) ; do ln -s $x ,$x ; done
$ ls -l
total 4
lrwxrwxrwx 1 tanel tanel 5 Jun 23 16:38 ,temps -> temps
-rwxr--r-- 1 tanel tanel 251 May 30 23:26 tempsRe: Start all of your commands with a comma (2009)
#97I use short custom command names like aa, st, di, dp, cm and le in some thin wrappers around git. One of these names actually collides with a utility that is installed by default on some systems. Doesn’t matter to me. I have my own bin dirs before the system dirs in my path, so mine “win”, and I’m not really interested at all in the tool that mine has a name collision with. If someone were to make a useful to me tool…
Re: Start all of your commands with a comma (2009)
#98https://news.ycombinator.com/item?id=22778988 (April 2020, 90 comments)
Re: Start all of your commands with a comma (2009)
#99The idea about starting my own scripts' names with a comma would have made the job go much faster, and I'm sure would have helped to job some memories about why each script was written, before opening it.
Re: Start all of your commands with a comma (2009)
#100A kinda relevant question. I use Windows most of time. Like the author, I have bunch of CLI scripts (in Python mainly) which I put into my ~/bin/ equivalent. After setting python.exe as the default program for `.py` extension, and adding `.py` to `%pathext%`, I can now run my ~/bin/hello.py script at any path by just type `hello`, which I use hundreds of time a day. I now use Linux more and more (still a newbie) but…
Simply remove the .py from the filename. It's perfectly acceptable to call it "hello". I can't think of a downside to the shebang. If you really wanted to run the script with a different interpreter, just specify it. "nohtyp hello" or whatever. If that still bothers you too much, you could define an alias in your shell startup. For example, in bash, you might do: alias hello="python3 /path/to/hello.py" If you were so…