@@ -8,7 +8,8 @@ Solutions to leetcode problems.
8
8
```
9
9
#!/bin/bash
10
10
11
- editor="sublime-text.subl"
11
+ LLANG="java"
12
+ EDITOR="sublime-text.subl"
12
13
LEETCODE='/home/user/.local/bin/leetcode'
13
14
14
15
_yargs_completions()
@@ -83,7 +84,7 @@ function fetch {
83
84
out=$("$LEETCODE" submission "$1");
84
85
echo "$out";
85
86
if [ "$(echo -n $out | awk '{ print $NF }')" != "submissions?" ]; then
86
- $($editor "$(echo -n $out | awk '{ print $NF }')");
87
+ $($EDITOR "$(echo -n $out | awk '{ print $NF }')");
87
88
fi
88
89
fi
89
90
}
@@ -97,21 +98,26 @@ function solution {
97
98
function resume {
98
99
Q="$(cat .lastAttempt | tr -d '\n')";
99
100
"$LEETCODE" show $(echo -n "${Q%%.*}");
100
- $($editor "$(cat .lastAttempt | tr -d '\n')");
101
+ $($EDITOR "$(cat .lastAttempt | tr -d '\n')");
101
102
}
102
103
alias startt="xterm -geometry 45x21-0+0 termdown &";
103
- #function startt{
104
- # "xterm -geometry 42x21-0+0 termdown &"
105
- #}
104
+
105
+ function restartTimer {
106
+ pkill -f termdown
107
+ xterm -geometry 48x27-0+0 termdown &
108
+ # pkill -f leetimer
109
+ # ./.leetimer.sh &
110
+ }
111
+
106
112
function solve {
107
113
if [ -z "$1" ]; then
108
114
resume;
109
115
elif [ -z "$2" ] && [ ! -z "$(ls | grep -i "^$1\.")" ]; then
110
- "$editor " "$(ls | grep -i "$(ls | grep -i " ^$1\.")" )";
116
+ "$EDITOR " "$(ls | grep -i "^$1\." | head -n1 )";
111
117
else
112
- show "$1" -gxe - q D -l java ;
118
+ "$LEETCODE" show "$1" -gx -e "${EDITOR}" - q D -l ${LLANG} ;
113
119
fi
114
- xterm -geometry 48x27-0+0 termdown &
120
+ restartTimer;
115
121
}
116
122
117
123
export -f run
0 commit comments