Hacker News new | past | comments | ask | show | jobs | submit login

I do the following [1]:

- I define "cdn" to be what others call "mkcd", as then if I have a command line "cd foo" and it tells me that foo doesn't exist, I can just add the 'n' to the previous entry. I also overload "cdn" so that when not given any argument, it goes into the newest subdirectory in the current directory.

- "u", "uu", "uuu", "uuuu", "uuuuu" for going "up" that many levels, and unlike the aliases in OP, I define them as functions and if those are given an argument, they descends into the path from there: "u foo" is equivalent to "cd ../foo", "uu foo" to "cd ../../foo".

- I also have a function called "mvcd foo bar" that moves foo to bar and then goes into bar. "mvcdnewdir foo bar" that does the same but will create bar. (I'm pondering unifying them to a version that always calls mkdir -p)

- an alias "c" for cd [2]. The single letter messes with the history search though (ctl-r c space or ctl-r cd space ?), so it's not necessarily a good idea. `shopt -s autocd` that I just learned about here may be better.

- some functions for special locations, "cs" for ~/scratch, "cb" for ~/bookmarks, etc.

[1] see .bashrc at https://github.com/pflanze/chj-home [2] but I never use bash's "alias" since aside of being shorter it is always worse than a function (no way to extend it later to take parameters, and messes up live redefinitions)




cdn is a good idea. I'm going to steal it, and change it to ncd, so that all i have to do to add that 'n' is C-a to the begin of line.


There's a small benefit to adding the n after the cd: When my thought process goes like "I need to go into directory" I can already type cd, then "oh that doesn't exist yet" then I can type the "n", then I can type out the "foo". You could possibly argue though that "cd foo -n" would be the right thing to type then. Or, finish "cd foo" then ctl-a "n" as you say.


Even better, just do

n!!

(!! repeats the previous command).


Reminds me of the family of LISP functions to access specific elements of a list, for example `(caddr l)` being defined as `(car (cdr (cdr l)))`




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: