Hot answers tagged

6

Aliases are for commands - what you need is a simple variable that references your long directory name. Add something like this to your ~/.bashrc: shortdir="/super/long/directory/name" Now, commands like ls "$shortdir" or du "$shortdir" will give you what you want.


5

If you already have the necessary directories created in the target location, then with the GNU implementations of find and xargs, it's not too difficult: find ~/path/to/src -name "*stringtomatch*" -printf "%P\0" | xargs -r0 --replace ln -s ~/path/to/src/'{}' ~/path/to/dest/'{}' The -printf "%P\0" outputs the path with the source directory parameter ...


3

Expansion of aliases is disabled by default inside scripts: see for example Can't use alias in script, even if I define it just above! When you execute . myshellscript ll you are not just running myshellscript, you are sourcing it into the current (interactive) shell, where the alias is expanded. In contrast, when you run mss ls you are simply running ...


3

With bash, you have the CDPATH variable. The following is said about it: CDPATH The search path for the cd command. This is a colon-separated list of directories in which the shell looks for destination directories specified by the cd command. A sample value is ".:~:/usr". If you have /my/super/very/long/path/to/projectdir then if you put /my/super/...


2

When you create a symbolic link, it allows you to access the directory from the place where you created it. For instance, in your case it would allow you to do cd /usr/local/bin/projects instead of cd /projectdir which, depending on the length of the path to your project could save some keystrokes. Compare for instance cd /my/super/very/long/path/to/...


2

I created a short script to do this, with a nice output which should be easy check the results. It doesn't need to have the destination directory structure created. Use as follows: $ ./recursive-symlink.sh --help Usage: ./recursive-symlink.sh <source_path> <dest_path> <find_args...> To show its usage, let's say I have the following ...


1

You can test this from the command line fairly easily: # set up test mkdir A mkdir B echo "this is A" > A/test.txt echo "this is B" > B/test.txt echo "this is A" > A/old.txt echo "this is B" > B/new.txt # contents of A change on copy ln -s A S cat S/test.txt cp -r B/ A/ cat S/test.txt cat A/test.txt # S still points to A ls -l S/ ls -l A/ ls -...


1

The symbolic link S points to A by means of the path to A. Copying files into A (which is what your command is doing) will not affect this link. If you, for whatever reason, renamed or removed A, then the symbolic link S would be broken and unusable. If you then created something else, possibly a new directory, called A in the same location as the old A, ...


1

With zsh (assuming the target directories already exist): autoload zmv # best in ~/.zshrc zmv -Ls ~/path/to/src/'(**/)(*stringtomatch*)' ~/path/to/dst/'$1$2' If your ln implementation is the GNU one, you can use its -r option to make relative symlinks (here also -v for verbose). zmv -Ls -o-rv ~/path/to/src/'(**/)(*stringtomatch*)' ~/path/to/dst/'$1$2'


Only top voted, non community-wiki answers of a minimum length are eligible