Skip to content

Instantly share code, notes, and snippets.

@konsumer
Created May 17, 2019 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save konsumer/d045da02e7e97f59fdad07989a42ab0c to your computer and use it in GitHub Desktop.
Save konsumer/d045da02e7e97f59fdad07989a42ab0c to your computer and use it in GitHub Desktop.
Open a new tab in xfce4-terminal, if it's running, and cd to wherever the last-run zsh is
#!/bin/bash
# use tabs if terminal is running, otherwise new window
# designed for use with meta-T to open new terminal window/tab
XPID=$(pgrep zsh -o)
if [ "${XPID}" != "" ];then
cwd=$(pwdx $XPID|sed -e "s/${XPID}: //")
cwd=${cwd:-$HOME}
xfce4-terminal --tab --default-working-directory="${cwd}"
else
xfce4-terminal
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment