Added function to set working directory.
If a working directory is set with wdir(), bashrc will cd into the path stored in a file written in /tmp. A new terminal will then have a shell in that directory. cwdir() deletes the file in /tmp and pwdir() prints the working directory from said file if it exists.
This commit is contained in:
parent
9ae8541b92
commit
4feed1672f
9
.bashrc
9
.bashrc
@ -35,6 +35,9 @@ if grep "arch-laptop" /etc/hostname &> /dev/null ; then
|
|||||||
export IS_LAPTOP=1
|
export IS_LAPTOP=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Path to store working directory
|
||||||
|
export WDIR_PATH="/tmp/$(id -u).wdir"
|
||||||
|
|
||||||
# include bash aliases
|
# include bash aliases
|
||||||
if [ -f ~/.bash_aliases ]
|
if [ -f ~/.bash_aliases ]
|
||||||
then
|
then
|
||||||
@ -53,3 +56,9 @@ then
|
|||||||
source ~/.nnn_bookmarks
|
source ~/.nnn_bookmarks
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -f $WDIR_PATH ]
|
||||||
|
then
|
||||||
|
wdir="$(cat $WDIR_PATH)"
|
||||||
|
echo "Working directory from $WDIR_PATH"
|
||||||
|
cd "$wdir"
|
||||||
|
fi
|
||||||
|
@ -99,3 +99,30 @@ tzathura()
|
|||||||
fi
|
fi
|
||||||
zathura "$@" -e $(</tmp/tabbed.xid) & disown
|
zathura "$@" -e $(</tmp/tabbed.xid) & disown
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wdir()
|
||||||
|
{
|
||||||
|
wdir="$PWD/$1"
|
||||||
|
[ -d "$wdir" ] && echo "$wdir" > "$WDIR_PATH" && echo "set $wdir"
|
||||||
|
}
|
||||||
|
|
||||||
|
pwdir()
|
||||||
|
{
|
||||||
|
if [ -f "$WDIR_PATH" ]
|
||||||
|
then
|
||||||
|
cat "$WDIR_PATH"
|
||||||
|
else
|
||||||
|
echo "Working directory not set."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
cwdir()
|
||||||
|
{
|
||||||
|
if [ -f "$WDIR_PATH" ]
|
||||||
|
then
|
||||||
|
rm -f "$WDIR_PATH"
|
||||||
|
echo "Cleared working directory."
|
||||||
|
else
|
||||||
|
echo "Working directory not set."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user