I am wonder how to start emacsclient in a new maximized frame.
emacsclient -c
starts a new frame but the man page indicated no way to maximize this frame. There are no such options as --maximized.
Warning : this is no a duplicate from the post : How do I provide a command-line option to emacsclient?. Indeed, the answers of this post don't fix my issue. They use the -F option which seems to be documented on the man for them but which is not present in my man emacsclient (in debian sid) and the -F option does not work in my case :
$ emacsclient -c -F "((fullscreen . maximized))"
emacsclient: unrecognized option '-F'
Try `emacsclient --help' for more information
Here is the result of emacsclient --help for information :
emacsclient --help
Usage: emacsclient [OPTIONS] FILE...
Tell the Emacs server to visit the specified files.
Every FILE can be either just a FILENAME or [+LINE[:COLUMN]] FILENAME.
The following OPTIONS are accepted:
-V, --version Just print version info and return
-H, --help Print this usage information message
-nw, -t, --tty Open a new Emacs frame on the current terminal
-c, --create-frame Create a new frame instead of trying to
use the current Emacs frame
-e, --eval Evaluate the FILE arguments as ELisp expressions
-n, --no-wait Don't wait for the server to return
-d DISPLAY, --display=DISPLAY
Visit the file in the given display
-s SOCKET, --socket-name=SOCKET
Set filename of the UNIX socket for communication
-f SERVER, --server-file=SERVER
Set filename of the TCP authentication file
-a EDITOR, --alternate-editor=EDITOR
Editor to fallback to if the server is not running
If EDITOR is the empty string, start Emacs in daemon
mode and try connecting again
Report bugs with M-x report-emacs-bug.
(add-to-list 'default-frame-alist '(fullscreen . fullboth))
in .emacs does the job.
Here's a minimal working example from Evgeny's answer
emacsclient -c -F "'(fullscreen . fullboth)"
emacsclient -c -F "'(fullscreen . maximized)"
alias ecx="emacsclient -c -F \"'(fullscreen . maximized)\""
emacsclient -c -F "((width . 100) (height . 100) (left . 400))"
You can try using ‘-F alist’ or ‘--frame-parameters=alist’ option.
alist format is described here
You can select width, height and font so that you'll have comfortable window size.
Related
I've installed a new dev machine using Ubuntu 14.02. I have also installed all the relevant software. php/apache2/sublime/composer etc.
I'd like to be able to open files with a sublime or subl command in the terminal, but can't seem to find the command to point things correctly.
My sublime executable resides here...
/opt/sublime_text/sublime_text
in /usr/bin/subl I have the command
#!/bin/sh
exec /opt/sublime_text/sublime_text "$#"
I just can't find the command in the terminal to make it happen. The sublime documentation points to mac instructions, but I'm too newby to translate.
Any suggestions?
$# in a shell script basically copies all arguments given to the shell script (after the name of the script) and places them at that point during execution of the script.
For example,
if you were to run subl test.txt, it would be as though you are running exec /opt/sublime_text/sublime_text "test.txt".
Now, /opt/sublime_text/sublime_text --help or subl --help gives us help text which shows the usage as well.
Sublime Text build 3065
Usage: sublime_text [arguments] [files] edit the given files
or: sublime_text [arguments] [directories] open the given directories
Arguments:
--project <project>: Load the given project
--command <command>: Run the given command
-n or --new-window: Open a new window
-a or --add: Add folders to the current window
-w or --wait: Wait for the files to be closed before returning
-b or --background: Don't activate the application
-h or --help: Show help (this message) and exit
-v or --version: Show version and exit
Filenames may be given a :line or :line:column suffix to open at a specific
location.
If you pass more than one parameter, then all of them are also treated the same. So, if you ran subl file1.txt file2.cpp file3.html then it'd open all 3 of those files.
As per Mathias comment in my question I found the answer here...
How can I open Sublime Text 2 files from the command line in linux to a tab, not a new window
I'm trying to write a script that opens 3 terminal windows and runs a couple of statements in those windows. But it's not working. I've tried using the && operator as well as " " but I can't get it to work. I've also tried it with the statements on the same line as well as below each other. The error I'm receiving is that the cd child process failed to execute stating that there is no such Directory. But the directory ~/Projects/catkin_ws is correct.
#!/bin/bash
# ROS opstarten
gnome-terminal -e cd ~/Projects/catkin_ws source devel/setup.bash roscore
# gazebo opstarten
gnome-terminal -e cd ~/Projects/catkin_ws
source devel/setup.bash
roslaunch cvg_sim_gazebo Qr_Chessboard.launch
# programma opstarten
gnome-terminal -e cd ~/Projects/catkin_ws
source devel/setup.bash
/usr/bin/python /home/user/Projects/catkin_ws/src/drone7_project/src/drone_program.py
If you really want to run them on separate terminals programmatically you can use a terminal multiplexer such as GNU screen for that.
First you have to start a session:
$ screen -S demo
Then open all the terminals you need inside it with Ctrl-a c and configure their environments as needed, and then you can send commands to any screen page (tab) from your script using the "-X stuff" option (to stuff characters into a virtual screen terminal):
$ screen -S demo -p <page_number> -X stuff 'ls -l
'
Note that you also have to send the newline character to really enter the command.
I try add main enviornment path to bash and I success run roscore in another terminal.
#!/bin/bash
# ROS opstarten
PATH=/opt/ros/kinetic/bin
gnome-terminal --tab -e /opt/ros/kinetic/bin/roscore
You need to quote the statements and use a statement separator between them.
gnome-terminal -e 'cd ~/Projects/catkin_ws; source devel/setup.bash; /usr/bin/python /home/user/Projects/catkin_ws/src/drone7_project/src/drone_program.py'
or alternatively with newline as statement separator
gnome-terminal -e 'cd ~/Projects/catkin_ws
source devel/setup.bash
/usr/bin/python /home/user/Projects/catkin_ws/src/drone7_project/src/drone_program.py'
However, running these commands in a separate terminal seems rather misdirected. Why don't you run them as regular background jobs in your current terminal with output to a file?
The directory where a tmux session is started in will be the directory that new windows start at. How do I change this starting directory without closing the tmux session?
The way to do this is to detach from the session (^b d with the default keybindings) and then specify a different directory when you reattach to it. When attaching to a session, use the -c flag to specify the working directory. Here's an example:
$ tmux list-sessions
tmuxwtfbbq: 3 windows (created Tue Apr 5 14:25:48 2016) [190x49]
$ tmux attach-session -t tmuxwtfbbq -c /home/chuck/new_default_directory
This setting will be persisted - after you've reset the working directory, you won't need to keep specifying it every time you reattach to the session.
For the record, I'm on tmux version 2.0 (though I don't think it matters - I couldn't find anything about adding a -c option to the attach-session command in the change logs so I assume it's been there for quite a while).
Chucksmash's answer is a good one, but it can also be achieved without using the session if you like. The command attach-session is also available in the tmux command prompt; and the target session can be specified as the "current" session using a dot.
attach-session -t . -c /path/to/new/directory
Here's how you can change the tmux session's working directory without detaching the session, and without needing use to the <prefix> keystrokes:
(Option 1) Enter the directory at tmux command prompt:
tmux command-prompt "attach -c %1"
...will open a command prompt, then you type the working directory you want ~/my/dir and press ENTER
(Option 2) Provide the directory on the in-pane command line:
# Execute this in one of the shell panes of within your tmux session:
tmux command-prompt -I $PWD -P "New session dir:" "attach -c %1"
With this approach, the prompt for new-directory is pre-populated with the current dir of the pane which launched the command. Of course you can substitute anything else for $PWD if you please.
Want a shell function?
I have added this to my shell initialization:
# Change the current directory for a tmux session, which determines
# the starting dir for new windows/panes:
function tmux-cwd {
tmux command-prompt -I $PWD -P "New session dir:" "attach -c %1"
}
With all of these options, any future new windows will start in the given dir.
Note: attach, attach-session, and a are all aliases for each other. The tmux command-prompt has many other powers, it's worth reading the man page
use attach-session -c from command prompt or in a binding.
I have bindings to use the current directory automatically, using the provided pane_current_path var.
I have this bound to M-c, to update the current path.
# tmux.conf
# set default directory for new windows in this session to current directory:
bind M-c attach-session -c "#{pane_current_path}"
Similarly, when I just want another window in the current directory without changing the default, I have a binding on C:
# tmux.conf
# open a new window in the current directory
bind C new-window -c "#{pane_current_path}"
My bindings:
c: open a new window in session default directory [default binding]
C: open a new window in current directory
M-c: set session default directory to current directory
Happy Tmuxing!
The default working directory can be changed from the command line like this:
TMUX= tmux -C attach -c directory -t session </dev/null >/dev/null
Compared to command-prompt, for example, this has the advantage that no interactive prompts or confirmations are produced, so this can be run in a script. Unsetting TMUX allows attaching from inside a session, the option -C turns on control mode for non-interactive use and redirecting from /dev/null causes the client to detach immediately, while still updating the default directory. Redirecting the output is not necessary, but it suppresses messages.
I want to write a script that gets the active tmux window's name and uses it as a variable for my vim session. Is this possible? I looked through the tmux manual and didn't see anything.
You can use display-message -p to query the name of the active window (among other things):
tmux display-message -p '#W'
If you want to target a specific window, you can use -t:
tmux -t «target-window» display-message -p '#W'
See the man page for the various ways to specify a target window (search for “target-window” in the Commands section).
SYNOPSIS
tmux [-28lquvVC] [-c shell-command] [-f file] [-L socket-name] [-S socket-path] [command [flags]]
SKIP
command [flags]
This specifies one of a set of commands used to control
tmux, as described in the following sections. If no commands are
specified, the new-session command is assumed.
You can find full list of tmux commands (two last arguments) in the manual, but now you interest is 'list-windows'.
tmux list-windows
0: zsh [156x40] [layout aebd,156x40,0,0,0] #0
1: mc [156x40] [layout aebe,156x40,0,0,1] #1 (active)
As you can see active window marked as '(active)'. This is what you were looking for?
First list all window names and active status, the active one will end with 1, then extract the name before it
tmux lsw -F '#{window_name}#{window_active}'|sed -n 's|^\(.*\)1$|\1|p'
I have an alias in bash that runs emacsclient if emacs daemon is already running and start emacs otherwise. However, in the event that a fresh instance of emacs is fired up, can I make it run in the background so I can still use that terminal (or close it)? In my bash profile, I have
alias ec="/usr/bin/emacsclient.emacs-snapshot -n -c -a /usr/bin/emacs-snapshot"
And I might be at the terminal and type
$ ec newfile
If emacs daemon is not already running, is there an alias I can create to make the line above do the equivalent of
$ emacs newfile &
instead of
$ emacs newfile
(I should also mention that I am using Linux Ubuntu and emacs-snapshot is assigned to the alias, 'emacs').
Thanks much!
Instead of calling /usr/bin/emacs-snapshot directly, write a script that calls /usr/bin/emacs-snapshot in the background and then returns:
#!/bin/sh
case $# in
0) /usr/bin/emacs-snapshot &
*) /usr/bin/emacs-snapshot "$#" &
esac
Then you call the script in the ordinary way; it will launch a background emacs process and return immediately.
If you want to get fancy you can use /bin/bash and disown the process after the esac (get the pid with $!).
While this is not the direct answer to your question, this is the more elegant way to "start emacs deamon or run emacsclient otherwise". Create the following alias: alias emacs=emacsclient -c -a "". As of man emacsclient:
-a, --alternate-editor=EDITOR
...
If the value of EDITOR is the empty string, run `emacs --daemon' to start Emacs in daemon mode, and try to connect to it.