This commit is contained in:
2024-04-30 07:08:23 +02:00
commit a711247971
2043 changed files with 16874 additions and 0 deletions

7
snippets/sh-mode/args Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: args
# key: args
# --
if [ $# -lt ${1:2} ]
then $0
fi

6
snippets/sh-mode/bang Normal file
View File

@@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: bang
# key: !
# --
#!/usr/bin/env bash
$0

10
snippets/sh-mode/case Normal file
View File

@@ -0,0 +1,10 @@
# -*- mode: snippet -*-
# name: case
# key: case
# --
case ${1:cond} in
${2:pattern} )
${3:stuff}
;;
$0
esac

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: for loop
# key: for
# --
for ${1:var} in ${2:stuff}; do
$0
done

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: function
# key: f
# --
function ${1:name} {
$0
}

8
snippets/sh-mode/if Normal file
View File

@@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: if
# key: if
# --
if ${1:[ -f file]}
then ${2:do}
fi
$0

9
snippets/sh-mode/ife Normal file
View File

@@ -0,0 +1,9 @@
# -*- mode: snippet -*-
# name: ife
# key: ife
# --
if ${1:cond}
then ${2:stuff}
else ${3:other}
fi
$0

View File

@@ -0,0 +1,9 @@
# -*- mode: snippet -*-
# name: safer bash settings for scripts
# key: s!
# --
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
$0

View File

@@ -0,0 +1,14 @@
# -*- mode: snippet -*-
# name: the currently executing/sourced script's directory
# key: script-dir
# --
# See https://stackoverflow.com/a/246128/3561275
SOURCE="\${BASH_SOURCE[0]}"
while [ -h "\$SOURCE" ]; do # resolve \$SOURCE until the file is no longer a symlink
DIR="\$( cd -P "\$( dirname "\$SOURCE" )" >/dev/null 2>&1 && pwd )"
SOURCE="\$(readlink "\$SOURCE")"
[[ \$SOURCE != /* ]] && SOURCE="\$DIR/\$SOURCE" # if \$SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="\$( cd -P "\$( dirname "\$SOURCE" )" >/dev/null 2>&1 && pwd )"
$0

7
snippets/sh-mode/select Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: select
# key: select
# --
select ${1:var} in ${2:stuff}; do
$0
done

7
snippets/sh-mode/until Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: until loop
# key: until
# --
until ${1:cond}; do
$0
done

7
snippets/sh-mode/while Normal file
View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: while loop
# key: while
# --
while ${1:cond}; do
$0
done