Ich habe die folgende Implementierung gefunden. Ich benutze es für Webentwicklungsprojekte. Konsolen für Task-Läufer (z. B. gulp), Git, Javascript-Compiler (z. B. typescript) usw. Ziel war es, 4 Konsolenfenster zu öffnen und das Verzeichnis in das Verzeichnis zu ändern, in dem ich die * .cmd ausgeführt habe. Ich wollte nicht mehrere Kopien des Stapelskripts haben, falls ich es ändern musste. Ich wollte nicht, dass die Shell Batch ist und ich wollte, dass die Shell Bash ist. Ich bin auf Windows, also wird Cygwin für die Bash-Shell benötigt.
Ich habe eine willkürlich benannte .cmd-Datei erstellt. Ich habe meine angerufen 4 consoles.cmd
. Cygwin ist installiert (die 64bit Version in meinem Fall). Auch das Cygwin- chere
Paket ist installiert und erforderlich.
4 consoles.cmd
Inhalt:
@echo off
for %%i in ("%~dp0..\..") DO (set dirVar=%%~ni)
for %%i in ("%~dp0.") DO (set dir2Var=%%~ni)
set finalValue=%dirVar% %dir2Var%
start C:\"Program Files"\ConEmu\ConEmu64.exe -cmdlist ^
C:\cygwin64\bin\bash -c "/bin/xhere /bin/bash.exe" -cur_console:fna:t:"%finalValue%":C:"C:\cygwin64\Cygwin.ico" ^|^|^| ^
C:\cygwin64\bin\bash -c "/bin/xhere /bin/bash.exe" -cur_console:s1TVna:t:"%finalValue%":C:"C:\cygwin64\Cygwin.ico" ^|^|^| ^
C:\cygwin64\bin\bash -c "/bin/xhere /bin/bash.exe" -cur_console:s1THna:t:"%finalValue%":C:"C:\cygwin64\Cygwin.ico" ^|^|^| ^
C:\cygwin64\bin\bash -c "/bin/xhere /bin/bash.exe" -cur_console:s2THna:t:"%finalValue%":C:"C:\cygwin64\Cygwin.ico"
Ich habe 4 consoles.cmd
einen Datei-Hosting-Dienst für Sicherungszwecke eingerichtet, falls meine Festplatte abstürzt. Auch für eine gewisse Bequemlichkeit beim Teilen zwischen Entwicklungsmaschinen.
Das Batch-Skript ändert das Verzeichnis für alle 4 Konsolenfenster in das Verzeichnis, in dem sich die .cmd befindet. Also habe ich Hard Symbolic-Links in dem Verzeichnis erstellt, in das alle 4 Konsolenfenster das Verzeichnis wechseln sollen. Die symbolischen Verknüpfungen verweisen zurück auf das Kanonische 4 consoles.cmd
.
Führen Sie eine symbolische Verknüpfung aus und die 4 Arbeitsverzeichnisse der Konsolen-Shells sind der Speicherort, an dem sich die symbolische Verknüpfung im Dateisystem befindet
Mein gulp task runner code für alle die interessiert sind
package.json
{
"name": "MyApp",
"version": "1.0.0",
"description": "",
"main": "gulpfile.js",
"private": true,
"devDependencies": {
"del": "^1.2.0",
"gulp": "^3.9.0",
"gulp-batch": "^1.0.5",
"gulp-concat": "^2.5.2",
"gulp-imagemin": "^2.2.1",
"gulp-minify-css": "^1.1.6",
"gulp-ng-annotate": "^1.0.0",
"gulp-plumber": "^1.0.1",
"gulp-rename": "^1.2.2",
"gulp-sourcemaps": "^1.5.2",
"gulp-uglify": "^1.2.0",
"gulp-watch": "^4.2.4",
"imagemin-pngquant": "^4.1.0"
},
"author": "Author",
"license": "ISC"
}
bower.json
{
"name": "MyProject",
"version": "1",
"license": "MIT",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components"
],
"dependencies": {
"bootstrap": "~3.3.4",
"jquery": "~2.1.3",
"angular": "~1.4.0",
"angular-route": "~1.4.0",
"angular-animate": "~1.4.0",
"font-awesome": "~4.3.0",
"underscore": "~1.8.3",
"bootstrap-datepicker": "~1.4.0",
"angularjs-toaster": "~0.4.12",
"angular-scroll": "~0.7.0",
"moment": "~2.10.2",
"angular-loading-bar": "~0.7.1"
}
}
gulpfile.js
'use strict';
var gulp = require('gulp');
var batch = require('gulp-batch');
var sourcemaps = require('gulp-sourcemaps');
var minifycss = require('gulp-minify-css');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var concat = require('gulp-concat');
var del = require('del');
var plumber = require('gulp-plumber');
var watch = require('gulp-watch');
var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
var ngAnnotate = require('gulp-ng-annotate');
gulp.task('default', ['clean'], function () {
gulp.start('images', 'vendorCss', 'applicationCss', 'fontIcons', 'vendorJavascript', 'applicationJavascript');
});
gulp.task('clean', function (cb) {
del(['./dist/*'], cb);
});
gulp.task('images', function () {
return gulp.src([
'./content/img/**/*'
])
.pipe(imagemin({
optimizationLevel: 3,
progressive: true,
interlaced: true,
svgoPlugins: [{ removeViewBox: false }],
use: [pngquant()]
}))
.pipe(gulp.dest('./dist/img'));
});
gulp.task('fontIcons', function () {
return gulp.src([
'./bower_components/bootstrap/dist/fonts/**.*',
'./bower_components/font-awesome/fonts/**.*'
])
.pipe(gulp.dest('./dist/fonts'));
});
gulp.task('vendorCss', function () {
return gulp.src([
'./bower_components/bootstrap/dist/css/bootstrap.css',
'./bower_components/font-awesome/css/font-awesome.css',
'./bower_components/angularjs-toaster/toaster.css',
'./bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker3.css',
'./bower_components/angular-loading-bar/build/loading-bar.css'
])
.pipe(concat('vendor.css'))
.pipe(gulp.dest('./dist/css'))
.pipe(rename({ suffix: '.min' }))
.pipe(minifycss())
.pipe(gulp.dest('./dist/css'));
});
gulp.task('vendorJavascript', function () {
return gulp.src([
'./bower_components/jquery/dist/jquery.js',
'./bower_components/angular/angular.js',
'./bower_components/angular-route/angular-route.js',
'./bower_components/angular-resource/angular-resource.js',
'./bower_components/angular-animate/angular-animate.js',
'./bower_components/angular-scroll/angular-scroll.js',
'./bower_components/angular-loading-bar/build/loading-bar.js',
'./bower_components/angularjs-toaster/toaster.js',
'./bower_components/bootstrap/dist/js/bootstrap.js',
'./bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.js',
'./bower_components/underscore/underscore.js',
'./bower_components/moment/moment.js'
])
.pipe(sourcemaps.init())
.pipe(concat('vendor.js'))
.pipe(gulp.dest('./dist/script'))
.pipe(uglify())
.pipe(rename('vendor.min.js'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./dist/script'));
});
gulp.task('applicationCss', function () {
return gulp.src([
'./content/css/site.css',
'./content/css/animation.css'
])
.pipe(plumber())
.pipe(concat('app.css'))
.pipe(gulp.dest('./dist/css'))
.pipe(rename({ suffix: '.min' }))
.pipe(minifycss())
.pipe(gulp.dest('./dist/css'));
});
gulp.task('applicationJavascript', function () {
return gulp.src([
'./angular/**/*.js'
])
.pipe(plumber())
.pipe(ngAnnotate())
.pipe(sourcemaps.init())
.pipe(concat('app.js'))
.pipe(gulp.dest('./dist/script'))
.pipe(uglify())
.pipe(rename('app.min.js'))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./dist/script'));
});
gulp.task('watchApplicationJavascript', ['applicationJavascript'], function () {
watch('./angular/**/*.js', batch(function (events, done) {
gulp.start('applicationJavascript', done);
}));
});
gulp.task('watchApplicationCss', ['applicationCss'], function () {
watch(['./content/css/site.css', './content/css/animation.css'], batch(function (events, done) {
gulp.start('applicationCss', done);
}));
});