From 39ac1c97826f712b3b272547f7bf8d03934158d6 Mon Sep 17 00:00:00 2001 From: Jonathan Stott Date: Wed, 13 Jul 2011 22:07:43 +0100 Subject: [PATCH 1/2] Use XDG Base Directory instead of a .directory Host files are read from $XDG_CONFIG_HOME/resty. Cookies and host file are stored in $XDG_DATA_HOME/resty/c and $XDG_DATA_HOME/resty/host, respectively. One less .directory in $HOME. --- resty | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/resty b/resty index c9807fe..8629f9e 100755 --- a/resty +++ b/resty @@ -14,13 +14,15 @@ export _resty_path="" export _resty_nohistory="" function resty() { - local confdir host cookies method h2t editor domain _path opt dat res ret out err verbose raw i j d tmpf args2 wantdata vimedit quote query maybe_query + local confdir datadir host cookies method h2t editor domain _path opt dat res ret out err verbose raw i j d tmpf args2 wantdata vimedit quote query maybe_query local -a curlopt local -a curlopt2 - confdir="${HOME}/.resty" - host="${confdir}/host" - cookies="$confdir/c" + confdir="${XDG_CONFIG_HOME}/resty" + mkdir -p "$confdir" + datadir="${XDG_DATA_HOME}/resty" + host="$datadir/host" + cookies="$datadir/c" method="$1"; [[ $# > 0 ]] && shift h2t=$((exec 2>&-; (which lynx >/dev/null && echo lynx -stdin -dump) \ || which html2text || which cat) |tail -n 1) From 7a693be7294ebfbf92ea68bb362ea22e98fdaef7 Mon Sep 17 00:00:00 2001 From: Jonathan Stott Date: Sat, 16 Jul 2011 00:29:32 +0100 Subject: [PATCH 2/2] Fallback to ~/.resty without XDG dirs Be a bit kinder to people without XDG goodness --- resty | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/resty b/resty index 8629f9e..8683983 100755 --- a/resty +++ b/resty @@ -18,9 +18,14 @@ function resty() { local -a curlopt local -a curlopt2 - confdir="${XDG_CONFIG_HOME}/resty" + if [ -n "$XDG_CONFIG_HOME" ]; then + confdir="$XDG_CONFIG_HOME/resty" + datadir="$XDG_DATA_HOME/resty" + else + confdir="$HOME/.resty" + datadir="$confdir" + fi mkdir -p "$confdir" - datadir="${XDG_DATA_HOME}/resty" host="$datadir/host" cookies="$datadir/c" method="$1"; [[ $# > 0 ]] && shift