Declare functions with the ~function~ keyword

master
Jacopo De Simoi 3 years ago
parent 8049f9164a
commit 37f564018a
  1. 53
      zshrc.org

@ -80,21 +80,21 @@ The other two swap between build and src dirs on my local git checkout
#+begin_src sh :tangle kde-utils.sh
#!/bin/zsh
kde-current-activity () {
function kde-current-activity () {
qdbus >/dev/null && kactivities-cli --current-activity | awk {'print $2'}
}
kde-current-activity-name () {
function kde-current-activity-name () {
qdbus >/dev/null && kactivities-cli --current-activity | awk {'print $3'}
}
local kde_src_basedir="/scratch/src/kde"
local kde_build_basedir="/scratch/src/kde/build"
kde-cd-build () {
function kde-cd-build () {
cd ${PWD/$kde_src_basedir/$kde_build_basedir/}
}
kde-cd-src () {
function kde-cd-src () {
cd ${PWD/$kde_build_basedir/$kde_src_basedir/}
}
#+end_src
@ -102,7 +102,7 @@ The other two swap between build and src dirs on my local git checkout
Send a message through OSD
#+begin_src sh :tangle kde-utils.sh
kde-osd-message() {
function kde-osd-message() {
qdbus org.freedesktop.Notifications /org/kde/osdService org.kde.osdService.showText alert $1
}
#+end_src
@ -124,11 +124,11 @@ source ~/scripts/kde-utils.sh
These are various helpers to drive my current Android phone when connected to the box.
#+begin_src sh
run-task () {
function run-task () {
adb -s $ANDROID_CUR shell am broadcast --user 0 -a net.dinglish.tasker.run_task -e task "$1"
}
android-remote-keyboard()
function android-remote-keyboard()
{
# should set this up in a tmux session
adb -s $ANDROID_CUR shell ime set de.onyxbits.remotekeyboard/.RemoteKeyboardService;
@ -136,7 +136,7 @@ These are various helpers to drive my current Android phone when connected to th
sleep 1;
telnet 127.0.0.1 6023
}
android-remote-keyboard-wifi()
function android-remote-keyboard-wifi()
{
# should set this up in a tmux session
adb -s $ANDROID_IP:5555 shell ime set de.onyxbits.remotekeyboard/.RemoteKeyboardService;
@ -145,8 +145,7 @@ These are various helpers to drive my current Android phone when connected to th
telnet 127.0.0.1 6023
}
android-remote-keyboard-blu()
function android-remote-keyboard-blu()
{
# should set this up in a tmux session
adb -s $ANDROID_BLU shell ime set de.onyxbits.remotekeyboard/.RemoteKeyboardService;
@ -155,14 +154,14 @@ These are various helpers to drive my current Android phone when connected to th
telnet 127.0.0.1 6028
}
setup-ipwebcam()
function setup-ipwebcam()
{
adb -s $ANDROID_BLU forward tcp:8097 tcp:8080
ffmpeg -i http://localhost:8097/video -map 0:v -pix_fmt yuv420p -f v4l2 /dev/video2
adb -s $ANDROID_BLU forward --remove tcp:8097
}
setup-pi-webcam()
function setup-pi-webcam()
{
ffmpeg -i http://192.168.0.41:8080/stream/video.mjpeg -map 0:v -pix_fmt yuv420p -f v4l2 /dev/video2
}
@ -171,7 +170,7 @@ These are various helpers to drive my current Android phone when connected to th
This is an autoremote helper
#+begin_src sh
autoremote () {
function autoremote () {
curl "https://autoremotejoaomgcd.appspot.com/sendmessage?key=cVRJiHQtxGk:APA91bGQz3O3Z5RUkgvq6hXzlIiLvyC8ZVW5XlgIBhLO5Li3QwZausSkoaK48D3jyhFcJAi3pqB-T4fI45rICR0Rld9ikeTHMZp2m6w05FxaSvQcdofJ3blyxJGLT9B-6oGruLenXdrM&message=$(echo $1 | sed -e 's/ /\%20/g')&password=$(pass autoremote)"
}
#+end_src
@ -182,7 +181,7 @@ This is an autoremote helper
This function checks if we are in a tmux session before
executing the command; otherwise print an error and bail out
#+begin_src sh
tmux-guard()
function tmux-guard()
{
if [[ -v TMUX ]]; then
$@
@ -193,7 +192,7 @@ This is an autoremote helper
#+end_src
- wttr.in
#+begin_src sh
wttr()
function wttr()
{
local location=Toronto
[[ $(tput cols) -le 124 ]] && local narrow=n;
@ -207,7 +206,7 @@ This is an autoremote helper
BIG FAT WARNING: this needs to specify an actual file as a destination
(similar to ln) adding a directory would not work.
#+begin_src sh
bl()
function bl()
{
mv $1 $2
ln $2 $1
@ -237,11 +236,11 @@ BIG FAT WARNING: this needs to specify an actual file as a destination
}
#+end_src
*** shell helpers :daily:pi:android:
Underscore filename
This function is a poor-man eselect for configuration files it mv's
filename to filename_ or viceversa
#+begin_src sh
# this function is a poor-man eselect for configuration files
# it mv's filename to filename_ or viceversa
uv() {
function uv()
{
if [[ -f $1 ]]; then
if [[ ${1:(-1)} == '_' ]]; then
mv -i $1 ${1%_}
@ -290,16 +289,16 @@ Underscore filename
#+end_src
**** mu4e + agenda :daily:
#+begin_src sh
μ() {
function μ() {
eca -e "(mu4e)"
}
agenda() {
function agenda() {
# TODO: add parameter just in case
eca -e "(org-agenda-list)"
}
kill-emacs() {
function kill-emacs() {
eca -e "(kill-emacs)"
}
#+end_src
@ -427,19 +426,19 @@ This needs to be diff'd among the versions
#+end_src
*** git helpers :daily:
#+begin_src sh
git-create-pi-remote () {
function git-create-pi-remote () {
REPO_NAME=$(basename "`pwd`")
source ~/scripts/git-init-pi4.sh "$REPO_NAME.git"
git remote add π "git@ssh.jacopods.xyz:repos/$REPO_NAME.git"
}
git-create-thinkspoon-remote () {
function git-create-thinkspoon-remote () {
REPO_NAME=$(basename "`pwd`")
source ~/scripts/git-init-thinkspoon.sh "$REPO_NAME.git"
git remote add thinkspoon "git@thinkspoon.local:repos/$REPO_NAME.git"
}
git-current-branch () {
function git-current-branch () {
git status -b | head -n 1 | awk {'print $3'}
}
#+end_src
@ -530,7 +529,7 @@ technique
alias acroread="env WINEPREFIX=$HOME/.wine32 WINEARCH='win32' wine ~/.wine32/drive_c/Program\ Files/Adobe/Reader\ 11.0/Reader/AcroRd32.exe >/dev/null 2>/dev/null"
run-silent() {
function run-silent() {
"$@" 2>/dev/null
}

Loading…
Cancel
Save