CrunchBang Linux Pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

CrunchBang Linux Pastebin

Difference between
modified post 838 by johnraff on Mon 22nd Nov 16:10 and
original post 835 by johnraff on Sat 20th Nov 16:38
Show old version | new version | both versions

    
11
#!/bin/sh
22
# shell (hopefully dash!) places menu for openbox
33
# Usage: add
44
# <menu id="places" label="Places" execute="/path/to/dash_places_menu.sh ~" />
55
# to your .config/openbox/menu.xml (you don't need a final slash after the ~)
66
# or, if you want the "recent files" menu incorporated at the top, use:
77
# <menu id="places" label="Places" execute="/path/to/dash_places_menu.sh --recent ~" />
88
# make sure you have recently_opened_menu.sh somewhere, and enter its path below.
1010
# path to your "recent files" script, if you want to incorporate it:
1111
recent_script="$HOME"/scripts/recently_opened_menu.sh
1313
# Command to open folders at "Browse here..." - any file manager
1414
open_folder_cmd=thunar
1515
# Default command to open files with - others might be xdg-open, gnome-open, pcmanfm...
1616
default_open_cmd=exo-open  # exo-open comes with thunar
1717
# Text editor of choice
1818
text_editor=gedit
2020
# function to open files with default open command, or alternative command for certain files
2121
# - add other conditions to choice
2222
open_file() {
2323
	[ -x "$1" ] && exec "$text_editor" "$1"     # comment out this line if you don't want to edit executables instead of executing
2424
	#[ -x "$1" ] && exec "terminator -e" "$1"     # uncomment this and comment out previous line to run executables in terminal instead of editing
2525
	[ "${1##*.}" = desktop ] && exec "$text_editor" "$1"     # comment out this line if you don't want to edit .desktop files instead of executing
2626
	exec "$default_open_cmd" "$1"     # use default open command if above conditions not satisfied
2727
}
2929
# extra dotfiles to display in HOME folder (dotfiles are hidden by default)
3030
# edit the list (space separated, surrounded by single quotes) or comment this line out, to taste:
3131
shown_dotfiles='.config .local .Xdefaults .bash_aliases .bashrc .fonts.conf .gtkrc-2.0.mine .profile .xsession-errors'
3333
# By default, this script will display directories separately, before files.
3434
# To change this behaviour, see NOTE1, NOTE2 and NOTE3 below.
3636
#######################################################################
38+
case $1 in
3839
# if "--open" option is sent as $1, open file ($2) instead of generating menu
39-
[ "$1" = '--open' ] && {
40+
--open)
4041
open_file "$2"
4142
echo "$0 : failed to open $2" >&2
42-
exit    # in case exec command fails
43+
    exit;;    # in case exec command fails
43-
}
45-
output='<openbox_pipe_menu>
46-
'
4744
# if "--recent" option is sent, incorporate "recent files" menu
48-
[ "$1" = '--recent' ] && {
45+
--recent)
4946
shift
47+
    output='<openbox_pipe_menu>
48+
'
5049
if [ -x "$recent_script" ]
5150
then
52-
    output="$output"'<separator label="Recent Files" />
51+
        output="$output"'<separator label="Recently opened..." />
53-
<menu execute="'"$recent_script"'" id="recent" label="Recent Files" />
52+
<menu execute="'"$recent_script"'" id="recent" label="Files" />
5453
'
5554
else
5655
    echo "$0 : cannot find executable script $recent_script" >&2
57-
fi
56+
    fi;;
58-
}
57+
*)
58+
    output='<openbox_pipe_menu>
59+
';;
60+
esac
6062
path="${1:-$HOME}"  # default starting place is ~, otherwise $1
6163
path="$( echo "${path}"/ | tr -s '/' )"    # ensure one final slash
6264
[ -d "$path" ] || { echo "$0 : $path is not a directory" >&2; exit 1; }
64-
# escape xml special characters
66+
case "$path" in    # only escape if string needs it
65-
escape() {
67+
*\&*|*\<*|*\>*|*\"*|*\'*) pathe=$(sed "s/\&/\&amp;/g;s/</\&lt;/g;s/>/\&gt;/g;s/\"/\&quot;/g;s/'/\&apos;/g;") <<XXX
66-
case "$1" in    # only escape if string needs it
68+
$path
67-
*\&*|*\<*|*\>*|*\"*|*\'*) sed "s/\&/\&amp;/g;s/</\&lt;/g;s/>/\&gt;/g;s/\"/\&quot;/g;s/'/\&apos;/g;" <<XXX
68-
$1
6969
XXX
7070
;;
71-
*) printf '%s' "$1";;
71+
*)pathe=$path;;
7272
esac
73-
}
75-
# escape &apos; (originally ') with surrounding '""' for command line
74+
case "$pathe" in
76-
escapos() {
75+
*\&apos\;*) pathe_apos=$(sed 's/\&apos;/\&apos;\&quot;\&apos;\&quot;\&apos;/g;')<<XXX
77-
case "$1" in
76+
$pathe
78-
*\&apos\;*) sed 's/\&apos;/\&apos;\&quot;\&apos;\&quot;\&apos;/g;'<<XXX
79-
$1
8077
XXX
8178
;;
82-
*) printf '%s' "$1";;
79+
*) pathe_apos=$pathe;;
8380
esac
84-
}
86-
pathe="$( escape "$path" )"
82+
output="$output"'<separator label="'$pathe'" />

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me