Changeset View
Standalone View
kdevplatform/util/kdevplatform_shell_environment.sh
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | 62 | function checkToolsInPath { | |||
---|---|---|---|---|---|
63 | for TOOL in $@; do | 63 | for TOOL in $@; do | ||
64 | if ! [ "$(which $TOOL 2> /dev/null)" ]; then | 64 | if ! [ "$(which $TOOL 2> /dev/null)" ]; then | ||
65 | echo "The utility $TOOL is not in your path, the shell integration will not work properly." | 65 | echo "The utility $TOOL is not in your path, the shell integration will not work properly." | ||
66 | fi | 66 | fi | ||
67 | done | 67 | done | ||
68 | } | 68 | } | ||
69 | 69 | | |||
70 | # Check if all required tools are there (on the host machine) | 70 | # Check if all required tools are there (on the host machine) | ||
71 | checkToolsInPath sed qdbus ls cut dirname mktemp basename readlink hostname | 71 | checkToolsInPath sed ls cut dirname mktemp basename readlink hostname | ||
72 | | ||||
73 | # special handling for qdbus variants | ||||
74 | _qdbus=qdbus-qt5 | ||||
kfunk: Maybe rename to `QDBUS_EXE`? | |||||
I used _qdbus to follow _shell, but then the naming patterns seems not consistent. I preferred qdbus over qdbus-qt5, as the latter seems he exception. But no fixed opinion, there are arguments for both orders. Why the "too"? kossebau: I used `_qdbus` to follow `_shell`, but then the naming patterns seems not consistent.
Whatever… | |||||
kfunk: Shouldn't this prefer `qdbus-qt5` over `qdbus`, too? | |||||
Reasoning here: qdbus could resemble the Qt4-Version of qdbus in case there are multiple installs of Qt; qdbus-qt5 never is. Thus using qdbus-qt5 as first option is more fail-safe.
Well, kdevelop! first checks qdbus-qt5 -- but otoh order is not important there.
Ah, okay, that wasn't obvious from the diff: Use whatever you prefer, and what appears consistent in this file. _qdbus then, if you prefer. kfunk: > I preferred qdbus over qdbus-qt5, as the latter seems he exception. But no fixed opinion… | |||||
75 | if ! [ "$(which $_qdbus 2> /dev/null)" ]; then | ||||
76 | _qdbus=qdbus | ||||
77 | if ! [ "$(which $_qdbus 2> /dev/null)" ]; then | ||||
78 | echo "The utility qdbus (or qdbus-qt5) is not in your path, the shell integration will not work properly." | ||||
79 | fi | ||||
80 | fi | ||||
72 | 81 | | |||
73 | if ! [ "$KDEV_SSH_FORWARD_CHAIN" ]; then | 82 | if ! [ "$KDEV_SSH_FORWARD_CHAIN" ]; then | ||
74 | # Check for additional utilities that are required on the client machine | 83 | # Check for additional utilities that are required on the client machine | ||
75 | checkToolsInPath kioclient5 | 84 | checkToolsInPath kioclient5 | ||
76 | fi | 85 | fi | ||
77 | 86 | | |||
78 | # Queries the session name from the running application instance | 87 | # Queries the session name from the running application instance | ||
79 | function getSessionName { | 88 | function getSessionName { | ||
80 | echo "$(qdbus $KDEV_DBUS_ID /org/kdevelop/SessionController org.kdevelop.SessionController.sessionName)" | 89 | echo "$($_qdbus $KDEV_DBUS_ID /org/kdevelop/SessionController org.kdevelop.SessionController.sessionName)" | ||
81 | } | 90 | } | ||
82 | 91 | | |||
83 | function getSessionDir { | 92 | function getSessionDir { | ||
84 | echo "$(qdbus $KDEV_DBUS_ID /org/kdevelop/SessionController org.kdevelop.SessionController.sessionDir)" | 93 | echo "$($_qdbus $KDEV_DBUS_ID /org/kdevelop/SessionController org.kdevelop.SessionController.sessionDir)" | ||
85 | } | 94 | } | ||
86 | 95 | | |||
87 | function getCurrentShellEnvPath { | 96 | function getCurrentShellEnvPath { | ||
88 | local ENV_ID=$KDEV_SHELL_ENVIRONMENT_ID | 97 | local ENV_ID=$KDEV_SHELL_ENVIRONMENT_ID | ||
89 | if [ "$1" ]; then | 98 | if [ "$1" ]; then | ||
90 | ENV_ID=$1 | 99 | ENV_ID=$1 | ||
91 | fi | 100 | fi | ||
92 | 101 | | |||
▲ Show 20 Lines • Show All 170 Lines • ▼ Show 20 Line(s) | |||||
263 | function shev! { | 272 | function shev! { | ||
264 | showenv! $@ | 273 | showenv! $@ | ||
265 | } | 274 | } | ||
266 | 275 | | |||
267 | # Internals: | 276 | # Internals: | ||
268 | 277 | | |||
269 | # Opens a document in internally in the application | 278 | # Opens a document in internally in the application | ||
270 | function openDocument { | 279 | function openDocument { | ||
271 | RESULT=$(qdbus $KDEV_DBUS_ID /org/kdevelop/DocumentController org.kdevelop.DocumentController.openDocumentSimple $1) | 280 | RESULT=$($_qdbus $KDEV_DBUS_ID /org/kdevelop/DocumentController org.kdevelop.DocumentController.openDocumentSimple $1) | ||
272 | if [[ "$RESULT" != "true" ]]; then | 281 | if [[ "$RESULT" != "true" ]]; then | ||
273 | echo "Failed to open $1" | 282 | echo "Failed to open $1" | ||
274 | fi | 283 | fi | ||
275 | } | 284 | } | ||
276 | 285 | | |||
277 | # Opens a document in internally in the application | 286 | # Opens a document in internally in the application | ||
278 | function openDocuments { | 287 | function openDocuments { | ||
279 | if [[ $_shell == "zsh" ]]; then | 288 | if [[ $_shell == "zsh" ]]; then | ||
280 | arr=(${=1}) | 289 | arr=(${=1}) | ||
281 | else | 290 | else | ||
282 | arr=("$1") | 291 | arr=("$1") | ||
283 | fi | 292 | fi | ||
284 | RESULT=$(qdbus $KDEV_DBUS_ID /org/kdevelop/DocumentController org.kdevelop.DocumentController.openDocumentsSimple "(" $arr ")") | 293 | RESULT=$($_qdbus $KDEV_DBUS_ID /org/kdevelop/DocumentController org.kdevelop.DocumentController.openDocumentsSimple "(" $arr ")") | ||
285 | if [[ "$RESULT" != "true" ]]; then | 294 | if [[ "$RESULT" != "true" ]]; then | ||
286 | echo "Failed to open $1" | 295 | echo "Failed to open $1" | ||
287 | fi | 296 | fi | ||
288 | } | 297 | } | ||
289 | 298 | | |||
290 | # Executes a command on the client machine using the custom-script integration. | 299 | # Executes a command on the client machine using the custom-script integration. | ||
291 | # First argument: The full command. Second argument: The working directory. | 300 | # First argument: The full command. Second argument: The working directory. | ||
292 | function executeInApp { | 301 | function executeInApp { | ||
293 | local CMD="$1" | 302 | local CMD="$1" | ||
294 | local WD=$2 | 303 | local WD=$2 | ||
295 | if ! [ "$WD" ]; then | 304 | if ! [ "$WD" ]; then | ||
296 | WD=$(pwd) | 305 | WD=$(pwd) | ||
297 | fi | 306 | fi | ||
298 | RESULT=$(qdbus $KDEV_DBUS_ID /org/kdevelop/ExternalScriptPlugin org.kdevelop.ExternalScriptPlugin.executeCommand "$CMD" "$WD") | 307 | RESULT=$($_qdbus $KDEV_DBUS_ID /org/kdevelop/ExternalScriptPlugin org.kdevelop.ExternalScriptPlugin.executeCommand "$CMD" "$WD") | ||
299 | if [[ "$RESULT" != "true" ]]; then | 308 | if [[ "$RESULT" != "true" ]]; then | ||
300 | echo "Execution failed" | 309 | echo "Execution failed" | ||
301 | fi | 310 | fi | ||
302 | } | 311 | } | ||
303 | 312 | | |||
304 | # First argument: The full command. Second argument: The working directory. | 313 | # First argument: The full command. Second argument: The working directory. | ||
305 | # Executes the command silently and synchronously, and returns the output | 314 | # Executes the command silently and synchronously, and returns the output | ||
306 | function executeInAppSync { | 315 | function executeInAppSync { | ||
307 | local CMD=$1 | 316 | local CMD=$1 | ||
308 | local WD=$2 | 317 | local WD=$2 | ||
309 | if ! [ "$WD" ]; then | 318 | if ! [ "$WD" ]; then | ||
310 | WD=$(pwd) | 319 | WD=$(pwd) | ||
311 | fi | 320 | fi | ||
312 | RESULT=$(qdbus $KDEV_DBUS_ID /org/kdevelop/ExternalScriptPlugin org.kdevelop.ExternalScriptPlugin.executeCommandSync "$CMD" "$WD") | 321 | RESULT=$($_qdbus $KDEV_DBUS_ID /org/kdevelop/ExternalScriptPlugin org.kdevelop.ExternalScriptPlugin.executeCommandSync "$CMD" "$WD") | ||
313 | echo "$RESULT" | 322 | echo "$RESULT" | ||
314 | } | 323 | } | ||
315 | 324 | | |||
316 | # Getter functions: | 325 | # Getter functions: | ||
317 | 326 | | |||
318 | function getActiveDocument { | 327 | function getActiveDocument { | ||
319 | qdbus $KDEV_DBUS_ID /org/kdevelop/DocumentController org.kdevelop.DocumentController.activeDocumentPath $@ | 328 | $_qdbus $KDEV_DBUS_ID /org/kdevelop/DocumentController org.kdevelop.DocumentController.activeDocumentPath $@ | ||
320 | } | 329 | } | ||
321 | 330 | | |||
322 | function getOpenDocuments { | 331 | function getOpenDocuments { | ||
323 | qdbus $KDEV_DBUS_ID /org/kdevelop/DocumentController org.kdevelop.DocumentController.activeDocumentPaths | 332 | $_qdbus $KDEV_DBUS_ID /org/kdevelop/DocumentController org.kdevelop.DocumentController.activeDocumentPaths | ||
324 | } | 333 | } | ||
325 | 334 | | |||
326 | function raise! { | 335 | function raise! { | ||
327 | qdbus $KDEV_DBUS_ID /kdevelop/MainWindow org.kdevelop.MainWindow.ensureVisible | 336 | $_qdbus $KDEV_DBUS_ID /kdevelop/MainWindow org.kdevelop.MainWindow.ensureVisible | ||
328 | } | 337 | } | ||
329 | 338 | | |||
330 | function bdir! { | 339 | function bdir! { | ||
331 | TARG=$(qdbus $KDEV_DBUS_ID /org/kdevelop/ProjectController org.kdevelop.ProjectController.mapSourceBuild "$(pwd)" false) | 340 | TARG=$($_qdbus $KDEV_DBUS_ID /org/kdevelop/ProjectController org.kdevelop.ProjectController.mapSourceBuild "$(pwd)" false) | ||
332 | if [ "$TARG" ]; then | 341 | if [ "$TARG" ]; then | ||
333 | cd $TARG | 342 | cd $TARG | ||
334 | else | 343 | else | ||
335 | echo "Got no path" | 344 | echo "Got no path" | ||
336 | fi | 345 | fi | ||
337 | } | 346 | } | ||
338 | 347 | | |||
339 | function project! { | 348 | function project! { | ||
340 | TARG=$(qdbus $KDEV_DBUS_ID /org/kdevelop/ProjectController org.kdevelop.ProjectController.mapSourceBuild "$(pwd)" true) | 349 | TARG=$($_qdbus $KDEV_DBUS_ID /org/kdevelop/ProjectController org.kdevelop.ProjectController.mapSourceBuild "$(pwd)" true) | ||
341 | if [ "$TARG" ]; then | 350 | if [ "$TARG" ]; then | ||
342 | cd $TARG | 351 | cd $TARG | ||
343 | else | 352 | else | ||
344 | echo "Got no path" | 353 | echo "Got no path" | ||
345 | fi | 354 | fi | ||
346 | } | 355 | } | ||
347 | 356 | | |||
348 | 357 | | |||
349 | # Main functions: | 358 | # Main functions: | ||
350 | 359 | | |||
351 | function raise! { | 360 | function raise! { | ||
352 | qdbus $KDEV_DBUS_ID /kdevelop/MainWindow org.kdevelop.MainWindow.ensureVisible | 361 | $_qdbus $KDEV_DBUS_ID /kdevelop/MainWindow org.kdevelop.MainWindow.ensureVisible | ||
353 | } | 362 | } | ||
354 | 363 | | |||
355 | function sync! { | 364 | function sync! { | ||
356 | local P=$(getActiveDocument $@) | 365 | local P=$(getActiveDocument $@) | ||
357 | if [ "$P" ]; then | 366 | if [ "$P" ]; then | ||
358 | 367 | | |||
359 | if [[ "$P" == fish://* ]]; then | 368 | if [[ "$P" == fish://* ]]; then | ||
360 | # This regular expression filters the user@host:port out of fish:///user@host:port/path/... | 369 | # This regular expression filters the user@host:port out of fish:///user@host:port/path/... | ||
▲ Show 20 Lines • Show All 199 Lines • ▼ Show 20 Line(s) | 568 | if [[ "$LOC" == "$1" ]]; then | |||
560 | continue; | 569 | continue; | ||
561 | fi | 570 | fi | ||
562 | if [[ "$LOC" == "$2" ]]; then | 571 | if [[ "$LOC" == "$2" ]]; then | ||
563 | continue; | 572 | continue; | ||
564 | fi | 573 | fi | ||
565 | LOCATION="$LOCATION;$(mapFileToClient $LOC)" | 574 | LOCATION="$LOCATION;$(mapFileToClient $LOC)" | ||
566 | done | 575 | done | ||
567 | 576 | | |||
568 | qdbus $KDEV_DBUS_ID /org/kdevelop/GrepViewPlugin org.kdevelop.GrepViewPlugin.startSearch "$PATTERN" "$LOCATION" true | 577 | $_qdbus $KDEV_DBUS_ID /org/kdevelop/GrepViewPlugin org.kdevelop.GrepViewPlugin.startSearch "$PATTERN" "$LOCATION" true | ||
569 | } | 578 | } | ||
570 | 579 | | |||
571 | function dsearch! { | 580 | function dsearch! { | ||
572 | PATTERN=$1 | 581 | PATTERN=$1 | ||
573 | 582 | | |||
574 | if ! [ "$PATTERN" ]; then | 583 | if ! [ "$PATTERN" ]; then | ||
575 | echo "Error: No pattern given." | 584 | echo "Error: No pattern given." | ||
576 | return 1 | 585 | return 1 | ||
Show All 12 Lines | 597 | if [[ "$LOC" == "$1" ]]; then | |||
589 | continue; | 598 | continue; | ||
590 | fi | 599 | fi | ||
591 | if [[ "$LOC" == "$2" ]]; then | 600 | if [[ "$LOC" == "$2" ]]; then | ||
592 | continue; | 601 | continue; | ||
593 | fi | 602 | fi | ||
594 | LOCATION="$LOCATION;$(mapFileToClient $LOC)" | 603 | LOCATION="$LOCATION;$(mapFileToClient $LOC)" | ||
595 | done | 604 | done | ||
596 | 605 | | |||
597 | qdbus $KDEV_DBUS_ID /org/kdevelop/GrepViewPlugin org.kdevelop.GrepViewPlugin.startSearch "$PATTERN" "$LOCATION" false | 606 | $_qdbus $KDEV_DBUS_ID /org/kdevelop/GrepViewPlugin org.kdevelop.GrepViewPlugin.startSearch "$PATTERN" "$LOCATION" false | ||
598 | } | 607 | } | ||
599 | 608 | | |||
600 | ##### SSH DBUS FORWARDING -------------------------------------------------------------------------------------------------------------------- | 609 | ##### SSH DBUS FORWARDING -------------------------------------------------------------------------------------------------------------------- | ||
601 | 610 | | |||
602 | DBUS_SOCKET_TRANSFORMER=$KDEV_BASEDIR/kdev_dbus_socket_transformer | 611 | DBUS_SOCKET_TRANSFORMER=$KDEV_BASEDIR/kdev_dbus_socket_transformer | ||
603 | 612 | | |||
604 | # We need this, to make sure that our forwarding-loops won't get out of control | 613 | # We need this, to make sure that our forwarding-loops won't get out of control | ||
605 | # This configures the shell to kill background jobs when it is terminated | 614 | # This configures the shell to kill background jobs when it is terminated | ||
▲ Show 20 Lines • Show All 216 Lines • Show Last 20 Lines |
Maybe rename to QDBUS_EXE?