summaryrefslogtreecommitdiff
path: root/.local/bin/development/nx
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/development/nx')
-rwxr-xr-x.local/bin/development/nx85
1 files changed, 3 insertions, 82 deletions
diff --git a/.local/bin/development/nx b/.local/bin/development/nx
index 862be99..8305487 100755
--- a/.local/bin/development/nx
+++ b/.local/bin/development/nx
@@ -21,7 +21,7 @@ shift $((OPTIND - 1))
[ "$#" -gt 1 ] && err "too many arguments. Only one expected"
-new_script() {
+new_file() {
cat << EOF > "$1"
#!/bin/sh
@@ -47,77 +47,8 @@ EOF
chmod u+x -- "$1" || exit
}
-
-new_c_file() {
- cat << EOF > "$1"
-#include <stdio.h>
-
-int main()
-{
- printf("Hello\n");
-
- return 0;
-}
-EOF
-}
-
-
-new_cpp_file() {
- cat << EOF > "$1"
-#include <iostream>
-
-using namespace std;
-
-int main()
-{
- cout << "Hello" << endl;
-
- cin.get();
- return 0;
-}
-EOF
-}
-
-
-new_py_file() {
- cat << EOF > "$1"
-import timeit
-
-print("Finished in %fs" % timeit.timeit())
-EOF
-}
-
-
-new_java_file() {
- PATTERN="Scanner"
- VIMCMDS="normal!2n\n noh"
- cat << EOF > "$1"
-import java.util.Scanner;
-
-class ${1%.java} {
- public static void main(String args[]) {
- Scanner sc = new Scanner(System.in);
-
- System.out.println("Finished!");
- sc.close
- }
-}
-EOF
-}
-
-
file="$1"
-new_file() {
- case "$file" in
- *.c) new_c_file "$file" ;;
- *.cpp) new_cpp_file "$file" ;;
- *.py) new_py_file "$file" ;;
- *.java) new_java_file "$file" ;;
- *) new_script "$file" ;;
- esac
-}
-
if [ -f "$file" ]; then
[ ! -w "$file" ] && chmod u+rw "$file"
if [ -s "$file" ]; then
@@ -134,15 +65,5 @@ fi
ls -lF --color -- "$file"
-case "$EDITOR" in
- '') echo "$0: \$EDITOR variable not set" >&2 && exit 1 ;;
- vi|*vim*)
- VIMCONF="$(mktemp)"; export VIMCONF
- [ -n "$VIOPTS" ] && echo "set $VIOPTS" >> "$VIMCONF"
- [ -n "$PATTERN" ] && echo "/$PATTERN" >> "$VIMCONF"
- [ -n "$VIMCMDS" ] && echo "$VIMCMDS" >> "$VIMCONF"
- $EDITOR -S "$VIMCONF" "$file"
- rm -f "$VIMCONF"
- ;;
- *) $EDITOR "$file" ;;
-esac; exit
+${EDITOR} "$file"
+