-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLS_MAGIC
35 lines (22 loc) · 1020 Bytes
/
LS_MAGIC
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Follow the steps below to setup << ls -dt $PWD/* | tac >> as an Environment variable.
- Enables a list with full paths of all files in current or requested directory - in descending order!
Why? - Often it's the most recently modified / saved file that we're after in the Command Line, this conveniently lists that file right above your text prompt in a Linux Terminal.
1. Create a bash script with nano
nano LS_MAGIC
2. Copy / Paste the following:
#!/bin/bash
# Set directory to the first argument, or to the current directory if no argument is given.
# Use realpath to get full path of directory
directory=$(realpath "${1:-$PWD}")
# List files in the specified (or current) directory in reverse order with full paths
ls -dt "$directory"/* | tac
3. Save & Exit then add executable priviledge
CTRL X
ENTER
chmod +x LS_MAGIC
4. Add to path
mv ./LS_MAGIC /usr/bin/LS_MAGIC
5. Test!
While in your Downloads folder try: LS_MAGIC
While in your Downloads folder list home directory contents: LS_MAGIC ~
Bam!