Update function mycd
Change name from cdls Update cd alias If cd fails and the first parameter is a file, it will try and open it in vim
This commit is contained in:
parent
3b37debbf7
commit
a1f45666a3
1 changed files with 17 additions and 6 deletions
|
@ -34,14 +34,25 @@ function old() {
|
||||||
mv "$1" "$1.old"
|
mv "$1" "$1.old"
|
||||||
}
|
}
|
||||||
|
|
||||||
function cdls() {
|
function mycd() {
|
||||||
cd "$@"
|
cd "$@" 2> /dev/null
|
||||||
if [ ! $TMUX ]; then
|
if [ $? = 0 ]; then
|
||||||
pwd > ~/.current-folder
|
# If we get here cd was successful
|
||||||
|
if [ ! $TMUX ]; then
|
||||||
|
pwd > ~/.current-folder
|
||||||
|
fi
|
||||||
|
ls
|
||||||
|
else
|
||||||
|
# If we get here, cd was not successful
|
||||||
|
if [ -f "$1" ]; then
|
||||||
|
vim "$1"
|
||||||
|
else
|
||||||
|
echo "Can't cd"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
ls
|
|
||||||
}
|
}
|
||||||
alias cd="cdls"
|
alias cd="mycd"
|
||||||
|
|
||||||
function mkcd() {
|
function mkcd() {
|
||||||
mkdir -p "$1"
|
mkdir -p "$1"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue