From 45a3550acdfb981823e7fadd62db3eb59e7ae48c Mon Sep 17 00:00:00 2001 From: Masanori Tani Date: Thu, 13 Jul 2023 02:01:01 +0900 Subject: [PATCH] Initialize for Emacs --- .devcontainer/devcontainer.json | 12 --- .devcontainer/scripts/post-create.sh | 10 -- .vscode/settings.json | 10 -- README.md | 44 +-------- bootstrap.sh | 14 --- deno.json | 12 --- deno.lock | 36 ------- deps/README.md | 5 - deps/core/deps.ts | 1 - deps/core/mod.ts | 45 --------- deps/utils/deps.ts | 2 - deps/utils/mod.ts | 77 --------------- emacs/init.el | 1 + manager/action/change-shell.ts | 75 -------------- manager/action/direnv.ts | 38 -------- manager/action/go.ts | 39 -------- manager/action/mod.ts | 19 ---- manager/action/poetry.ts | 38 -------- manager/action/rust.ts | 39 -------- manager/action/sheldon.ts | 39 -------- manager/action/starship.ts | 38 -------- manager/action/volta.ts | 38 -------- manager/deps.ts | 6 -- manager/main.ts | 52 ---------- manager/remove.ts | 13 --- manager/remove/mod.ts | 3 - source/bashrc | 140 --------------------------- source/gitconfig | 16 --- source/gpg/gpg-agent.conf | 2 - source/sheldon.toml | 26 ----- source/starship.toml | 47 --------- source/tmux.conf | 0 source/zshrc | 78 --------------- 33 files changed, 2 insertions(+), 1013 deletions(-) delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .devcontainer/scripts/post-create.sh delete mode 100644 .vscode/settings.json delete mode 100644 bootstrap.sh delete mode 100644 deno.json delete mode 100644 deno.lock delete mode 100644 deps/README.md delete mode 100644 deps/core/deps.ts delete mode 100644 deps/core/mod.ts delete mode 100644 deps/utils/deps.ts delete mode 100644 deps/utils/mod.ts create mode 100644 emacs/init.el delete mode 100644 manager/action/change-shell.ts delete mode 100644 manager/action/direnv.ts delete mode 100644 manager/action/go.ts delete mode 100644 manager/action/mod.ts delete mode 100644 manager/action/poetry.ts delete mode 100644 manager/action/rust.ts delete mode 100644 manager/action/sheldon.ts delete mode 100644 manager/action/starship.ts delete mode 100644 manager/action/volta.ts delete mode 100644 manager/deps.ts delete mode 100644 manager/main.ts delete mode 100644 manager/remove.ts delete mode 100644 manager/remove/mod.ts delete mode 100644 source/bashrc delete mode 100644 source/gitconfig delete mode 100644 source/gpg/gpg-agent.conf delete mode 100644 source/sheldon.toml delete mode 100644 source/starship.toml delete mode 100644 source/tmux.conf delete mode 100644 source/zshrc diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index f1aebac..0000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "Ubuntu", - "image": "mcr.microsoft.com/devcontainers/base:jammy", - "postCreateCommand": ". ${containerWorkspaceFolder}/.devcontainer/scripts/post-create.sh", - "customizations": { - "vscode": { - "extensions": [ - "denoland.vscode-deno" - ] - } - } -} diff --git a/.devcontainer/scripts/post-create.sh b/.devcontainer/scripts/post-create.sh deleted file mode 100644 index 6b9d2c1..0000000 --- a/.devcontainer/scripts/post-create.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -set -ue - -curl -fsSL https://deno.land/x/install/install.sh | sh - -echo 'export DENO_INSTALL="$HOME/.deno"' >> ~/.bashrc -echo 'export PATH="$DENO_INSTALL/bin:$PATH"' >> ~/.bashrc - -exec /bin/bash --login diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index be481ea..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "deno.enable": true, - "deno.lint": true, - "deno.config": "./deno.json", - "editor.defaultFormatter": "denoland.vscode-deno", - "editor.formatOnSave": true, - "[markdown]": { - "editor.formatOnSave": false - } -} diff --git a/README.md b/README.md index a6e9104..c5d06bc 100644 --- a/README.md +++ b/README.md @@ -1,43 +1 @@ -# dotfiles - -my dotfiles - -# 手順 - -Install [deno](https://deno.land/) - -```console -curl -fsSL https://deno.land/x/install/install.sh | sh -``` - -`~/.bashrc`, `~/.zshrc` に以下を書き込む(後で `~/.zshrc` は上書きされる) - -```bash -export DENO_INSTALL="$HOME/.deno" -export PATH="$DENO_INSTALL/bin:$PATH" -``` - -Execute - -```console -# TODO: shell script bootstrap -# curl https://raw.githubusercontent.com/uta8a/dotfiles/main/bootstrap.sh | bash -``` - -# dev - -```console -deno task deploy # deploy dotfiles -deno task check # check stat -deno task rm # rm symlinks or files -``` - -# directory - -```text -.devcontainer/ # for develop -.vscode/ # for develop -deps/ # temporary, switch to upstream in the future -manager/ # manager of dotfiles, powered by AumyF/dotstingray -source/ # dotfiles -``` +# Emacs \ No newline at end of file diff --git a/bootstrap.sh b/bootstrap.sh deleted file mode 100644 index 4ef7eb5..0000000 --- a/bootstrap.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -set -ue - -curl -fsSL https://deno.land/x/install/install.sh | sh - -export DENO_INSTALL="$HOME/.deno" -export PATH="$DENO_INSTALL/bin:$PATH" - -# mkdir -p $DIR -# git clone dotfiles -# deno task rm -# deno task deploy -# source ~/.zshrc -# deno task check \ No newline at end of file diff --git a/deno.json b/deno.json deleted file mode 100644 index 36ae73b..0000000 --- a/deno.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "fmt": { - "options": { - "semiColons": true - } - }, - "tasks": { - "deploy": "deno run --unstable --allow-run --allow-env --allow-read --allow-write manager/main.ts deploy", - "check": "deno run --unstable --allow-run --allow-env --allow-read manager/main.ts check", - "rm": "deno run --unstable --allow-env --allow-read --allow-write manager/remove.ts" - } -} diff --git a/deno.lock b/deno.lock deleted file mode 100644 index d666c40..0000000 --- a/deno.lock +++ /dev/null @@ -1,36 +0,0 @@ -{ - "version": "2", - "remote": { - "https://deno.land/std@0.177.0/_util/asserts.ts": "178dfc49a464aee693a7e285567b3d0b555dc805ff490505a8aae34f9cfb1462", - "https://deno.land/std@0.177.0/_util/os.ts": "d932f56d41e4f6a6093d56044e29ce637f8dcc43c5a90af43504a889cf1775e3", - "https://deno.land/std@0.177.0/fmt/colors.ts": "938c5d44d889fb82eff6c358bea8baa7e85950a16c9f6dae3ec3a7a729164471", - "https://deno.land/std@0.177.0/fs/_util.ts": "65381f341af1ff7f40198cee15c20f59951ac26e51ddc651c5293e24f9ce6f32", - "https://deno.land/std@0.177.0/fs/copy.ts": "14214efd94fc3aa6db1e4af2b4b9578e50f7362b7f3725d5a14ad259a5df26c8", - "https://deno.land/std@0.177.0/fs/empty_dir.ts": "c3d2da4c7352fab1cf144a1ecfef58090769e8af633678e0f3fabaef98594688", - "https://deno.land/std@0.177.0/fs/ensure_dir.ts": "724209875497a6b4628dfb256116e5651c4f7816741368d6c44aab2531a1e603", - "https://deno.land/std@0.177.0/fs/ensure_file.ts": "c38602670bfaf259d86ca824a94e6cb9e5eb73757fefa4ebf43a90dd017d53d9", - "https://deno.land/std@0.177.0/fs/ensure_link.ts": "c0f5b2f0ec094ed52b9128eccb1ee23362a617457aa0f699b145d4883f5b2fb4", - "https://deno.land/std@0.177.0/fs/ensure_symlink.ts": "2955cc8332aeca9bdfefd05d8d3976b94e282b0f353392a71684808ed2ffdd41", - "https://deno.land/std@0.177.0/fs/eol.ts": "f1f2eb348a750c34500741987b21d65607f352cf7205f48f4319d417fff42842", - "https://deno.land/std@0.177.0/fs/exists.ts": "b8c8a457b71e9d7f29b9d2f87aad8dba2739cbe637e8926d6ba6e92567875f8e", - "https://deno.land/std@0.177.0/fs/expand_glob.ts": "45d17e89796a24bd6002e4354eda67b4301bb8ba67d2cac8453cdabccf1d9ab0", - "https://deno.land/std@0.177.0/fs/mod.ts": "bc3d0acd488cc7b42627044caf47d72019846d459279544e1934418955ba4898", - "https://deno.land/std@0.177.0/fs/move.ts": "4cb47f880e3f0582c55e71c9f8b1e5e8cfaacb5e84f7390781dd563b7298ec19", - "https://deno.land/std@0.177.0/fs/walk.ts": "ea95ffa6500c1eda6b365be488c056edc7c883a1db41ef46ec3bf057b1c0fe32", - "https://deno.land/std@0.177.0/path/_constants.ts": "e49961f6f4f48039c0dfed3c3f93e963ca3d92791c9d478ac5b43183413136e0", - "https://deno.land/std@0.177.0/path/_interface.ts": "6471159dfbbc357e03882c2266d21ef9afdb1e4aa771b0545e90db58a0ba314b", - "https://deno.land/std@0.177.0/path/_util.ts": "d7abb1e0dea065f427b89156e28cdeb32b045870acdf865833ba808a73b576d0", - "https://deno.land/std@0.177.0/path/common.ts": "ee7505ab01fd22de3963b64e46cff31f40de34f9f8de1fff6a1bd2fe79380000", - "https://deno.land/std@0.177.0/path/glob.ts": "d479e0a695621c94d3fd7fe7abd4f9499caf32a8de13f25073451c6ef420a4e1", - "https://deno.land/std@0.177.0/path/mod.ts": "4b83694ac500d7d31b0cdafc927080a53dc0c3027eb2895790fb155082b0d232", - "https://deno.land/std@0.177.0/path/posix.ts": "8b7c67ac338714b30c816079303d0285dd24af6b284f7ad63da5b27372a2c94d", - "https://deno.land/std@0.177.0/path/separator.ts": "0fb679739d0d1d7bf45b68dacfb4ec7563597a902edbaf3c59b50d5bcadd93b1", - "https://deno.land/std@0.177.0/path/win32.ts": "d186344e5583bcbf8b18af416d13d82b35a317116e6460a5a3953508c3de5bba", - "https://deno.land/x/dotstingray@v0.1.1/core/deps.ts": "35ebeb0429b4f32e5cd94c6ec20cadacaa00fc660a396dbac11ed9b93686b067", - "https://deno.land/x/dotstingray@v0.1.1/core/mod.ts": "499f74693d3e30021144613d8aaba7d04b0c18e4d4e3212a9d38be78a9bb81cf", - "https://deno.land/x/dotstingray@v0.1.1/utils/deps.ts": "33183b4f41a2ba01891a505a80495d4f145220c044150fc743eec7d0b3dc7645", - "https://deno.land/x/dotstingray@v0.1.1/utils/mod.ts": "deb9b8246edde85d57e6190df65ed121880bb3e4717cd6ceb1aa79f006cde60d", - "https://raw.githubusercontent.com/AumyF/dotstingray/v0.1.0/core/mod.ts": "6abdb5533718f04f6f28593c99eee28aaf1bf6aea8aa2a752b7f42b755bf783a", - "https://raw.githubusercontent.com/AumyF/dotstingray/v0.1.0/utils/mod.ts": "8492a4c42b03297fa9ee4c4c584943f2e788e53430ea8ce5d608ad5295699c04" - } -} diff --git a/deps/README.md b/deps/README.md deleted file mode 100644 index c59eade..0000000 --- a/deps/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Credit - -Original work: [AumyF/dotstingray](https://github.com/AumyF/dotstingray) - -TODO: switch to upstream diff --git a/deps/core/deps.ts b/deps/core/deps.ts deleted file mode 100644 index 97caa6c..0000000 --- a/deps/core/deps.ts +++ /dev/null @@ -1 +0,0 @@ -export { green, red } from "https://deno.land/std@0.177.0/fmt/colors.ts"; diff --git a/deps/core/mod.ts b/deps/core/mod.ts deleted file mode 100644 index a065f63..0000000 --- a/deps/core/mod.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { green, red } from "./deps.ts"; - -export type Stat = - & { name: string } - & ({ ok: true; message?: undefined } | { ok: false; message: string }); - -export type Action = { - /** A function to set the environment up. As its return type `Promise` suggests, it may include side effects such as software installation or filesystem write. */ - run: () => Promise; - /** Checks whether the environment is set up correctly. It should not have any implicit outputs. */ - stat: () => Promise; -}; - -export type Task = { stat: () => Promise; run: () => Promise }; - -export const defineTask = (actions: Action[]) => { - const printStat = async () => { - for (const { stat } of actions) { - const statResult = await stat(); - if (statResult.ok) { - console.log(green(`OK ${statResult.name}`)); - } else { - console.log(red(`KO ${statResult.name}: ${statResult.message}`)); - } - } - }; - - const executeRun = async () => { - for (const { stat, run } of actions) { - const statResult = await stat(); - - if (statResult.ok) continue; - - try { - await run(); - } catch (e) { - console.log(red(`KO ${statResult.name}: ${e?.message}`)); - continue; - } - console.log(green(`OK ${statResult.name}`)); - } - }; - - return { stat: printStat, run: executeRun }; -}; diff --git a/deps/utils/deps.ts b/deps/utils/deps.ts deleted file mode 100644 index 0387881..0000000 --- a/deps/utils/deps.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { ensureDir } from "https://deno.land/std@0.177.0/fs/mod.ts"; -export { dirname } from "https://deno.land/std@0.177.0/path/mod.ts"; diff --git a/deps/utils/mod.ts b/deps/utils/mod.ts deleted file mode 100644 index 7409a98..0000000 --- a/deps/utils/mod.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { dirname, ensureDir } from "./deps.ts"; -import { Action } from "../core/mod.ts"; - -/** Given a `source` and a `destination`, returns `Action` which represents symbolic link from `source` to `destination`. */ -export const link = ( - { source, destination }: { source: string; destination: string }, -): Action => ({ - run: async () => { - await ensureDir(dirname(destination)); - await Deno.symlink(await Deno.realPath(source), destination); - }, - stat: async () => { - let path: string; - - try { - path = await Deno.readLink(destination); - } catch (e) { - return { name: destination, ok: false, message: e.message }; - } - - let sourcePath: string; - try { - sourcePath = await Deno.realPath(source); - } catch (e) { - return { name: destination, ok: false, message: e.message }; - } - - if (path === sourcePath) { - return { name: destination, ok: true }; - } else { - return { - name: destination, - ok: false, - message: "symlink does not point the destination", - }; - } - }, -}); - -/** Given a `content` and a `destination`, returns `Action` which represents writing `content` to `destination`. - */ -export const write = ( - { content, destination }: { - content: Uint8Array | string; - destination: string; - }, -): Action => ({ - run: async () => { - await ensureDir(dirname(destination)); - - if (content instanceof Uint8Array) { - await Deno.writeFile(destination, content); - } else { - await Deno.writeTextFile(destination, content); - } - }, - stat: async () => { - try { - await Deno.realPath(destination); - } catch (e) { - return { name: destination, ok: false, message: e.message }; - } - - let sourceContent; - if (content instanceof Uint8Array) { - sourceContent = await Deno.readFile(destination); - } else { - sourceContent = await Deno.readTextFile(destination); - } - - if (sourceContent === content) { - return { name: destination, ok: true }; - } else { - return { name: destination, ok: false, message: "file differs" }; - } - }, -}); diff --git a/emacs/init.el b/emacs/init.el new file mode 100644 index 0000000..08eb45a --- /dev/null +++ b/emacs/init.el @@ -0,0 +1 @@ +(message "hello") diff --git a/manager/action/change-shell.ts b/manager/action/change-shell.ts deleted file mode 100644 index 608ac22..0000000 --- a/manager/action/change-shell.ts +++ /dev/null @@ -1,75 +0,0 @@ -import type { Action, Stat } from "../deps.ts"; - -// sudo chsh -s /bin/SHELL_NAME - -const reverseRecord = < - T extends PropertyKey, - U extends PropertyKey, ->(input: Record) => { - return Object.fromEntries( - Object.entries(input).map(([key, value]) => [ - value, - key, - ]), - ) as Record; -}; - -const shells: Record = { - sh: "/bin/sh", - bash: "/bin/bash", - zsh: "/bin/zsh", -}; - -class ShellPromise implements PromiseLike { - readonly #promise: Promise; - - constructor(stat: Stat) { - this.#promise = Promise.resolve(stat); - } - - then( - onFulfilled?: - | ((value: Stat) => Result1 | PromiseLike) - | undefined - | null, - onRejected?: - | ((reason: unknown) => Result2 | PromiseLike) - | undefined - | null, - ): Promise { - return this.#promise.then(onFulfilled, onRejected); - } -} - -export const changeShell = ( - { destination }: { destination: string }, -): Action => ({ - run: async () => { - // Deno.Command needs unstable - const chsh = new Deno.Command("sudo", { - args: ["chsh", "-s", shells[destination]], - }); - const output = await chsh.output(); - if (!output.success) { - throw new Error(new TextDecoder().decode(output.stderr)); - } - }, - stat: async () => { - const target = Deno.env.get("SHELL"); - - if (!target) { - return { name: destination, ok: false, message: "$SHELL is not set." }; - } - const checkShells = reverseRecord(shells); - if (checkShells[target] !== destination) { - return { - name: destination, - ok: false, - message: `$SHELL=${checkShells[target]} is not ${destination}.`, - }; - } - // return PromiseLike to avoid warning - const promise = new ShellPromise({ name: destination, ok: true }); - return await promise; - }, -}); diff --git a/manager/action/direnv.ts b/manager/action/direnv.ts deleted file mode 100644 index 618b2e4..0000000 --- a/manager/action/direnv.ts +++ /dev/null @@ -1,38 +0,0 @@ -import type { Action } from "../deps.ts"; - -export const installDirenv = (): Action => ({ - run: async () => { - const p = Deno.run({ - cmd: ["bash"], - stdout: "piped", - stdin: "piped", - }); - - const install = "curl -sfL https://direnv.net/install.sh | bash"; - await p.stdin.write(new TextEncoder().encode(install)); - - await p.stdin.close(); - const output = await p.output(); - if (!(await p.status()).success) { - throw new Error(new TextDecoder().decode(output)); - } - p.close(); - }, - stat: async () => { - const checker = new Deno.Command("direnv", { args: ["--version"] }); - let output: Deno.CommandOutput; - try { - output = await checker.output(); - } catch (e) { - return { name: "direnv", ok: false, message: e.message }; - } - if (!output.success) { - return { - name: "direnv", - ok: false, - message: new TextDecoder().decode(output.stderr), - }; - } - return { name: "direnv", ok: true }; - }, -}); diff --git a/manager/action/go.ts b/manager/action/go.ts deleted file mode 100644 index fb0cf67..0000000 --- a/manager/action/go.ts +++ /dev/null @@ -1,39 +0,0 @@ -import type { Action } from "../deps.ts"; - -export const installGo = (): Action => ({ - run: async () => { - const p = Deno.run({ - cmd: ["bash"], - stdout: "piped", - stdin: "piped", - }); - - const install = - "wget https://go.dev/dl/go1.20.linux-amd64.tar.gz -O - | sudo tar xzf - -C /usr/local/bin"; - await p.stdin.write(new TextEncoder().encode(install)); - - await p.stdin.close(); - const output = await p.output(); - if (!(await p.status()).success) { - throw new Error(new TextDecoder().decode(output)); - } - p.close(); - }, - stat: async () => { - const checker = new Deno.Command("go", { args: ["version"] }); - let output: Deno.CommandOutput; - try { - output = await checker.output(); - } catch (e) { - return { name: "go", ok: false, message: e.message }; - } - if (!output.success) { - return { - name: "go", - ok: false, - message: new TextDecoder().decode(output.stderr), - }; - } - return { name: "go", ok: true }; - }, -}); diff --git a/manager/action/mod.ts b/manager/action/mod.ts deleted file mode 100644 index 240d698..0000000 --- a/manager/action/mod.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { changeShell } from "./change-shell.ts"; -import { installRust } from "./rust.ts"; -import { installDirenv } from "./direnv.ts"; -import { installGo } from "./go.ts"; -import { installPoetry } from "./poetry.ts"; -import { installSheldon } from "./sheldon.ts"; -import { installStarship } from "./starship.ts"; -import { installVolta } from "./volta.ts"; - -export { - changeShell, - installDirenv, - installGo, - installPoetry, - installRust, - installSheldon, - installStarship, - installVolta, -}; diff --git a/manager/action/poetry.ts b/manager/action/poetry.ts deleted file mode 100644 index 20b9e48..0000000 --- a/manager/action/poetry.ts +++ /dev/null @@ -1,38 +0,0 @@ -import type { Action } from "../deps.ts"; - -export const installPoetry = (): Action => ({ - run: async () => { - const p = Deno.run({ - cmd: ["bash"], - stdout: "piped", - stdin: "piped", - }); - - const install = "curl -sSL https://install.python-poetry.org | python3 -"; - await p.stdin.write(new TextEncoder().encode(install)); - - await p.stdin.close(); - const output = await p.output(); - if (!(await p.status()).success) { - throw new Error(new TextDecoder().decode(output)); - } - p.close(); - }, - stat: async () => { - const checker = new Deno.Command("poetry", { args: ["--version"] }); - let output: Deno.CommandOutput; - try { - output = await checker.output(); - } catch (e) { - return { name: "poetry", ok: false, message: e.message }; - } - if (!output.success) { - return { - name: "poetry", - ok: false, - message: new TextDecoder().decode(output.stderr), - }; - } - return { name: "poetry", ok: true }; - }, -}); diff --git a/manager/action/rust.ts b/manager/action/rust.ts deleted file mode 100644 index 2dc5c08..0000000 --- a/manager/action/rust.ts +++ /dev/null @@ -1,39 +0,0 @@ -import type { Action } from "../deps.ts"; - -export const installRust = (): Action => ({ - run: async () => { - const p = Deno.run({ - cmd: ["bash"], - stdout: "piped", - stdin: "piped", - }); - - const install = - "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y"; - await p.stdin.write(new TextEncoder().encode(install)); - - await p.stdin.close(); - const output = await p.output(); - if (!(await p.status()).success) { - throw new Error(new TextDecoder().decode(output)); - } - p.close(); - }, - stat: async () => { - const checker = new Deno.Command("rustup", { args: ["--version"] }); - let output: Deno.CommandOutput; - try { - output = await checker.output(); - } catch (e) { - return { name: "rust", ok: false, message: e.message }; - } - if (!output.success) { - return { - name: "rust", - ok: false, - message: new TextDecoder().decode(output.stderr), - }; - } - return { name: "rust", ok: true }; - }, -}); diff --git a/manager/action/sheldon.ts b/manager/action/sheldon.ts deleted file mode 100644 index 1a78b2b..0000000 --- a/manager/action/sheldon.ts +++ /dev/null @@ -1,39 +0,0 @@ -import type { Action } from "../deps.ts"; - -export const installSheldon = (): Action => ({ - run: async () => { - const p = Deno.run({ - cmd: ["bash"], - stdout: "piped", - stdin: "piped", - }); - - const install = - "curl --proto '=https' -fLsS https://rossmacarthur.github.io/install/crate.sh | bash -s -- --repo rossmacarthur/sheldon --to ~/.local/bin"; - await p.stdin.write(new TextEncoder().encode(install)); - - await p.stdin.close(); - const output = await p.output(); - if (!(await p.status()).success) { - throw new Error(new TextDecoder().decode(output)); - } - p.close(); - }, - stat: async () => { - const checker = new Deno.Command("sheldon", { args: ["--version"] }); - let output: Deno.CommandOutput; - try { - output = await checker.output(); - } catch (e) { - return { name: "sheldon", ok: false, message: e.message }; - } - if (!output.success) { - return { - name: "sheldon", - ok: false, - message: new TextDecoder().decode(output.stderr), - }; - } - return { name: "sheldon", ok: true }; - }, -}); diff --git a/manager/action/starship.ts b/manager/action/starship.ts deleted file mode 100644 index a24c9df..0000000 --- a/manager/action/starship.ts +++ /dev/null @@ -1,38 +0,0 @@ -import type { Action } from "../deps.ts"; - -export const installStarship = (): Action => ({ - run: async () => { - const p = Deno.run({ - cmd: ["bash"], - stdout: "piped", - stdin: "piped", - }); - - const install = "curl -sS https://starship.rs/install.sh | sh -s -- -y"; - await p.stdin.write(new TextEncoder().encode(install)); - - await p.stdin.close(); - const output = await p.output(); - if (!(await p.status()).success) { - throw new Error(new TextDecoder().decode(output)); - } - p.close(); - }, - stat: async () => { - const checker = new Deno.Command("starship", { args: ["--version"] }); - let output: Deno.CommandOutput; - try { - output = await checker.output(); - } catch (e) { - return { name: "starship", ok: false, message: e.message }; - } - if (!output.success) { - return { - name: "starship", - ok: false, - message: new TextDecoder().decode(output.stderr), - }; - } - return { name: "starship", ok: true }; - }, -}); diff --git a/manager/action/volta.ts b/manager/action/volta.ts deleted file mode 100644 index 26260b7..0000000 --- a/manager/action/volta.ts +++ /dev/null @@ -1,38 +0,0 @@ -import type { Action } from "../deps.ts"; - -export const installVolta = (): Action => ({ - run: async () => { - const p = Deno.run({ - cmd: ["bash"], - stdout: "piped", - stdin: "piped", - }); - - const install = "curl https://get.volta.sh | bash"; - await p.stdin.write(new TextEncoder().encode(install)); - - await p.stdin.close(); - const output = await p.output(); - if (!(await p.status()).success) { - throw new Error(new TextDecoder().decode(output)); - } - p.close(); - }, - stat: async () => { - const checker = new Deno.Command("volta", { args: ["--version"] }); - let output: Deno.CommandOutput; - try { - output = await checker.output(); - } catch (e) { - return { name: "volta", ok: false, message: e.message }; - } - if (!output.success) { - return { - name: "volta", - ok: false, - message: new TextDecoder().decode(output.stderr), - }; - } - return { name: "volta", ok: true }; - }, -}); diff --git a/manager/deps.ts b/manager/deps.ts deleted file mode 100644 index 7a40ffb..0000000 --- a/manager/deps.ts +++ /dev/null @@ -1,6 +0,0 @@ -// export { defineTask } from "https://deno.land/x/dotstingray@v0.1.1/core/mod.ts" -// export { link } from "https://deno.land/x/dotstingray@v0.1.1/utils/mod.ts"; - -export { defineTask } from "../deps/core/mod.ts"; -export type { Action, Stat } from "../deps/core/mod.ts"; -export { link, write } from "../deps/utils/mod.ts"; diff --git a/manager/main.ts b/manager/main.ts deleted file mode 100644 index 27d4e70..0000000 --- a/manager/main.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { defineTask, link } from "./deps.ts"; -import { - changeShell, - installDirenv, - installGo, - installPoetry, - installRust, - installSheldon, - installStarship, - installVolta, -} from "./action/mod.ts"; - -const home = Deno.env.get("HOME"); - -if (!home) throw new Error("$HOME is not set"); - -const deploy = defineTask([ - link({ source: "source/bashrc", destination: `${home}/.bashrc` }), - link({ source: "source/zshrc", destination: `${home}/.zshrc` }), - link({ source: "source/gitconfig", destination: `${home}/.gitconfig` }), - link({ - source: "source/starship.toml", - destination: `${home}/.config/starship.toml`, - }), - link({ - source: "source/gpg/gpg-agent.conf", - destination: `${home}/.gnupg/gpg-agent.conf`, - }), - link({ - source: "source/sheldon.toml", - destination: `${home}/.config/sheldon/plugins.toml`, - }), - link({ source: "source/tmux.conf", destination: `${home}/.tmux.conf` }), - /// changeShellはVS Code Devcontainer内でそもそもchshが動かなさそう? - // changeShell({ destination: "zsh" }), - installRust(), - installDirenv(), - installGo(), - installPoetry(), - installSheldon(), - installStarship(), - installVolta(), -]); - -if (Deno.args.includes("deploy")) { - await deploy.run(); -} else if (Deno.args.includes("check")) { - await deploy.stat(); -} else { - console.log(`unknown commands: ${Deno.args}`); - Deno.exit(1); -} diff --git a/manager/remove.ts b/manager/remove.ts deleted file mode 100644 index 9b62e0f..0000000 --- a/manager/remove.ts +++ /dev/null @@ -1,13 +0,0 @@ -import * as rm from "./remove/mod.ts"; - -const home = Deno.env.get("HOME"); - -if (!home) throw new Error("$HOME is not set"); - -await rm.link({ destination: `${home}/.bashrc` }); -await rm.link({ destination: `${home}/.zshrc` }); -await rm.link({ destination: `${home}/.gitconfig` }); -await rm.link({ destination: `${home}/.config/starship.toml` }); -await rm.link({ destination: `${home}/.gnupg/gpg-agent.conf` }); -await rm.link({ destination: `${home}/.config/sheldon/plugins.toml` }); -await rm.link({ destination: `${home}/.tmux.conf` }); diff --git a/manager/remove/mod.ts b/manager/remove/mod.ts deleted file mode 100644 index 1b78986..0000000 --- a/manager/remove/mod.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const link = async ({ destination }: { destination: string }) => { - await Deno.remove(destination, { recursive: true }); -}; diff --git a/source/bashrc b/source/bashrc deleted file mode 100644 index 72e61fd..0000000 --- a/source/bashrc +++ /dev/null @@ -1,140 +0,0 @@ -# ~/.bashrc: executed by bash(1) for non-login shells. -# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) -# for examples - -# If not running interactively, don't do anything -case $- in - *i*) ;; - *) return;; -esac - -# don't put duplicate lines or lines starting with space in the history. -# See bash(1) for more options -HISTCONTROL=ignoreboth - -# append to the history file, don't overwrite it -shopt -s histappend - -# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) -HISTSIZE=1000 -HISTFILESIZE=2000 - -# check the window size after each command and, if necessary, -# update the values of LINES and COLUMNS. -shopt -s checkwinsize - -# If set, the pattern "**" used in a pathname expansion context will -# match all files and zero or more directories and subdirectories. -#shopt -s globstar - -# make less more friendly for non-text input files, see lesspipe(1) -[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" - -# set variable identifying the chroot you work in (used in the prompt below) -if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then - debian_chroot=$(cat /etc/debian_chroot) -fi - -# set a fancy prompt (non-color, unless we know we "want" color) -case "$TERM" in - xterm-color|*-256color) color_prompt=yes;; -esac - -# uncomment for a colored prompt, if the terminal has the capability; turned -# off by default to not distract the user: the focus in a terminal window -# should be on the output of commands, not on the prompt -#force_color_prompt=yes - -if [ -n "$force_color_prompt" ]; then - if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then - # We have color support; assume it's compliant with Ecma-48 - # (ISO/IEC-6429). (Lack of such support is extremely rare, and such - # a case would tend to support setf rather than setaf.) - color_prompt=yes - else - color_prompt= - fi -fi - -if [ "$color_prompt" = yes ]; then - PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' -else - PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' -fi -unset color_prompt force_color_prompt - -# If this is an xterm set the title to user@host:dir -case "$TERM" in -xterm*|rxvt*) - PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" - ;; -*) - ;; -esac - -# enable color support of ls and also add handy aliases -if [ -x /usr/bin/dircolors ]; then - test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" - alias ls='ls --color=auto' - #alias dir='dir --color=auto' - #alias vdir='vdir --color=auto' - - alias grep='grep --color=auto' - alias fgrep='fgrep --color=auto' - alias egrep='egrep --color=auto' -fi - -# colored GCC warnings and errors -#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' - -# some more ls aliases -alias ll='ls -alF' -alias la='ls -A' -alias l='ls -CF' - -# Add an "alert" alias for long running commands. Use like so: -# sleep 10; alert -alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' - -# Alias definitions. -# You may want to put all your additions into a separate file like -# ~/.bash_aliases, instead of adding them here directly. -# See /usr/share/doc/bash-doc/examples in the bash-doc package. - -if [ -f ~/.bash_aliases ]; then - . ~/.bash_aliases -fi - -# enable programmable completion features (you don't need to enable -# this, if it's already enabled in /etc/bash.bashrc and /etc/profile -# sources /etc/bash.bashrc). -if ! shopt -oq posix; then - if [ -f /usr/share/bash-completion/bash_completion ]; then - . /usr/share/bash-completion/bash_completion - elif [ -f /etc/bash_completion ]; then - . /etc/bash_completion - fi -fi - -## PATH -export PATH=$PATH:/usr/local/go/bin # go -export PATH=$PATH:$HOME/go/bin # go get -# export PATH=$HOME/.nodebrew/current/bin:$PATH # nodebrew -export PATH="$HOME/.local/bin:$PATH" # oj -export PATH="$HOME/.poetry/bin:$PATH" # poetry - -## alias -alias ga='cd $(ghq list --full-path | fzf)' # search repo -# alias gh='hub browse $(ghq list | peco | cut -d "/" -f 2,3)' -alias g='cd $(ghq list --full-path github.com/uta8a | fzf)' # search `github.com/uta8a` repo -alias guu='cd $(ghq root)/$(ghq list | grep -vE "*github.com/uta8a*" | fzf)' -alias vv='vim -u $HOME/.ghq/github.com/uta8a/book.compilerbook/.vimrc' - -## config -export GPG_TTY=$(tty) # gpg -. "$HOME/.cargo/env" # rust -eval "$(starship init bash)" # starship -export VOLTA_HOME="$HOME/.volta" -export PATH="$VOLTA_HOME/bin:$PATH" - -[ -f ~/.fzf.bash ] && source ~/.fzf.bash diff --git a/source/gitconfig b/source/gitconfig deleted file mode 100644 index 6e26a77..0000000 --- a/source/gitconfig +++ /dev/null @@ -1,16 +0,0 @@ -[remind] - root = ~/.ghq/github.com/uta8a -[ghq] - root = ~/.ghq -[user] - name = "Masanori Tani" - email = "uta8a@uta8a.org" -[core] - editor = vim -[commit] - gpgsign = false # true - -[credential "https://github.com"] - helper = !gh auth git-credential -[credential "https://gist.github.com"] - helper = !gh auth git-credential diff --git a/source/gpg/gpg-agent.conf b/source/gpg/gpg-agent.conf deleted file mode 100644 index 4b024c2..0000000 --- a/source/gpg/gpg-agent.conf +++ /dev/null @@ -1,2 +0,0 @@ -max-cache-ttl 60480000 -default-cache-ttl 604800000 diff --git a/source/sheldon.toml b/source/sheldon.toml deleted file mode 100644 index 79a2f12..0000000 --- a/source/sheldon.toml +++ /dev/null @@ -1,26 +0,0 @@ -# `sheldon` configuration file -# ---------------------------- -# -# You can modify this file directly or you can use one of the following -# `sheldon` commands which are provided to assist in editing the config file: -# -# - `sheldon add` to add a new plugin to the config file -# - `sheldon edit` to open up the config file in the default editor -# - `sheldon remove` to remove a plugin from the config file -# -# See the documentation for more https://github.com/rossmacarthur/sheldon#readme - -shell = "zsh" - -[plugins] - -# For example: -# -# [plugins.base16] -# github = "chriskempson/base16-shell" - -[plugins.zsh-autosuggestions] -github = "zsh-users/zsh-autosuggestions" - -[plugins.zsh-completions] -github = "zsh-users/zsh-completions" diff --git a/source/starship.toml b/source/starship.toml deleted file mode 100644 index 7ea68b3..0000000 --- a/source/starship.toml +++ /dev/null @@ -1,47 +0,0 @@ -# ~/.config/starship.toml - -# Use custom format -format = """ -$username$hostname: $directory$status$git_branch -${custom.devbox} """ - -# Wait 10 milliseconds for starship to check files under the current directory. -scan_timeout = 10 - -# Disable the blank line at the start of the prompt -add_newline = true - -[directory] -format = "[$path]($style) [$read_only]($read_only_style)" -style = "bold bg:black" -truncation_length = 3 -truncation_symbol = "" - -[status] -disabled = false -format = '[\[$symbol $common_meaning$signal_name$maybe_int\]]($style) ' -map_symbol = true -style = "bg:black" - -[hostname] -disabled = false -format = "[@$hostname](#fbbef5 bold underline)" -ssh_only = false - -[username] -disabled = false -format = "[$user]($style)" -show_always = true -style_root = "#fbbef5 bold underline" -style_user = "#fbbef5 bold underline" - -[git_branch] -symbol = "🌱 " -format = "[$symbol$branch]($style)" -truncation_symbol = "" - -[custom.devbox] -command = 'if [ "$DEVBOX_SHELL_ENABLED" = "1" ]; then echo "📦 devbox>"; else echo "$"; fi' -when = true -style = 'bold white' -format = '[$output]($style)' diff --git a/source/tmux.conf b/source/tmux.conf deleted file mode 100644 index e69de29..0000000 diff --git a/source/zshrc b/source/zshrc deleted file mode 100644 index e8b5f63..0000000 --- a/source/zshrc +++ /dev/null @@ -1,78 +0,0 @@ -# Set up the prompt - -# autoload -Uz promptinit -# promptinit -# prompt adam1 - -setopt histignorealldups sharehistory - -# Use emacs keybindings even if our EDITOR is set to vi -bindkey -e - -# Keep 10000 lines of history within the shell and save it to ~/.zsh_history: -HISTSIZE=10000 -SAVEHIST=10000 -HISTFILE=~/.zsh_history - -# . $HOME/.asdf/asdf.sh # asdf -# fpath=(${ASDF_DIR}/completions $fpath) # asdf completion -# Use modern completion system -autoload -Uz compinit -compinit -# autoload -U bashcompinit && bashcompinit # awscli completion -# complete -C $HOME/.asdf/shims/aws_completer aws # awscli completion - -# zstyle ':completion:*' auto-description 'specify: %d' -# zstyle ':completion:*' completer _expand _complete _correct _approximate -# zstyle ':completion:*' format 'Completing %d' -# zstyle ':completion:*' group-name '' -# zstyle ':completion:*' menu select=2 -# eval "$(dircolors -b)" -# zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} -# zstyle ':completion:*' list-colors '' -# zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s -# zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*' -# zstyle ':completion:*' menu select=long -# zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s -# zstyle ':completion:*' use-compctl false -# zstyle ':completion:*' verbose true - -# zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' -# zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd' - -## PATH -export PATH="$PATH:/usr/local/bin/go/bin" # go -export PATH="$PATH:$HOME/go/bin" # go get / install go tool -export VOLTA_HOME="$HOME/.volta" # volta / node -export PATH="$PATH:$VOLTA_HOME/bin" # volta / node -# export PATH="$PATH:$HOME/.local/bin" # oj / online-judge-tools -export PATH="$PATH:$HOME/.poetry/bin" # poetry / python -export PATH="$PATH:$HOME/.cargo/bin" # cargo / rust -# export PATH="$PATH:$HOME/filez/tmp/buildg" # buildg / dockerfile debug tool -# export PATH="$PATH:$HOME/filez/zig/zig-linux-x86_64-0.10.0-dev.2998+a45592715" # zig / ziglang -export PATH="$PATH:$HOME/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin" # LSP / rust-analyzer -export DENO_INSTALL="$HOME/.deno" -export PATH="$PATH:$DENO_INSTALL/bin" -# export JAVA_HOME=`echo $(dirname $(readlink $(readlink $(which java)))) | sed -e 's/\/bin$//g' | sed -e 's/\/jre$//g'` -## Env -export EDITOR=vim - -## alias -alias ga='cd $(ghq list --full-path | fzf)' # search repo -alias gb='g && gh browse' # search my repo and open in browser, when in VS Code Terminal -alias g='cd $(ghq list --full-path github.com/uta8a | fzf)' # search `github.com/uta8a` repo -alias guu='cd $(ghq root)/$(ghq list | grep -vE "*github.com/uta8a*" | fzf)' # exclude uta8a repo search -alias vv='nvim -c "Telescope file_browser path=~/.ghq/github.com/uta8a"' # vim starts with ghq -## ps -aux | grep cloudflared で確認 -alias remote-ssh='sudo systemctl start cloudflared.service' # cloudflared access tunnel start -alias remote-ssh-stop='sudo systemctl stop cloudflared.service' # cloudflared access tunnel stop -alias ide="~/.scripts/ide.sh" - -## config -eval "$(sheldon source)" # sheldon / zsh plugin manager -export GPG_TTY=$(tty) # gpg -eval "$(starship init zsh)" # starship - - -[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh -eval "$(direnv hook zsh)"