All Questions
14
questions
28
votes
8
answers
24k
views
How to set an alias on a per-directory basis?
Suppose you have an alias go, but want it to do different things in different directories?
In one directory it should run cmd1, but in another directory it should run cmd2
By the way, I have an ...
10
votes
1
answer
5k
views
Can rm recursively remove empty directories?
In an old version of Unix, the rm command would delete directories if they were empty. From the Research Unix Eighth Edition man page for rm: "If an entry is a directory it is removed only if empty." ...
8
votes
4
answers
9k
views
How to create a short path?
We have so many useful folders, which are in different path, for our working in Linux.
For example :
$ cd ~/Documents/Courses/EDX/physics2013/
$ cd ~/Documents/Company/OpenGL/Proj/...
$ cd ~/...
3
votes
2
answers
650
views
Preventing accidental directory deletion. Making an alias that contains options?
I use an alias to prevent me from accidentally deleting files, and I would like to do something similar for directories.
For files, I have the following added to my .bashrc:
alias rm="rm -i"
I ...
3
votes
1
answer
8k
views
creating abbreviations for commonly used paths
I was wondering whether it is possible to create abbreviations that can be used in terminal. I know about alias command, but am not sure whether that can be used for what I am looking for.
Example: ...
2
votes
2
answers
5k
views
How to create an alias to the directories and copy one file to another?
I want to copy a file from /home/e_empid/file1 to /home/e_empid /dir1/dir2/dir3/Backupfile1. User does not want to write a long command each time. Write a command to set an alias for above action?
I ...
2
votes
2
answers
2k
views
Set alias to run python venv setup based on current directory name
Can't seem to figure out what the issue is. This is on a Fedora 37 with default setup (bash, gnome, etc...).
What I want to achieve is to create an alias that creates a python virtual environment, ...
1
vote
1
answer
818
views
dirs -v does not list the directory stack?
I have seen How do I use pushd and popd commands? , and I am aware that with pushd <dir> I would push <dir> to the directory stack, with popd I would pop the top directory from the ...
0
votes
2
answers
97
views
Defining Custom Location aliases
I'm trying to find a way to access a directory without specifying the whole path each time.
For example, i download a lot of videos and I've set up a folder to store all those videos, since I'll be ...
0
votes
1
answer
873
views
Global alias for all files in a directory, by their file names (extensions, if available will be omitted)
In Ubuntu 16.04 I have a directory nearly 10 files, each containing a single Bash script files:
"$HOME"/myScripts/x.sh
"$HOME"/myScripts/y.sh
...
Instead creating nearly 10 different aliases to each ...
0
votes
0
answers
197
views
Why doesn't creating file with echo work for remote directories in this script?
I aliased the following script:
#!/usr/bin/bash
if [[ -d "template.html" ]]; then
:
else
cp -n /home/$(whoami)/CS/Software/Pollen/template.html .
fi
/usr/bin/echo "#lang pollen
[...
0
votes
2
answers
1k
views
Can't I define aliases (using `export`) that are in my current directory? Doing so gives a `not found` message
TLDR: have to define an alias/variable using the export command, I can't use the full path and using a relative path (i.e. defining the alias while in the directory directly above what I want to ...
0
votes
1
answer
312
views
Always exclude path in find command
I have a directory whose contents should never be found by find, so I aliased find like this:
alias find='find -not -path "*.sync*"'
the issue is that find now complains that operators are not ...
0
votes
2
answers
73
views
Entering the last modified directory
Which command can I use to:
Enter the last modified directory in the current directory.
If no directory exists or is possible to enter, do nothing.
I'm looking for an alias named ca that will work ...