gt — a script to create a gedit scratchpad


I am really lazy with my editors. I have aliases in my shell configuration for gedit and vim to open them as quickly as possible:

alias v="vim -p"
alias sv="sudo vim -p"
alias g="bgcmd gedit"
alias sg="bgcmd gksudo geany"

This is very nice for me because I use my editors quite a bit. One thing I needed though was a command that would create and open a temporary file in gedit. The main reason for this is that, there are times, I don’t know how to name or place the file properly yet. At other times, the reason is I like to have a scratchpad but would rather not lose information if it was just a New File and I forgot about it, or a crash happened.

The bash script

Running geditmp will create and open a file named of the current time (MMDDhhmm) and will be saved in the trash folder. If geditmp is followed by a name (e.g. gt the name will be appended to the current time.


The name is helpful if wanting to dig the file out of the trash folder at a later time.

# (g)edit (t)emp. file. Create/open a temporary file(s).

# Variables
tmp_dir=~/.local/share/Trash/files; [ ! -d "$tmp_dir" ] && mkdir -pv "$tmp_dir"
time="$(date +%m%d%H%M)"

# gedit existence test
hash gedit 2>&- || { echo "Requires program \"gedit\"."; exit 1; }

# Help
if [ $# -lt 1 ] || [ "$1" = -h -o "$1" = --help ]; then
  echo "${0##*/} [name1] [name2*]… — gedit temp. file. Create/open a temporary file(s)."
  exit 1

for name in "$@"; do
  nohup gedit "$tmp_dir"/"$time"-"$name" &> /dev/null &
About these ads

About Todd Partridge (Gently)

Good times, good people, good fun.

Posted on 2013-08-26, in Command Line, Linux, Script. Bookmark the permalink. Leave a comment.

Comments are closed.


Get every new post delivered to your Inbox.

Join 57 other followers

%d bloggers like this: