Ubuntu user 備忘録


# Keyboard

Show applications
\> regions and languages 
\> input sources 
- Add "Japanese (Mozc)"
- Add "English (US)"

(Reference) https://geek-memo.com/ubukey/

```shell

$ sudo dpkg-reconfigure keyboard-configuration

Your console font configuration will be updated the next time your system
boots. If you want to update it now, run 'setupcon' from a virtual console.
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools (0.136ubuntu6.3) ...
update-initramfs: Generating /boot/initrd.img-5.8.0-38-generic
```
![Screenshot from 2021-01-26 17-58-21.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/610740/cbac702d-506e-c854-ea67-2c7d70ba82a8.png)


# Keyboard shortcut

Show applications
\> keyboard shortcuts

ex) Super + space > New input mode

Shortcuts for Terminal.app can be set via preferences in Terminal.app


# Python

(Reference) 
- https://qiita.com/y__sama/items/5b62d31cb7e6ed50f02c 
- https://qiita.com/y__sama/items/f732bb7bec2bff355b69

Make an empty file first. 

```shell
$ nano .bash_profile
```


```python

$ git clone https://github.com/yyuu/pyenv.git ~/.pyenv
$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
$ source ~/.bash_profile
```


```shell

$ pyenv install anaconda3-5.2.0 
Downloading Anaconda3-5.2.0-Linux-x86_64.sh...
-> https://repo.continuum.io/archive/Anaconda3-5.2.0-Linux-x86_64.sh
Installing Anaconda3-5.2.0-Linux-x86_64...
Installed Anaconda3-5.2.0-Linux-x86_64 to /home/nemo_kohei/.pyenv/versions/anaconda3-5.2.0

$ pyenv rehash

$ pyenv global anaconda3-5.2.0

$ echo 'alias activate="source $PYENV_ROOT/versions/anaconda3-5.2.0/bin/activate"' >> ~/.bash_profile

$ source .bash_profile 

$ python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

$ conda update conda

Solving environment: done

## Package Plan ##

  environment location: /home/nemo_kohei/.pyenv/versions/anaconda3-5.2.0

  added / updated specs: 
    - conda

The following packages will be downloaded:
...
    pysocks-1.7.1              |           py37_1          27 KB
...

The following packages will be UPDATED:
...
    pyopenssl:              18.0.0-py36_0           --> 19.0.0-py37_0           
    pysocks:                1.6.8-py36_0            --> 1.7.1-py37_1  
    python:                 3.6.5-hc3d631a_2        --> 3.7.0-hc3d631a_0        
...

Proceed ([y]/n)? y
...
python-3.7.0         | 31.7 MB | ############################################################################################################################ | 100% 
...
Preparing transaction: done
Verifying transaction: done
Executing transaction: done


$ python
Python 3.7.0 (default, Jun 28 2018, 13:15:42) 
[GCC 7.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

```


```shell
$ conda create -n py37 python=3.7 anaconda
...
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate py37
#
# To deactivate an active environment, use
#
#     $ conda deactivate

$ conda activate py37

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - fish
  - tcsh
  - xonsh
  - zsh
  - powershell

See 'conda init --help' for more information and options.

IMPORTANT: You may need to close and restart your shell after running 'conda init'.

$ conda init --help
usage: conda init [-h] [--all] [--reverse] [--json] [-v] [-q] [-d]
                  [shells [shells ...]]

Initialize conda for shell interaction. [Experimental]

Options:

positional arguments:
  shells         One or more shells to be initialized. If not given, the
                 default value is 'bash' on unix and 'cmd.exe' on Windows. Use
                 the '--all' flag to initialize all shells. Currently
                 compatible shells are {bash, fish, powershell, tcsh, xonsh,
                 zsh}

optional arguments:
  -h, --help     Show this help message and exit.
  --all          Initialize all currently available shells.
  -d, --dry-run  Only display what would have been done.

setup type:
  --reverse      Undo past effects of conda init.

Output, Prompt, and Flow Control Options:
  --json         Report all output as json. Suitable for using conda
                 programmatically.
  -v, --verbose  Use once for info, twice for debug, three times for trace.
  -q, --quiet    Do not display progress bar.

Key parts of conda's functionality require that it interact directly with the shell
within which conda is being invoked. The `conda activate` and `conda deactivate` commands
specifically are shell-level commands. That is, they affect the state (e.g. environment
variables) of the shell context being interacted with. Other core commands, like
`conda create` and `conda install`, also necessarily interact with the shell environment.
They're therefore implemented in ways specific to each shell. Each shell must be configured
to make use of them.

This command makes changes to your system that are specific and customized for each shell.
To see the specific files and locations on your system that will be affected before, use the
'--dry-run' flag.  To see the exact changes that are being or will be made to each location,
use the '--verbose' flag.

IMPORTANT: After running `conda init`, most shells will need to be closed and restarted
           for changes to take effect.


$ conda init bash
no change     /home/kohei/.pyenv/versions/anaconda3-5.2.0/condabin/conda
no change     /home/kohei/.pyenv/versions/anaconda3-5.2.0/bin/conda
no change     /home/kohei/.pyenv/versions/anaconda3-5.2.0/bin/conda-env
no change     /home/kohei/.pyenv/versions/anaconda3-5.2.0/bin/activate
no change     /home/kohei/.pyenv/versions/anaconda3-5.2.0/bin/deactivate
no change     /home/kohei/.pyenv/versions/anaconda3-5.2.0/etc/profile.d/conda.sh
no change     /home/kohei/.pyenv/versions/anaconda3-5.2.0/etc/fish/conf.d/conda.fish
no change     /home/kohei/.pyenv/versions/anaconda3-5.2.0/shell/condabin/Conda.psm1
no change     /home/kohei/.pyenv/versions/anaconda3-5.2.0/shell/condabin/conda-hook.ps1
no change     /home/kohei/.pyenv/versions/anaconda3-5.2.0/lib/python3.7/site-packages/xontrib/conda.xsh
no change     /home/kohei/.pyenv/versions/anaconda3-5.2.0/etc/profile.d/conda.csh
modified      /home/kohei/.bashrc

==> For changes to take effect, close and re-open your current shell. <==


```


"close and re-open your current shell."と言われたので、新しいターミナルウィンドウを開く。


```shell
(base) kohei@kohei-VirtualBox:~$ conda activate py37
(py37) kohei@kohei-VirtualBox:~$ python
Python 3.7.9 (default, Aug 31 2020, 12:42:55) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
(py37) kohei@kohei-VirtualBox:~$ 

```


# Appendix

## Screenshot


```shell
$ gnome-screenshot --window --delay=5
```

Take a screenshot of the active window. (This command is executed 5 seconds after hitting this command.)