blob: fddd3f8d7e6cf2f4912c4a41b0511199b33dc915 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#!/bin/bash
if [ ! -e "$HOME/.cdmem" ]; then
echo $HOME > ~/.cdmem
fi
alias cd='source cd-memo'
if [[ "$(pwd)" != "$HOME" ]]; then
echo "cd: working directory is already set, ignoring"
echo "You can still go to last working directory using 'cd --'"
return
fi
\cd "$(cat ~/.cdmem)" 2> /dev/null
if [ "$?" -ne "0" ]; then
echo "cd: previous directory ($(cat ~/.cdmem)) is inaccessible"
fi
|