-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Register a URL handler for codelite:// (#3387)
- Loading branch information
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
|
||
# CodeLite URL Handler | ||
# codelite://open?url=file://@file&line=@line | ||
# codelite://open?file=@file&line=@line | ||
# codelite://open?url=file://@file:@line | ||
# codelite://open?file=@file:line | ||
# | ||
# @license GPL | ||
# @author Stefan Auditor <[email protected]> | ||
|
||
function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; } | ||
|
||
arg=$(urldecode "${1}") | ||
pattern=".*file(:\/\/|\=)(.*)(:|&line=)(.*)" | ||
|
||
# Get the file path. | ||
file=$(echo "${arg}" | sed -r "s/${pattern}/\2/") | ||
|
||
# Get the line number. | ||
line=$(echo "${arg}" | sed -r "s/${pattern}/\4/") | ||
|
||
# Check if codelite command exist. | ||
if type codelite > /dev/null; then | ||
/usr/bin/env codelite --line "${line}" "${file}" & | ||
fi | ||
|
||
if type wmctrl > /dev/null; then | ||
filename=$(basename "$file") | ||
/usr/bin/env wmctrl -i -a $(wmctrl -l | grep "${filename}" | tail -n 1 | cut -d ' ' -f1) | ||
fi | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[Desktop Entry] | ||
Name=CodeLite URL Handler | ||
Exec=codelite-url-handler %u | ||
Type=Application | ||
StartupNotify=false | ||
MimeType=x-scheme-handler/codelite; |